yes I do, as a matter of fact. Although explaining it is a bit heavy,
so I'll give it my best shot:
The CreateForm() reads the template which is returned as a FOR XML
AUTO query from the SQL server. It transforms it into ASP.NET code by
applying the stylesheet, then ParseControl will actually render it on
the page from a text stream. Then, ProcessResults reads the template
again, and walks down through it. In this example, it's building an
XML document from the results, but you needn't do that if you don't
want to. I just wrote this XML in, XML out so that I can change the
backend at some point in the future if I decide to dump SQL server.
Then all I'd have to do is change the DB calls to file reads or
whatever.
Notice that you can't use ParseControl to insert custom user controls
(peoplepicker and duedatepicker), you have to have a placeholder in
there, and substitute your controls in as childcontrols after the fact.
I've cut a bit of the end off my ProcessResults but you get the idea of
what you're asking from this here.
I have for you the template from the database, the xslt stylesheet, and
the code I used
Some of this create survey was from a completely different form I had,
so the comments and switch statements might not apply to this template.
It just goes to show you how little you have to do to the code to
completely change the form.
Have fun, and post back if you have some questions.
-----------------------------------------Template Document from the
Database ----------------
<ItemType ITId="1" ITName="New Employee" ITAppLevel="6">
<TypeTemplate TTId="1" TTNo="1" ITId="1" TTName="Name" TTSize="100"
TTDesc="Name of the new employee."/>
<TypeTemplate TTId="2" TTNo="2" ITId="1" TTName="Locator Code"
TTSize="10" TTDesc="Locator code of the new employee."/>
<TypeTemplate TTId="5" TTNo="3" ITId="1" TTName="Contractor"
TTSize="5" TTDesc="Is this person a contractor?"/>
<TypeTemplate TTId="6" TTNo="4" ITId="1" TTName="Start Date"
TTSize="12" TTDesc="Indicate the start date."/>
<TypeTemplate TTId="26" TTNo="5" ITId="1" TTName="Badge" TTSize="12"
TTDesc="Specify the badge number of the new employee (if known)"/>
<TypeTemplate TTId="27" TTNo="6" ITId="1" TTName="Manager"
TTSize="12" TTDesc="Who will be the manager of the new employee?"/>
</ItemType>
<ItemType ITId="2" ITName="Directory Access" ITAppLevel="1">
<TypeTemplate TTId="7" TTNo="1" ITId="2" TTName="Directory"
TTSize="255" TTDesc="What directory are you requesting access to?"/>
<TypeTemplate TTId="8" TTNo="2" ITId="2" TTName="Access Level"
TTSize="20" TTDesc="What level of access are you requesting to this
directory?"/>
<TypeTemplate TTId="21" TTNo="3" ITId="2" TTName="PMt" TTSize="12"
TTDesc="Specify the Data Owner of this area."/>
<TypeTemplate TTId="42" TTNo="4" ITId="2" TTName="Directory Type"
TTSize="128" TTDesc="Specify the type of Directory"/>
</ItemType>
<ItemType ITId="4" ITName="Unix Account" ITAppLevel="2">
<TypeTemplate TTId="29" TTNo="1" ITId="4" TTName="Host Name"
TTSize="25" TTDesc="On which unix host are you requesting an
account?"/>
</ItemType>
<ItemType ITId="5" ITName="SecurID" ITAppLevel="6">
<TypeTemplate TTId="28" TTNo="1" ITId="5" TTName="Used For"
TTSize="32" TTDesc="WWW Timesheet if for offsite timesheets only. All
others choose VPN."/>
</ItemType>
<ItemType ITId="6" ITName="CostPoint Access" ITAppLevel="2">
<TypeTemplate TTId="39" TTNo="1" ITId="6" TTName="Type of Access"
TTSize="64" TTDesc="Admin or Client level access?"/>
</ItemType>
<ItemType ITId="7" ITName="Create New FileNET Area" ITAppLevel="2">
<TypeTemplate TTId="31" TTNo="1" ITId="7" TTName="Area Requested"
TTSize="2048" TTDesc="To which area in FileNET are you requesting
access?"/>
</ItemType>
<ItemType ITId="8" ITName="ClearCase Client Install" ITAppLevel="2">
<TypeTemplate TTId="33" TTNo="1" ITId="8" TTName="Type of
Installation" TTSize="12" TTDesc="Select whether this will be a Basic
or Developer installation."/>
</ItemType>
<ItemType ITId="10" ITName="VSS/VI" ITAppLevel="2">
<TypeTemplate TTId="40" TTNo="1" ITId="10" TTName="Type of Request"
TTSize="64" TTDesc="Vss or VI?"/>
<TypeTemplate TTId="41" TTNo="2" ITId="10" TTName="Full Path of Area
Requested" TTSize="128" TTDesc="Specify the project or area to which
you are requesting rights."/>
<TypeTemplate TTId="43" TTNo="3" ITId="10" TTName="Need Client
Install" TTSize="64" TTDesc="Check 'yes' if you need the
client installed"/>
<TypeTemplate TTId="44" TTNo="4" ITId="10" TTName="Need User Account"
TTSize="64" TTDesc="Check 'yes' if you need a user account
for VSS or VI"/>
</ItemType>
<ItemType ITId="11" ITName="Local Administrator" ITAppLevel="14">
<TypeTemplate TTId="10" TTNo="1" ITId="11" TTName="Justification"
TTSize="2048" TTDesc="Specify a justification for requesting local
admin rights."/>
<TypeTemplate TTId="11" TTNo="2" ITId="11" TTName="Machine Tag"
TTSize="10" TTDesc="The tag number of the machine to which you are
requesting local admin rights."/>
</ItemType>
<ItemType ITId="12" ITName="FTP Access" ITAppLevel="2">
<TypeTemplate TTId="12" TTNo="1" ITId="12" TTName="Description"
TTSize="2048" TTDesc="Any information relevant to the FTP directory
access or creation request."/>
<TypeTemplate TTId="32" TTNo="1" ITId="12" TTName="Directory or
Project" TTSize="2048" TTDesc="Enter desired name for directory
creation, or specify the project to which you need access."/>
</ItemType>
<ItemType ITId="13" ITName="Outlook Email" ITAppLevel="2">
<TypeTemplate/>
</ItemType>
<ItemType ITId="14" ITName="Unix Email" ITAppLevel="2">
<TypeTemplate/>
</ItemType>
<ItemType ITId="15" ITName="Mail Forward" ITAppLevel="10">
<TypeTemplate TTId="13" TTNo="1" ITId="15" TTName="Forward
Destination" TTSize="50" TTDesc="Specify the email address to which you
are requesting your email be forwarded."/>
</ItemType>
<ItemType ITId="16" ITName="Private User Folder" ITAppLevel="2">
<TypeTemplate TTId="14" TTNo="1" ITId="16" TTName="Action"
TTSize="16" TTDesc="Add or remove this folder?"/>
</ItemType>
<ItemType ITId="17" ITName="Shared Project Folder" ITAppLevel="2">
<TypeTemplate TTId="15" TTNo="1" ITId="17" TTName="Action Required"
TTSize="16" TTDesc="Specify what action this request requires."/>
<TypeTemplate TTId="17" TTNo="2" ITId="17" TTName="Primary Data
Owner" TTSize="256" TTDesc="Specify who will be responsible for the
data stored in this area."/>
<TypeTemplate TTId="18" TTNo="3" ITId="17" TTName="Backup Data Owner"
TTSize="256" TTDesc="Specify an alternate point of contact."/>
<TypeTemplate TTId="19" TTNo="4" ITId="17" TTName="Project Name"
TTSize="128" TTDesc="What project will this area be associated with?"/>
<TypeTemplate TTId="25" TTNo="5" ITId="17" TTName="Folder Name"
TTSize="25" TTDesc="Specify desired folder name. We may remove spaces
and special characters if necessary."/>
</ItemType>
<ItemType ITId="18" ITName="Specific Description" ITAppLevel="0">
<TypeTemplate TTId="30" TTNo="1" ITId="18" TTName="Details"
TTSize="2048" TTDesc="Add any detail you could not specify in other
areas of the request."/>
</ItemType>
------------------------------------------StyleSheet------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove"
xmlns:uc1="remove">
<xsl

