Guest User

document types insert error

a guest
Mar 19th, 2011
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.93 KB | None | 0 0
  1. <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="CustomerDocuments.aspx.cs" Inherits="CustomerDocuments" StylesheetTheme="Theme" %>
  2.  
  3. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  4.  
  5. <table>
  6. <tr>
  7. <td style="width:20%"></td>
  8. <td style="width:80%"><asp:Label ID="lblErr" runat="server" ForeColor="Red"></asp:Label></td>
  9. </tr>
  10. <tr>
  11. <td colspan="2" style="background-color:rgb(255, 233, 126)" >
  12. <asp:Label ID="Label2" runat="server" Text="New Document Types"
  13. style="font-weight: 700"></asp:Label>
  14. </td>
  15. </tr>
  16. <tr>
  17. <td><asp:Label ID="Label3" runat="server" Text="Document Type"></asp:Label></td>
  18. <td>
  19. <asp:TextBox ID="txtDocType" runat="server"></asp:TextBox>
  20. </td>
  21. </tr>
  22. <tr>
  23. <td>&nbsp;</td>
  24. <td>&nbsp;</td>
  25. </tr>
  26. <tr>
  27. <td>&nbsp;</td>
  28. <td><asp:Button ID="btnSave0" runat="server" onclick="btnSave0_Click"
  29. Text="Save Document Type" />
  30. </td>
  31. </tr>
  32. <tr>
  33. <td>&nbsp;</td>
  34. <td>&nbsp;</td>
  35. </tr>
  36. <tr>
  37. <td colspan="2" style="background-color:rgb(255, 233, 126)" >
  38. <asp:Label ID="Label1" runat="server" Text="Customer Associated Document Types"
  39. style="font-weight: 700"></asp:Label>
  40. </td>
  41. </tr>
  42.  
  43. <tr>
  44. <td><asp:Label ID="Label4" runat="server" Text="Customers"></asp:Label></td>
  45. <td><asp:DropDownList ID="ddlCustomers" runat="server" BackColor='AliceBlue' Width=218px
  46. DataSourceID="Customers" DataTextField="CustomerName"
  47. DataValueField="CustomerId" AutoPostBack="True">
  48. </asp:DropDownList></td>
  49. </tr>
  50. <tr>
  51. <td><asp:Label ID="Label5" runat="server" Text="Customer Type"></asp:Label></td>
  52. <td>
  53. <asp:DropDownList ID="ddlDocumentTypes" runat="server"
  54. DataSourceID="DocumentTypes" DataTextField="DocumentType"
  55. DataValueField="DocumentTypeId" Width="209px">
  56. </asp:DropDownList>
  57. </td>
  58. </tr>
  59. <tr>
  60. <td>&nbsp;</td>
  61. <td>&nbsp;</td>
  62. </tr>
  63. <tr>
  64. <td>&nbsp;</td>
  65. <td><asp:Button ID="btnSave" runat="server" onclick="btnSave_Click" Text="Save" />
  66. </td>
  67. </tr>
  68. <tr>
  69. <td>&nbsp;</td>
  70. <td>&nbsp;</td>
  71. </tr>
  72. <tr>
  73. <td>&nbsp;</td>
  74. <td>&nbsp;</td>
  75. </tr>
  76. <tr>
  77. <td colspan="2">
  78. <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
  79. AllowSorting="True" AutoGenerateColumns="False" DataSourceID="CustomerDocumentTypes"
  80. EnableModelValidation="True" SkinID="GridListView"
  81. EmptyDataText="Customer has no document types associated">
  82. <Columns>
  83. <asp:BoundField DataField="DocumentType"
  84. HeaderText="Customer Document Types"
  85. SortExpression="DocumentType" />
  86. </Columns>
  87. </asp:GridView>
  88. </td>
  89. </tr>
  90. <tr>
  91. <td>&nbsp;</td>
  92. <td>
  93.  
  94.  
  95. <asp:SqlDataSource ID="Customers" runat="server"
  96. ConnectionString="<%$ ConnectionStrings:SecurityDB_20101025ConnectionString %>"
  97.  
  98. SelectCommand="SELECT * FROM [Customers] WHERE ([CustomerId] = ISNULL(@CustomerId, '') OR @IsSuperAdmin = 1 )
  99. order by customername
  100. "
  101. >
  102. <SelectParameters>
  103. <asp:SessionParameter Name="CustomerId" SessionField="CustomerID"
  104. />
  105. <asp:SessionParameter Name="IsSuperAdmin" SessionField="IsSuperAdmin" Type="Boolean"
  106. />
  107.  
  108. </SelectParameters>
  109. </asp:SqlDataSource>
  110. <asp:SqlDataSource ID="DocumentTypes" runat="server"
  111. ConnectionString="<%$ ConnectionStrings:SecurityDB_20101025ConnectionString %>"
  112.  
  113. SelectCommand="SELECT * FROM [DocumentTypes]
  114. WHERE DocumentTypeId NOT IN ( Select DocumentTypeId from CustomerDocumentTypes WHERE CustomerId = @CustomerId)" InsertCommand="INSERT INTO [DocumentTypes]
  115. (DocumentType)
  116. VALUES
  117. (@DocumentType)">
  118. <InsertParameters>
  119. <asp:ControlParameter ControlID="txtDocType" Name="DocumentType" PropertyName="Text" />
  120. </InsertParameters>
  121. <SelectParameters>
  122. <asp:ControlParameter ControlID="ddlCustomers" Name="CustomerId"
  123. PropertyName="SelectedValue" />
  124. </SelectParameters>
  125. </asp:SqlDataSource>
  126. <asp:SqlDataSource ID="CustomerDocumentTypes" runat="server"
  127. ConnectionString="<%$ ConnectionStrings:SecurityDB_20101025ConnectionString %>"
  128. SelectCommand="SELECT D.DocumentType FROM [CustomerDocumentTypes] C
  129. INNER JOIN DocumentTypes D
  130. ON C.DocumentTypeID = D.DocumentTypeID
  131. WHERE ([CustomerId] = @CustomerId)" InsertCommand="INSERT INTO CustomerDocumentTypes
  132. (CustomerID, DocumentTypeId)
  133. VALUES
  134. (@CustomerId, @DocumentTypeId)">
  135.  
  136. <SelectParameters>
  137. <asp:ControlParameter ControlID="ddlCustomers" Name="CustomerId"
  138. PropertyName="SelectedValue" Type="Int32" />
  139. </SelectParameters>
  140. <InsertParameters>
  141. <asp:ControlParameter ControlID="ddlCustomers" Name="CustomerId"
  142. PropertyName="SelectedValue" Type="Int32" />
  143. <asp:ControlParameter ControlID="ddlDocumentTypes" Name="DocumentTypeId"
  144. PropertyName="SelectedValue" Type="Int32" />
  145. </InsertParameters>
  146. </asp:SqlDataSource>
  147. <br />
  148. </td>
  149. </tr>
  150. </table>
  151. </asp:Content>
Advertisement
Add Comment
Please, Sign In to add comment