utput method="xml" indent="yes" encoding="utf-8"
omit-xml-declaration="yes"/>
<xsl:template match="/">
<table rules="all" border="1" cellpadding="2">
<xsl:for-each select="//ItemType">
<tr>
<td align="left">
<asp:Label id="Granter_{position()}" runat="server" >
<b>
<xsl:value-of select="@ITName" />
</b>
</asp:Label>
</td>
</tr>
<tr>
<xsl:if test="./TypeTemplate[@TTName]">
<td valign="top">
<table rules="all" cellpadding="2" width="100%">
<xsl:for-each select="TypeTemplate[@TTName]">
<tr>
<td align="center">
<xsl:value-of select="@TTName"/>
</td>
<td align="left" width="250">
<xsl:choose>
<xsl:when test="translate(@TTName, ' ','_') =
string('Locator_Code')">
<asp

ropDownList runat="server" id="Locator_Code"
title="{@TTDescription}">
<asp:ListItem value="" title="{@TTDescription}" >-- Select
--</asp:ListItem>
<asp:ListItem value="Location1" />
<asp:ListItem value="Location2" />
</asp

ropDownList>
</xsl:when>
<xsl:when test="@TTName = string('Index Tabs')">
<asp:RadioButtonList id="Index_Tabs" RepeatDirection="Horizontal"
runat="server" title="{@TTDescription}">
<asp:ListItem value="1" >Yes</asp:ListItem>
<asp:ListItem value="2" >No</asp:ListItem>
</asp:RadioButtonList>
</xsl:when>
<xsl:when test="@TTName = string('Collating')">
<asp:RadioButtonList id="Collating" RepeatDirection="Horizontal"
runat="server" title="{@TTDescription}">
<asp:ListItem value="1" >Yes</asp:ListItem>
<asp:ListItem value="2" >No</asp:ListItem>
</asp:RadioButtonList>
</xsl:when>
<xsl:when test="@TTName = string('Cover Option')">
<asp:RadioButtonList id="Cover_Option" RepeatDirection="Vertical"
runat="server" title="{@TTDescription}">
<asp:ListItem value="1" >Color</asp:ListItem>
<asp:ListItem value="2" >Black & White</asp:ListItem>
</asp:RadioButtonList>
</xsl:when>
<xsl:when test="@TTName = string('Color Sides per Sheet')">
<asp:RadioButtonList id="Color_Sides_per_Sheet"
RepeatDirection="Horizontal" runat="server" title="{@TTDescription}">
<asp:ListItem value="1" >One</asp:ListItem>
<asp:ListItem value="2" >Two</asp:ListItem>
</asp:RadioButtonList>
</xsl:when>
<xsl:when test="@TTName = string('Black and White Sides per
Sheet')">
<asp:RadioButtonList id="Black_and_White_Sides_per_Sheet"
RepeatDirection="Horizontal" runat="server" title="{@TTDescription}">
<asp:ListItem value="1" >One</asp:ListItem>
<asp:ListItem value="2" >Two</asp:ListItem>
</asp:RadioButtonList>
</xsl:when>
<xsl:when test="@TTName = string('Cover Stock')">
<asp

ropDownList id="Cover_Stock" runat="server"
title="{@TTDescription}">
<asp:ListItem value="">-- Select --</asp:ListItem>
<xsl:for-each select=".//Options">
<asp:ListItem value="{@oID}"><xsl:value-of
select="@oName"/></asp:ListItem>
</xsl:for-each>
</asp

ropDownList>
</xsl:when>
<xsl:when test="@TTName = string('Black and White Stock')">
<asp

ropDownList id="Black_and_White_Stock" runat="server"
title="{@TTDescription}">
<asp:ListItem value="">-- Select --</asp:ListItem>
<xsl:for-each select=".//Options">
<asp:ListItem value="{@oID}" ><xsl:value-of
select="@oName"/></asp:ListItem>
</xsl:for-each>
</asp

ropDownList>
</xsl:when>
<xsl:when test="@TTName = string('Color Stock')">
<asp

ropDownList id="Color_Stock" runat="server"
title="{@TTDescription}">
<asp:ListItem value="">-- Select --</asp:ListItem>
<xsl:for-each select=".//Options">
<asp:ListItem value="{@oID}" ><xsl:value-of
select="@oName"/></asp:ListItem>
</xsl:for-each>
</asp

ropDownList>
</xsl:when>
<xsl:when test="@TTName = string('Binding Method')">
<asp

ropDownList id="Binding_Method" runat="server"
title="{@TTDescription}">
<asp:ListItem value="" >-- Select --</asp:ListItem>
<xsl:for-each select=".//Options">
<asp:ListItem value="{@oID}" ><xsl:value-of
select="@oName"/></asp:ListItem>
</xsl:for-each>
</asp

ropDownList>
</xsl:when>
<xsl:when test="@TTName = string('Folding Method')">
<asp

ropDownList id="Folding_Method" runat="server"
title="{@TTDescription}">
<asp:ListItem value="" >-- Select --</asp:ListItem>
<xsl:for-each select=".//Options">
<asp:ListItem value="{@oID}" ><xsl:value-of
select="@oName"/></asp:ListItem>
</xsl:for-each>
</asp

ropDownList>
</xsl:when>
<xsl:when test="@TTName = string('Combs and Spiral Colors')">
<asp

ropDownList id="Combs_and_Spiral_Colors" runat="server"
title="{@TTDescription}">
<asp:ListItem value="" >-- Select --</asp:ListItem>
<xsl:for-each select=".//Options">
<asp:ListItem value="{@oID}" ><xsl:value-of
select="@oName"/></asp:ListItem>
</xsl:for-each>
</asp

ropDownList>
<br/>
</xsl:when>
<xsl:when test="@TTName = string('Tape Binding')">
<asp

ropDownList id="Tape_Binding" runat="server"
title="{@TTDescription}">
<asp:ListItem value="" >-- Select --</asp:ListItem>
<xsl:for-each select=".//Options">
<asp:ListItem value="{@oID}" ><xsl:value-of
select="@oName"/></asp:ListItem>
</xsl:for-each>
</asp

ropDownList>
</xsl:when>
<xsl:when test="@TTName = string('Binder Colors')">
<asp

ropDownList id="Binder_Colors" runat="server"
title="{@TTDescription}">
<asp:ListItem value="" >-- Select --</asp:ListItem>
<xsl:for-each select=".//Options">
<asp:ListItem value="{@oID}" ><xsl:value-of
select="@oName"/></asp:ListItem>
</xsl:for-each>
</asp

ropDownList>
</xsl:when>
<xsl:when test="@TTName = string('Due Date')">
<asp

laceHolder id="Due_Date" runat="server"
title="{@TTDescription}"></asp

laceHolder>
</xsl:when>
<xsl

therwise>
<asp:TextBox id="{translate(@TTName,' ','_')}"
title="{@TTDescription}" TextMode="SingleLine" runat="server"
width="{(@TTSize * 12) mod 480}">
<xsl:choose>
<xsl:when test="@TTSize < 51">
<xsl:attribute name="TextMode">
SingleLine
</xsl:attribute>
</xsl:when>
<xsl

therwise>
<xsl:attribute name="TextMode">
MultiLine
</xsl:attribute>
<xsl:attribute name="width">
100%
</xsl:attribute>
</xsl

therwise>
</xsl:choose>
</asp:TextBox>
</xsl

therwise>
</xsl:choose>
<xsl:if test="@TTRequiredField = 1"><asp:RequiredFieldValidator
id="Validator_{translate(@TTName,' ','_')}" runat="server"
ErrorMessage="<br/>{@TTDescription}"
ControlToValidate="{translate(@TTName,'
','_')}"></asp:RequiredFieldValidator></xsl:if>
</td>
</tr>
</xsl:for-each>
</table>
</td>
</xsl:if>
</tr>
</xsl:for-each>
</table>
<asp:button id="Submitter" runat="server" Text="Submit" />
</xsl:template>
</xsl:stylesheet>
------------------------------------Code----------------------------------------------------------------------
private void CreateForm()
{
// Load the data source
SqlConnection sCon = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
sCon.Open();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
SqlDataReader dr =
SqlHelper.ExecuteReader(ConfigurationSettings.AppSettings["ConnectionString"],
CommandType.StoredProcedure, "XmlWorkOrderTemplate");
while(dr.Read())
{
sb.Append(dr.GetString(0));
}
string xmlString = sb.ToString();
XPathDocument surveyDoc = new
XPathDocument(SqlHelper.ExecuteXmlReader(sCon,
CommandType.StoredProcedure, "XmlWorkOrderTemplate"));
Context.Items["surveyDoc"] = surveyDoc;
// Load the xslt to do the transformations
XslTransform transform = new XslTransform();
transform.Load(Server.MapPath("~/schemas/XSLTTemplateMaker.xslt"));
// Get the transformed result
StringWriter sw = new StringWriter();
transform.Transform(surveyDoc, null, sw);
string result = sw.ToString();
// remove the namespace attribute
result = result.Replace("xmlns:asp=\"remove\"", "");
result = result.Replace("xmlns:uc1=\"remove\"", "");
// parse the control(s) and add it to the page
Control ctrl = Page.ParseControl(result);
Panel1.Controls.Add(ctrl);
DueDatePicker ddp =
(DueDatePicker)LoadControl("UC/DueDatePicker.ascx");
PlaceHolder DueDatePH = (PlaceHolder)Panel1.FindControl("Due_Date");
DueDatePH.Controls.Add(ddp);
/*PeoplePicker pdo =
(PeoplePicker)LoadControl("UC/PeoplePicker.ascx");
PeoplePicker bdo =
(PeoplePicker)LoadControl("UC/PeoplePicker.ascx");
PeoplePicker pmt =
(PeoplePicker)LoadControl("UC/PeoplePicker.ascx");
PeoplePicker man =
(PeoplePicker)LoadControl("UC/PeoplePicker.ascx");
PlaceHolder managerPH =
(PlaceHolder)Panel1.FindControl("Manager_6");
managerPH.Controls.Add(man);
PlaceHolder primaryDataOwner =
(PlaceHolder)Panel1.FindControl("Primary_Data_Owner_2");
primaryDataOwner.Controls.Add(pdo);
PlaceHolder backupDataOwner =
(PlaceHolder)Panel1.FindControl("Backup_Data_Owner_3");
backupDataOwner.Controls.Add(bdo);
PlaceHolder pmtHolder = (PlaceHolder)Panel1.FindControl("PMt_3");
pmtHolder.Controls.Add(pmt); */
}
private void ProcessResults ()
{
ArrayList ItemsForApproval = new ArrayList();
string ITId;
string ITName;
string TTId;
string TTNo;
string TTName;
string NodeName;
string pmtName= "";
errors.Text = "";
messages.Text = "";
//string target =
((PeoplePicker)Page.FindControl("PeoplePicker1")).Value;
string target = PeoplePicker1.Value;
if (target != null)
{
//string human =
((PeoplePicker)Page.FindControl("PeoplePicker1")).Text;
string human = PeoplePicker1.Text;
string dateNow = System.DateTime.Now.ToString();
SRFChainOfCommand requestChain = new SRFChainOfCommand(target);
SRFPerson personManager = requestChain.Manager;
SRFPerson personDirector = requestChain.Director;
RRFWorkOrderSummary wos = new RRFWorkOrderSummary();
bool abort = false;
if (target != null)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sb.Append(Environment.NewLine);
sb.Append("<WorkOrder WORequestor=\"" + User.Identity.Name + "\"
WOTarget=\"" + target + "\" WOHuman=\"" + human + "\" WODate=\"" +
dateNow + "\" >");
sb.Append(Environment.NewLine);
// Load the data source
XPathDocument surveyDoc =
(XPathDocument)Context.Items["surveyDoc"];
// create an iterator for each question
XPathNodeIterator itra =
surveyDoc.CreateNavigator().Select("//ItemType");
// foreach question
while (itra.MoveNext())
{
ITId = itra.Current.GetAttribute("ITId", "");
ITName = itra.Current.GetAttribute("ITName", "");
ItemsForApproval.Add(Convert.ToInt32(ITId.ToString()));
//validate here and make sure we have all the data we're going
to need for each
//type of request
switch (ITId)
{
case "1": // new employee request
//make all sorts of wacky stuff happen
break;
case "2": // directory Access request
break;
case "11": // local administrator rights
break;
case "15": // email forward
break;
case "17": //shared project area
break;
}
sb.Append("<WorkItem ITId=\"" + ITId + "\" WIStatus=\"0\"
WIGrant=\"1\" WIStatusDate=\"" + System.DateTime.Now.ToString() +
"\">");
sb.Append(Environment.NewLine);
sb.Append("<ItemType ITId=\"" + ITId + "\" ITName=\"" + ITName +
"\">");
sb.Append(Environment.NewLine);
XPathNodeIterator itr =
itra.Current.SelectChildren("TypeTemplate", "");
while (itr.MoveNext())
{
// get the control name
TTId = itr.Current.GetAttribute("TTId", "");
TTNo = itr.Current.GetAttribute("TTNo", "");
TTName = itr.Current.GetAttribute("TTName", "");
NodeName = TTName;
if (NodeName.Equals(""))
{
NodeName = ITName;
sb.Append("<TypeTemplate>");
sb.Append(Environment.NewLine);
}
else
{
sb.Append("<TypeTemplate TTId=\"" + TTId + "\" TTNo=\"" + TTNo
+ "\" ITId=\"" + ITId + "\" TTName=\"" + TTName + "\">");
sb.Append(Environment.NewLine);
}
string controlName = NodeName.Replace(" ", "_"); // + "_" +
itr.CurrentPosition.ToString();
// append question information
// get the control
object ctrl = Panel1.FindControl(controlName);
// append the correct filled out information
if (ctrl is TextBox)
{
string theVal = ((TextBox)ctrl).Text;
if (theVal.Length > 0)
{
sb.Append("<Note TTId=\"" + TTId + "\" NData=\"" +
theVal.Replace("\"","'").Replace("&", "&") + "\" />");
switch (((TextBox)ctrl).ID)
{
case "Charge_Number":
wos.wosCharge = theVal;
Trace.Write("The charge was set to " + wos.wosCharge);
break;
case "Details":
wos.wosDetails = theVal;
break;
case "Black_and_White_Originals":
wos.wosBWOriginals = Convert.ToInt32(theVal);
break;
case "Black_and_White_Copies":
wos.wosBWCopies = Convert.ToInt32(theVal);
break;
case "Color_Originals":
wos.wosColorOriginals = Convert.ToInt32(theVal);
break;
case "Color_Copies":
wos.wosColorCopies = Convert.ToInt32(theVal);
break;
case "Sets_of_Index_Tabs":
wos.wosNumIndexTabs = Convert.ToInt32(theVal);
break;
}
}
}
if (ctrl is RadioButtonList)
{
// the selected item might be null
if (((RadioButtonList)ctrl).SelectedItem != null)
{
string theRadioVal =
((RadioButtonList)ctrl).SelectedItem.Value;
sb.Append("<Note TTId=\"" + TTId + "\" NData=\"" +
((RadioButtonList)ctrl).SelectedItem.Text + "\" />");
switch (((RadioButtonList)ctrl).ID)
{
case "Black_and_White_Sides_per_Sheet":
wos.wosBWSides = Convert.ToInt32(theRadioVal);
break;
case "Color_Sides_per_Sheet":
wos.wosColorSides = Convert.ToInt32(theRadioVal);
break;
case "Cover_Option":
wos.wosCoverOption = Convert.ToInt32(theRadioVal);
break;
case "Index_Tabs":
wos.wosIndexTabs = Convert.ToInt32(theRadioVal);
break;
case "Collating":
wos.wosCollating = Convert.ToInt32(theRadioVal);
break;
}
}
}
if (ctrl is Calendar)
{
sb.Append("<Note TTId=\"" + TTId + "\" NData=\"" +
((Calendar)ctrl).SelectedDate.ToString() + "\" />");
// this means it's the due date, add it to the list.
wos.wosDueDate = ((Calendar)ctrl).SelectedDate;
}
/*if (ctrl is PeoplePicker)
{
sb.Append("<Note TTId=\"" + TTId + "\" NData=\"" +
((PeoplePicker)ctrl).Value.ToString() + "\" />");
}*/
if (ctrl is PlaceHolder)
{
//we're taking it on faith that only DueDatePickers will be in
placeholders,
//but that's ok becuase if that isn't the case, we would have
to specify that
//manually, and we'd know about the change.
DueDatePicker subControl =
(DueDatePicker)(((PlaceHolder)ctrl).Controls[0]);
if(!subControl.SelectedDate.Equals((new
RRFDueDate()).TheDateTime))
{
sb.Append("<Note TTId=\"" + TTId + "\" NData=\"" +
subControl.SelectedDate.ToString() + "\" />");
}
wos.wosDueDate = subControl.SelectedDate;
}
if (ctrl is DropDownList)
{
string theVal =
((DropDownList)ctrl).SelectedItem.Value.ToString();
string theText =
((DropDownList)ctrl).SelectedItem.Text.ToString();
if (theVal.Length > 0)
{
sb.Append("<Note TTId=\"" + TTId + "\" NData=\"" + theText +
"\" />");
switch (((DropDownList)ctrl).ID)
{
case "Locator_Code": // string
wos.wosLocator = theVal;
break;
case "Cover_Stock": // integer
wos.wosCoverStockID = Convert.ToInt32(theVal);
break;
case "Black_and_White_Stock": //integer
wos.wosBWStockID = Convert.ToInt32(theVal);
break;
case "Color_Stock": // integer
wos.wosColorStockID = Convert.ToInt32(theVal);
break;
case "Binding_Method": //integer
wos.wosBindingMethod = Convert.ToInt32(theVal);
break;
case "Folding_Method": //integer
wos.wosFoldingMethod = Convert.ToInt32(theVal);
break;
case "Combs_and_Spiral_Colors": //integer
wos.wosCombsSpiralColors = Convert.ToInt32(theVal);
break;
case "Tape_Binding": // integer
wos.wosTapeBinding = Convert.ToInt32(theVal);
break;
case "Binder_Colors": // integer
wos.wosBinderColors = Convert.ToInt32(theVal);
break;
}
}
}
sb.Append(Environment.NewLine);
sb.Append("</TypeTemplate>");
sb.Append(Environment.NewLine);
}
sb.Append("</ItemType>");
sb.Append(Environment.NewLine);
sb.Append("</WorkItem>");
sb.Append(Environment.NewLine);
}
sb.Append("</WorkOrder>");
sb.Append(Environment.NewLine);
TextBox newBox = new TextBox();
newBox.Text = sb.ToString();
if(!abort)
{
//try
//{
SqlParameter [] param = new SqlParameter[2];
param[0] = new SqlParameter("@Order_Xml", SqlDbType.Text);
param[0].Direction = ParameterDirection.Input;
param[0].Value = newBox.Text;
param[1] = new SqlParameter("@OrderID", SqlDbType.Int);
param[1].Direction = ParameterDirection.Output;
SqlHelper.ExecuteNonQuery(ConfigurationSettings.AppSettings["ConnectionString"],
CommandType.StoredProcedure, "XmlNewWorkOrder", param);
int WorkOrderID = Convert.ToInt32(param[1].Value.ToString());
wos.wosWOId = WorkOrderID;
wos.Insert();
//string emailAddresses = requestChain.User.Email + ";";