Marius Vasile

Marius Vasile

  • 552
  • 1.9k
  • 145.7k

Multiple buttons on webpage acting as submit

Apr 23 2020 6:52 AM
I have four asp buttons, all handling code behing procedures, for example Button1 load data on click but on second click acts as submit button. Button 2 supose tp load data on specific textboxes grouped in same update panel, even outside panel it behaves the same. Webpage and code behind, a little long but for you to see the whole picture.
What I need is that each button to execute only the procedure is specify to 
 
 
  1. <body>  
  2. <form id="form1" runat="server">  
  3.     <div id="NavigationBar">  
  4.         <asp:SiteMapDataSource ID="navbar" runat="server" ShowStartingNode="false" />  
  5.         <asp:Menu ID="NavMenu" runat="server" Orientation="Horizontal" RenderingMode="List" DataSourceID="navbar" />  
  6.     </div>  
  7. <br /><br />  
  8. <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>  
  9. <div class="container">  
  10. <asp:Panel runat="server" DefaultButton="Button1">  
  11.         <p class="text-lg-left font-weight-bold" style="font-size:14px">WAP Review</p>  
  12.         <p class="text-success" style="font-size:12px">Enter WAPNo to be reviewed</p>  
  13.         <div class="row">  
  14.             <div class="col-2">  
  15.                 <asp:TextBox ID="tmpWAPNo" class="form-control" runat="server" />  
  16.                 <asp:RequiredFieldValidator id="val1" runat="server" style="display:none" ControlToValidate="tmpWAPNo" />  
  17.             </div>  
  18.             <div class="col-2">  
  19.                 <asp:Button class="btn btn-link" ID="Button1" Text="Load Data" runat="server" OnClick="GetData" UseSubmitBehavior="false"/>  
  20.             </div>  
  21.         </div>  
  22. <hr /><br />  
  23. </asp:Panel>  
  24. <asp:Panel runat="server" DefaultButton="Button3">  
  25.         <div id="ReviewNew" runat="server" visible="false">  
  26.             <div id="General2" class="row no-gutters">  
  27.                 <div class="col-2">  
  28.                     <asp:Label ID="Label39" class="form-control badge-primary" Text="IssueDT" runat="server" />  
  29.                     <asp:TextBox ID="txtIssueDT2" class="form-control" runat="server" />  
  30.                     <asp:RequiredFieldValidator id="val2" runat="server" style="display:none" ControlToValidate="txtIssueDT2" />  
  31.                 </div>  
  32.                 <div class="col-2">  
  33.                     <asp:Label ID="Label1" class="form-control badge-primary" Text="WellNo" runat="server" />  
  34.                     <asp:TextBox ID="txtWellNo2" class="form-control" runat="server" />  
  35.                     <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" style="display:none" ControlToValidate="txtWellNo2" />  
  36.                 </div>  
  37.                 <div class="col-4">  
  38.                     <asp:Label ID="Label40" class="form-control badge-primary" runat="server" Text="Job Type" />  
  39.                     <asp:DropDownList class="form-control" ID="ddlJobType" runat="server" DataTextField="JobType" DataValueField="JobType" AutoPostBack="True" OnSelectedIndexChanged="GetJobDetails" />  
  40.                     <asp:RequiredFieldValidator id="val3" runat="server" style="display:none" ControlToValidate="ddlJobType" InitialValue="0"/>  
  41.                 </div>  
  42.                 <div class="col-4">  
  43.                     <asp:Label class="form-control badge-primary" ID="Label49" runat="server" Text="Job Task" />  
  44.                     <asp:DropDownList class="form-control" ID="ddlJobTask2" runat="server" DataTextField="JobTask" DataValueField="JobTask" AutoPostBack="True" />  
  45.                     <asp:RequiredFieldValidator id="val12" runat="server" style="display:none" ControlToValidate="ddlJobTask2" InitialValue="0" />  
  46.                 </div>  
  47.             </div>  
  48.             <div class="row no-gutters">  
  49.                 <div class="col-4">  
  50.                     <asp:Label ID="Label42" class="form-control badge-primary" runat="server" Text="Division:" />  
  51.                     <asp:DropDownList class="form-control" ID="ddlDivision" runat="server" DataTextField="Division" DataValueField="Division" AutoPostBack="True" OnSelectedIndexChanged="GetDivisionDetails" />  
  52.                     <asp:RequiredFieldValidator id="val5" runat="server" style="display:none" ControlToValidate="ddlDivision" InitialValue="0"/>  
  53.                 </div>  
  54.                 <div class="col-4">  
  55.                     <asp:Label ID="Label43" class="form-control badge-primary" runat="server" Text="Unit:" />  
  56.                     <asp:DropDownList class="form-control" ID="ddlUnit" runat="server" DataTextField="Unit" DataValueField="Unit" AutoPostBack="True" />  
  57.                     <asp:RequiredFieldValidator id="val6" runat="server" style="display:none" ControlToValidate="ddlUnit" InitialValue="0"/>  
  58.                 </div>  
  59.                 <div class="col-4">  
  60.                     <asp:Label ID="Label44" class="form-control badge-primary" runat="server" Text="Service Company" />  
  61.                     <asp:DropDownList class="form-control" ID="ddlContractor" runat="server" DataTextField="Contractor" DataValueField="Contractor" />  
  62.                     <asp:RequiredFieldValidator ID="val7" runat="server" ControlToValidate="ddlContractor" InitialValue="0" />  
  63.                 </div>  
  64.             </div>  
  65. <hr /><br />  
  66.             <div id="Specific2" class="row no-gutters">  
  67.                 <div class="col-2">  
  68.                     <asp:Label class="form-control badge-primary" ID="Label45" runat="server" Text="Date:" />  
  69.                     <asp:TextBox class="form-control" ID="txtDate2" runat="server" ReadOnly="true" />  
  70.                     <asp:RequiredFieldValidator id="val8" runat="server" style="display:none" ControlToValidate="txtDate2" />  
  71.                 </div>  
  72.                 <div class="col-4">  
  73.                     <asp:Label class="form-control badge-primary" ID="Label46" runat="server" Text="Reviewer:" />  
  74.                     <asp:TextBox class="form-control" ID="txtReviewer2" runat="server" ReadOnly="true" />  
  75.                     <asp:RequiredFieldValidator id="val9" runat="server" style="display:none" ControlToValidate="txtReviewer2" />  
  76.                 </div>  
  77.                 <div class="col-3">  
  78.                     <asp:Label class="form-control badge-primary" ID="Label47" runat="server" Text="Location/ Area:" />  
  79.                     <asp:DropDownList class="form-control" ID="ddlLocation2" runat="server" DataTextField="WorkArea" DataValueField="WorkArea" />  
  80.                     <asp:RequiredFieldValidator id="val10" runat="server" style="display:none" ControlToValidate="ddlLocation2" InitialValue="0" />  
  81.                 </div>  
  82.                 <div class="col-3">  
  83.                     <asp:Label class="form-control badge-primary" ID="Label48" runat="server" Text="WAP Type" />  
  84.                     <asp:DropDownList class="form-control" ID="ddlWAPType" runat="server" DataTextField="WAPType" DataValueField="WAPType" />  
  85.                     <asp:RequiredFieldValidator id="val11" runat="server" style="display:none" ControlToValidate="ddlWAPType" InitialValue="0" />  
  86.                 </div>  
  87.             </div>  
  88. <hr /><br />  
  89.   
  90.             <div id="Issuer2" class="row no-gutters">  
  91.                 <div class="col">  
  92.                     <div class="row no-gutters">  
  93.                         <div class="col-12">  
  94.                             <asp:Label class="form-control badge-success" ID="Label50" runat="server" Text="Task Issuer" />  
  95.                         </div>  
  96.                     </div>  
  97.                     <div class="row no-gutters">  
  98.                         <div class="col-4">  
  99.                             <asp:Label class="form-control badge-primary" ID="Label52" runat="server" Text="Issuer BN" />  
  100.                             <asp:TextBox class="form-control" ID="IssuerBN" runat="server" AutoPostBack="True" OnTextChanged="GetIssuerName" />  
  101.                             <asp:RequiredFieldValidator id="val13" runat="server" style="display:none" ControlToValidate="IssuerBN" />  
  102.                         </div>  
  103.                         <div class="col-8">  
  104.                             <asp:Label class="form-control badge-primary" ID="Label53" runat="server" Text="Issuer Name" />  
  105.                             <asp:TextBox class="form-control" ID="IssuerName" runat="server" ReadOnly="true" />  
  106.                             <asp:RequiredFieldValidator id="val14" runat="server" style="display:none" ControlToValidate="IssuerName" />  
  107.                         </div>  
  108.                     </div>  
  109.                 </div>  
  110.                 <div class="col">  
  111.                     <div class="row no-gutters">  
  112.                         <div class="col-12">  
  113.                             <asp:Label class="form-control badge-success" ID="Label51" runat="server" Text="Task Receiver" />  
  114.                         </div>  
  115.                     </div>  
  116.                     <div class="row no-gutters">  
  117.                         <div class="col-4">  
  118.                             <asp:Label class="form-control badge-primary" ID="Label54" runat="server" Text="Receiver CN" />  
  119.                             <asp:TextBox class="form-control" ID="ReceiverCN" runat="server" AutoPostBack="True" OnTextChanged="GetReceiverName" />  
  120.                             <asp:RequiredFieldValidator id="val15" runat="server" style="display:none" ControlToValidate="ReceiverCN" />  
  121.                         </div>  
  122.                         <div class="col-8">  
  123.                             <asp:Label class="form-control badge-primary" ID="Label55" runat="server" Text="Receiver Name" />  
  124.                             <asp:TextBox class="form-control" ID="ReceiverName" runat="server" ReadOnly="true" />  
  125.                         <asp:RequiredFieldValidator id="val16" runat="server" style="display:none" ControlToValidate="ReceiverName" />  
  126.                         </div>  
  127.                     </div>  
  128.                 </div>  
  129.             </div>  
  130.    
  131. <hr /><br />  
  132.             <div id="Checklist2" class="row no-gutters">  
  133.                 <div class="col-3">  
  134.                     <asp:Label class="form-control badge-primary" ID="Label62" runat="server" Text="Checklist Category" />  
  135.                     <asp:DropDownList class="form-control" ID="ddlChkCategory2" runat="server" DataTextField="ChkCategory" DataValueField="ChkCategory" AutoPostBack="True" OnSelectedIndexChanged="GetChecklistDetails2" />  
  136.                     <asp:RequiredFieldValidator id="val17" runat="server" style="display:none" ControlToValidate="ddlChkCategory2" InitialValue="0" />  
  137.                 </div>  
  138.                 <div class="col-3">  
  139.                     <asp:Label class="form-control badge-primary" ID="Label63" runat="server" Text="Checklist Details" />  
  140.                     <asp:DropDownList class="form-control" ID="ddlChkDetails2" runat="server" DataTextField="ChkDetails" DataValueField="ChkDetails" />  
  141.                     <asp:RequiredFieldValidator id="val18" runat="server" style="display:none" ControlToValidate="ddlChkDetails2" InitialValue="0" />  
  142.                 </div>  
  143.                 <div class="col-6">  
  144.                     <asp:Label class="form-control badge-primary" ID="Label64" runat="server" Text="Remarks" />  
  145.                     <asp:TextBox  class="form-control" TextMode="MultiLine" ID="txtRemarks2" runat="server" />  
  146.                     <asp:RequiredFieldValidator id="val19" runat="server" style="display:none" ControlToValidate="txtRemarks2" />  
  147.                 </div>  
  148.             </div>  
  149.                     <asp:Button class="btn btn-link" ID="Button3" runat="server" OnClick="ReviewNewWAP" Text="Save Data" />  
  150. <hr /><br />  
  151.     </div>  
  152. </asp:Panel>  
  153. <asp:Panel runat="server" DefaultButton="Button4">  
  154.     <div id="ReviewExisting" runat="server" visible="false">  
  155.         <div id="General1" class="row no-gutters">  
  156.             <div class="col-2">  
  157.                 <asp:Label ID="Label33" class="form-control badge-primary" Text="IssueDT" runat="server" />  
  158.                 <asp:TextBox ID="txtIssueDT1" class="form-control" runat="server" ReadOnly="true" />  
  159.             </div>  
  160.             <div class="col-2">  
  161.                 <asp:Label ID="Label35" class="form-control badge-primary" Text="WellNo" runat="server" />  
  162.                 <asp:TextBox ID="txtWellNo1" class="form-control" runat="server" ReadOnly="true" />  
  163.             </div>  
  164.             <div class="col-3">  
  165.                 <asp:Label ID="Label34" class="form-control badge-primary" Text="Job Type" runat="server" />  
  166.                 <asp:TextBox ID="txtJobType" class="form-control" runat="server" ReadOnly="true" />  
  167.             </div>  
  168.             <div class="col-4">  
  169.                 <asp:Label class="form-control badge-primary" ID="Label81" runat="server" Text="Job Task" />  
  170.                 <asp:DropDownList class="form-control" ID="ddlJobTask1" runat="server" DataTextField="JobTask" DataValueField="JobTask" />  
  171.                 <asp:RequiredFieldValidator id="val21" runat="server" style="display:none" ControlToValidate="ddlJobTask1" InitialValue="0"/>  
  172.             </div>  
  173.               
  174.         </div>  
  175.   
  176. <hr /><br />  
  177.         <div class="row no-gutters">  
  178.             <div class="col-4">  
  179.                 <asp:Label ID="Label36" class="form-control badge-primary" Text="Division" runat="server" />  
  180.                 <asp:TextBox ID="txtDivision" class="form-control" runat="server" ReadOnly="true" />  
  181.             </div>  
  182.             <div class="col-4">  
  183.                 <asp:Label ID="Label37" class="form-control badge-primary" Text="Unit" runat="server" />  
  184.                 <asp:TextBox ID="txtUnit" class="form-control" runat="server" ReadOnly="true" />  
  185.             </div>  
  186.             <div class="col-4">  
  187.                 <asp:Label ID="Label38" class="form-control badge-primary" Text="Service Company" runat="server" />  
  188.                 <asp:TextBox ID="txtContractor" class="form-control" runat="server" ReadOnly="true" />  
  189.             </div>  
  190.         </div>  
  191.   
  192. <hr /><br />  
  193.         <div id="Specific1" class="row no-gutters">  
  194.             <div class="col-2">  
  195.                 <asp:Label class="form-control badge-primary" ID="Label77" runat="server" Text="Date:" />  
  196.                 <asp:TextBox class="form-control" ID="txtDate1" runat="server" ReadOnly="true" />  
  197.             </div>  
  198.             <div class="col-2">  
  199.                 <asp:Label class="form-control badge-primary" ID="Label78" runat="server" Text="Reviewer:" />  
  200.                 <asp:TextBox class="form-control" ID="txtReviewer1" runat="server" ReadOnly="true" />  
  201.             </div>  
  202.             <div class="col-4">  
  203.                 <asp:Label class="form-control badge-primary" ID="Label79" runat="server" Text="Location/ Area:" />  
  204.                 <asp:DropDownList class="form-control" ID="ddlLocation1" runat="server" DataTextField="WorkArea" DataValueField="WorkArea" />  
  205.                 <asp:RequiredFieldValidator id="val20" runat="server" style="display:none" ControlToValidate="ddlLocation1" InitialValue="0"/>  
  206.             </div>  
  207.             <div class="col-4">  
  208.                 <asp:Label class="form-control badge-primary" ID="Label80" runat="server" Text="WAP Type" />  
  209.                 <asp:TextBox class="form-control" ID="txtWAPType" runat="server" ReadOnly="true" />  
  210.             </div>  
  211.         </div>  
  212.              
  213.   
  214. <hr /><br />  
  215. <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
  216.     <ContentTemplate>  
  217.         <div class="col-1">  
  218.                 <asp:Label class="form-control invisible" ID="Label2" runat="server" Text="Job Task" />  
  219.                 <asp:Button class="btn btn-link" ID="Button2" Text="Load Task Data" runat="server" OnClick="LoadTaskData" UseSubmitBehavior="false"/>  
  220.             </div>  
  221.         <div id="Issuer1" class="row no-gutters">  
  222.             <div class="col">  
  223.                 <div class="row no-gutters">  
  224.                     <div class="col-12">  
  225.                         <asp:Label class="form-control badge-success" ID="Label56" runat="server" Text="Task Issuer" />  
  226.                     </div>  
  227.                 </div>  
  228.                 <div class="row no-gutters">  
  229.                     <div class="col-4">  
  230.                         <asp:Label class="form-control badge-primary" ID="Label58" runat="server" Text="Issuer BN" />  
  231.                         <asp:TextBox class="form-control" ID="txtIssuerBN1" runat="server"  ReadOnly="true"/>  
  232.                         <asp:RequiredFieldValidator id="val30" runat="server" style="display:none" ControlToValidate="txtIssuerBN1" />  
  233.                     </div>  
  234.                     <div class="col-8">  
  235.                         <asp:Label class="form-control badge-primary" ID="Label59" runat="server" Text="Issuer Name" />  
  236.                         <asp:TextBox class="form-control" ID="txtIssuerName1" runat="server" ReadOnly="true" />  
  237.                         <asp:RequiredFieldValidator id="val31" runat="server" style="display:none" ControlToValidate="txtIssuerName1" />  
  238.                     </div>  
  239.                 </div>  
  240.             </div>  
  241.             <div class="col">  
  242.                 <div class="row no-gutters">  
  243.                     <div class="col-12">  
  244.                         <asp:Label class="form-control badge-success" ID="Label57" runat="server" Text="Task Receiver" />  
  245.                     </div>  
  246.                 </div>  
  247.                 <div class="row no-gutters">  
  248.                     <div class="col-4">  
  249.                         <asp:Label class="form-control badge-primary" ID="Label60" runat="server" Text="Receiver CN" />  
  250.                         <asp:TextBox class="form-control" ID="txtReceiverCN1" runat="server" ReadOnly="true"/>  
  251.                         <asp:RequiredFieldValidator id="val32" runat="server" style="display:none" ControlToValidate="txtReceiverCN1" />  
  252.                     </div>  
  253.                     <div class="col-8">  
  254.                         <asp:Label class="form-control badge-primary" ID="Label61" runat="server" Text="Receiver Name" />  
  255.                         <asp:TextBox class="form-control" ID="txtReceiverName1" runat="server" ReadOnly="true" /><br />  
  256.                         <asp:RequiredFieldValidator id="val33" runat="server" style="display:none" ControlToValidate="txtReceiverName1" />  
  257.                     </div>  
  258.                 </div>  
  259.             </div>  
  260.         </div>  
  261. </ContentTemplate>  
  262. </asp:UpdatePanel>  
  263.         <div id="Checklist1" class="row no-gutters" runat="server">  
  264.             <div class="col-4">  
  265.                 <asp:Label class="form-control badge-primary" ID="Label94" runat="server" Text="Checklist Category" />  
  266.                 <asp:DropDownList class="form-control" ID="ddlChkCategory1" runat="server" DataTextField="ChkCategory" DataValueField="ChkCategory" AutoPostBack="True" OnSelectedIndexChanged="GetChecklistDetails1" />  
  267.                 <asp:RequiredFieldValidator id="val22" runat="server" style="display:none" ControlToValidate="ddlChkCategory1" InitialValue="0"/>  
  268.             </div>  
  269.             <div class="col-4">  
  270.                 <asp:Label class="form-control badge-primary" ID="Label95" runat="server" Text="Checklist Details" />  
  271.                 <asp:DropDownList class="form-control" ID="ddlChkDetails1" runat="server" DataTextField="ChkDetails" DataValueField="ChkDetails" />  
  272.                 <asp:RequiredFieldValidator id="val23" runat="server" style="display:none" ControlToValidate="ddlChkDetails1" InitialValue="0"/>  
  273.             </div>  
  274.             <div class="col-4">  
  275.                 <asp:Label class="form-control badge-primary" ID="Label96" runat="server" Text="Remarks" />  
  276.                 <asp:TextBox class="form-control" TextMode="MultiLine" ID="txtRemarks1" runat="server" />  
  277.                 <asp:RequiredFieldValidator id="val24" runat="server" style="display:none" ControlToValidate="txtRemarks1" /><br />  
  278.             </div>  
  279.         </div>      
  280.                 <asp:Button class="btn btn-link" ID="Button4" runat="server" OnClick="ReviewExistingWAP" Text="Save Data" />  
  281. <hr /><br />  
  282.      </div>  
  283. </asp:Panel>  
 
 
Code behind
 
  1. using System;  
  2. using System.Data;  
  3. using System.Data.SqlClient;  
  4. using System.Web.UI.WebControls;  
  5. using System.Configuration;  
  6. using System.Web.Services;  
  7. using System.Collections.Generic;  
  8. using System.Web.UI;  
  9. using System.Drawing;  
  10. namespace WAPReview  
  11. {  
  12. public partial class ReviewWAP : System.Web.UI.Page  
  13. {  
  14. string connString = Properties.Settings.Default.ConnectionString.ToString();  
  15. protected void Page_Load(object sender, EventArgs e)  
  16. {  
  17. if (Users.UserRole != "Admin" & Users.UserRole != "Reviewer")  
  18. {  
  19. Response.Redirect("/HomePage.aspx"false);  
  20. }  
  21. if (!IsPostBack)  
  22. {  
  23. GetWAPData();  
  24. GetDivisionName();  
  25. GetLocation1();  
  26. GetLocation2();  
  27. GetWAPType();  
  28. GetServiceCompany();  
  29. GetJobType();  
  30. GetChkCategory1();  
  31. GetChkCategory2();  
  32. }  
  33. Button2.Enabled = false;  
  34. Button3.Enabled = false;  
  35. Button4.Enabled = false;  
  36. Checklist1.Visible = false;  
  37. string UserName = Environment.UserName;  
  38. FillUserDetails FS = new FillUserDetails();  
  39. FS.fillUser(UserName);  
  40. txtReviewer1.Text = Users.FullName;  
  41. txtReviewer2.Text = Users.FullName;  
  42. txtDate1.Text = DateTime.Now.ToString();  
  43. txtDate2.Text = DateTime.Now.ToString();  
  44. }  
  45. protected void ReviewNewWAP(object sender, EventArgs e)  
  46. {  
  47. AddWAPReviewDataNew();  
  48. }  
  49. protected void ReviewExistingWAP(object sender, EventArgs e)  
  50. {  
  51. AddWAPReviewDataExisting();  
  52. }  
  53. protected void LoadTaskData(object sender, EventArgs e)  
  54. {  
  55. if (ddlJobTask1.DataValueField == "0")  
  56. {  
  57. ddlJobTask1.Attributes.Add("class""border-warning");  
  58. return;  
  59. }  
  60. else  
  61. {  
  62. GetTaskData();  
  63. Button3.Enabled = true;  
  64. Button4.Enabled = true;  
  65. Checklist1.Visible = true;  
  66. }  
  67. }  
  68. protected void AddWAPReviewDataNew()  
  69. {  
  70. using (SqlConnection conn = new SqlConnection(connString))  
  71. {  
  72. using (SqlCommand cmd = new SqlCommand("WAPReviewInsert"))  
  73. {  
  74. cmd.CommandType = CommandType.StoredProcedure;  
  75. {  
  76. cmd.Parameters.AddWithValue("@WAPNo", tmpWAPNo.Text);  
  77. cmd.Parameters.AddWithValue("@ReviewDate", txtDate2.Text);  
  78. cmd.Parameters.AddWithValue("@WorkArea", ddlLocation2.SelectedItem.Value);  
  79. cmd.Parameters.AddWithValue("@Reviewer", txtReviewer2.Text);  
  80. cmd.Parameters.AddWithValue("@Division", ddlDivision.SelectedItem.Value);  
  81. cmd.Parameters.AddWithValue("@Unit", ddlUnit.SelectedItem.Value);  
  82. cmd.Parameters.AddWithValue("@Contractor", ddlContractor.SelectedItem.Value);  
  83. cmd.Parameters.AddWithValue("@WAPType", ddlWAPType.SelectedItem.Value);  
  84. cmd.Parameters.AddWithValue("@JobType", ddlJobType.SelectedItem.Value);  
  85. cmd.Parameters.AddWithValue("@JobTask", ddlJobTask2.SelectedItem.Value);  
  86. cmd.Parameters.AddWithValue("@IssuerBN", IssuerBN.Text);  
  87. cmd.Parameters.AddWithValue("@IssuerName", IssuerName.Text);  
  88. cmd.Parameters.AddWithValue("@ReceiverCN", ReceiverCN.Text);  
  89. cmd.Parameters.AddWithValue("@ReceiverName", ReceiverName.Text);  
  90. cmd.Parameters.AddWithValue("@ChkCategory", ddlChkCategory2.SelectedItem.Value);  
  91. cmd.Parameters.AddWithValue("@ChkDetails", ddlChkDetails2.SelectedItem.Value);  
  92. cmd.Parameters.AddWithValue("@Remarks", txtRemarks2.Text);  
  93. cmd.Connection = conn;  
  94. conn.Open();  
  95. int result = cmd.ExecuteNonQuery();  
  96. if (result > 0)  
  97. {  
  98. ScriptManager.RegisterClientScriptBlock(thisthis.GetType(), "alertMessage""alert('Record Inserted Successfully')"true);  
  99. }  
  100. }  
  101. }  
  102. }  
  103. }  
  104. protected void AddWAPReviewDataExisting()  
  105. {  
  106. using (SqlConnection conn = new SqlConnection(connString))  
  107. {  
  108. using (SqlCommand cmd = new SqlCommand("WAPReviewInsert"))  
  109. {  
  110. cmd.CommandType = CommandType.StoredProcedure;  
  111. {  
  112. cmd.Parameters.AddWithValue("@WAPNo", tmpWAPNo.Text);  
  113. cmd.Parameters.AddWithValue("@ReviewDate", txtDate1.Text);  
  114. cmd.Parameters.AddWithValue("@WorkArea", ddlLocation1.SelectedItem.Value);  
  115. cmd.Parameters.AddWithValue("@Reviewer", txtReviewer1.Text);  
  116. cmd.Parameters.AddWithValue("@Division", txtDivision.Text);  
  117. cmd.Parameters.AddWithValue("@Unit", txtUnit.Text);  
  118. cmd.Parameters.AddWithValue("@Contractor", txtContractor.Text);  
  119. cmd.Parameters.AddWithValue("@WAPType", txtWAPType.Text);  
  120. cmd.Parameters.AddWithValue("@JobType", txtJobType.Text);  
  121. cmd.Parameters.AddWithValue("@JobTask", ddlJobTask1.SelectedItem.Value);  
  122. cmd.Parameters.AddWithValue("@IssuerBN", txtIssuerBN1.Text);  
  123. cmd.Parameters.AddWithValue("@IssuerName", txtIssuerName1.Text);  
  124. cmd.Parameters.AddWithValue("@ReceiverCN", txtReceiverCN1.Text);  
  125. cmd.Parameters.AddWithValue("@ReceiverName", txtReceiverName1.Text);  
  126. cmd.Parameters.AddWithValue("@ChkCategory", ddlChkCategory1.SelectedItem.Value);  
  127. cmd.Parameters.AddWithValue("@ChkDetails", ddlChkDetails1.SelectedItem.Value);  
  128. cmd.Parameters.AddWithValue("@Remarks", txtRemarks1.Text);  
  129. cmd.Connection = conn;  
  130. conn.Open();  
  131. int result = cmd.ExecuteNonQuery();  
  132. if (result > 0)  
  133. {  
  134. ScriptManager.RegisterClientScriptBlock(thisthis.GetType(), "alertMessage""alert('Record Inserted Successfully')"true);  
  135. }  
  136. }  
  137. }  
  138. }  
  139. }  
  140. protected void GetIssuerName(object sender, EventArgs e)  
  141. {  
  142. using (SqlConnection conn = new SqlConnection(connString))  
  143. {  
  144. try  
  145. {  
  146. SqlCommand cmd = new SqlCommand("selectIssuerName", conn);  
  147. cmd.CommandType = CommandType.StoredProcedure;  
  148. cmd.Parameters.AddWithValue("@IssuerBN", IssuerBN.Text);  
  149. cmd.Connection = conn;  
  150. conn.Open();  
  151. using (SqlDataReader rdr = cmd.ExecuteReader())  
  152. {  
  153. while (rdr.Read())  
  154. {  
  155. IssuerName.Text = rdr.GetValue(0).ToString();  
  156. }  
  157. }  
  158. }  
  159. catch  
  160. {  
  161. }  
  162. finally  
  163. {  
  164. conn.Close();  
  165. }  
  166. }  
  167. }  
  168. protected void GetReceiverName(object sender, EventArgs e)  
  169. {  
  170. using (SqlConnection conn = new SqlConnection(connString))  
  171. {  
  172. try  
  173. {  
  174. SqlCommand cmd = new SqlCommand("selectReceiverName", conn);  
  175. cmd.CommandType = CommandType.StoredProcedure;  
  176. cmd.Parameters.AddWithValue("@ReceiverCN", ReceiverCN.Text);  
  177. cmd.Connection = conn;  
  178. conn.Open();  
  179. using (SqlDataReader rdr = cmd.ExecuteReader())  
  180. {  
  181. while (rdr.Read())  
  182. {  
  183. ReceiverName.Text = rdr.GetValue(0).ToString();  
  184. }  
  185. }  
  186. }  
  187. catch  
  188. {  
  189. }  
  190. finally  
  191. {  
  192. conn.Close();  
  193. }  
  194. }  
  195. }  
  196. protected void GetLocation1()  
  197. {  
  198. SqlConnection conn = new SqlConnection(connString);  
  199. {  
  200. try  
  201. {  
  202. conn.Open();  
  203. SqlCommand cmd = new SqlCommand("spLocation", conn);  
  204. cmd.CommandType = CommandType.StoredProcedure;  
  205. ddlLocation1.DataSource = cmd.ExecuteReader();  
  206. ddlLocation1.DataTextField = "WorkArea";  
  207. ddlLocation1.DataBind();  
  208. conn.Close();  
  209. }  
  210. catch (Exception)  
  211. {  
  212. // Handle the error  
  213. }  
  214. }  
  215. ddlLocation2.Items.Insert(0, new ListItem("""0"));  
  216. if (ddlLocation1.SelectedValue == "OTHER")  
  217. {  
  218. //now handled with javascript  
  219. }  
  220. }  
  221. protected void GetLocation2()  
  222. {  
  223. using (SqlConnection conn = new SqlConnection(connString))  
  224. {  
  225. using (SqlCommand cmd = new SqlCommand("spLocation", conn))  
  226. {  
  227. cmd.CommandType = CommandType.StoredProcedure;  
  228. conn.Open();  
  229. ddlLocation2.DataSource = cmd.ExecuteReader();  
  230. ddlLocation2.DataTextField = "WorkArea";  
  231. ddlLocation2.DataBind();  
  232. }  
  233. }  
  234. ddlLocation2.Items.Insert(0, new ListItem("""0"));  
  235. }  
  236. protected void GetWAPType()  
  237. {  
  238. using (SqlConnection conn = new SqlConnection(connString))  
  239. {  
  240. using (SqlCommand cmd = new SqlCommand("spWAPType", conn))  
  241. {  
  242. cmd.CommandType = CommandType.StoredProcedure;  
  243. conn.Open();  
  244. ddlWAPType.DataSource = cmd.ExecuteReader();  
  245. ddlWAPType.DataTextField = "WAPType";  
  246. ddlWAPType.DataBind();  
  247. }  
  248. }  
  249. ddlWAPType.Items.Insert(0, new ListItem("Select WAP Type""0"));  
  250. }  
  251. protected void GetServiceCompany()  
  252. {  
  253. using (SqlConnection conn = new SqlConnection(connString))  
  254. {  
  255. string sqlQuery = "select * from tblContractor";  
  256. using (SqlCommand cmd = new SqlCommand(sqlQuery, conn))  
  257. {  
  258. cmd.CommandType = CommandType.Text;  
  259. conn.Open();  
  260. ddlContractor.DataSource = cmd.ExecuteReader();  
  261. ddlContractor.DataTextField = "Contractor";  
  262. ddlContractor.DataBind();  
  263. conn.Close();  
  264. }  
  265. }  
  266. ddlContractor.Items.Insert(0, new ListItem("Select Service Company""0"));  
  267. }  
  268. protected void GetJobType()  
  269. {  
  270. SqlConnection conn = new SqlConnection(connString);  
  271. {  
  272. try  
  273. {  
  274. conn.Open();  
  275. SqlCommand cmd = new SqlCommand("spJobType", conn);  
  276. cmd.CommandType = CommandType.StoredProcedure;  
  277. ddlJobType.DataSource = cmd.ExecuteReader();  
  278. ddlJobType.DataTextField = "JobType";  
  279. ddlJobType.DataBind();  
  280. conn.Close();  
  281. }  
  282. catch (Exception)  
  283. {  
  284. // Handle the error  
  285. }  
  286. }  
  287. ddlJobType.Items.Insert(0, new ListItem("Select Job Type""0"));  
  288. ddlJobTask2.Enabled = false;  
  289. }  
  290. protected void GetJobDetails(object sender, EventArgs e)  
  291. {  
  292. if (ddlJobType.SelectedValue == "0")  
  293. {  
  294. ddlJobTask2.Enabled = false;  
  295. }  
  296. else  
  297. {  
  298. ddlJobTask2.Enabled = true;  
  299. GetJobTask();  
  300. }  
  301. }  
  302. protected void GetJobTask()  
  303. {  
  304. using (SqlConnection conn = new SqlConnection(connString))  
  305. {  
  306. string sqlQuery = "SELECT JobTask FROM tblActivity WHERE JobType=@JobType";  
  307. using (SqlCommand cmd = new SqlCommand(sqlQuery, conn))  
  308. {  
  309. conn.Open();  
  310. cmd.CommandType = CommandType.Text;  
  311. cmd.Parameters.AddWithValue("@JobType", ddlJobType.SelectedValue);  
  312. ddlJobTask2.DataSource = cmd.ExecuteReader();  
  313. ddlJobTask2.DataTextField = "JobTask";  
  314. ddlJobTask2.DataBind();  
  315. }  
  316. }  
  317. ddlJobTask2.Items.Insert(0, new ListItem("Select Job Task""0"));  
  318. }  
  319. protected void GetJobTaskNew()  
  320. {  
  321. using (SqlConnection conn = new SqlConnection(connString))  
  322. {  
  323. string sqlQuery = "SELECT JobTask FROM WAPTask WHERE WAPNo=@WAPNo And JobType=@JobType And Status=1";  
  324. using (SqlCommand cmd = new SqlCommand(sqlQuery, conn))  
  325. {  
  326. conn.Open();  
  327. cmd.CommandType = CommandType.Text;  
  328. cmd.Parameters.AddWithValue("@WAPNo", tmpWAPNo.Text);  
  329. cmd.Parameters.AddWithValue("@JobType", txtJobType.Text);  
  330. ddlJobTask1.DataSource = cmd.ExecuteReader();  
  331. ddlJobTask1.DataTextField = "JobTask";  
  332. ddlJobTask1.DataBind();  
  333. }  
  334. }  
  335. ddlJobTask1.Items.Insert(0, new ListItem("Select Job Task""0"));  
  336. }  
  337. protected void GetChkCategory1()  
  338. {  
  339. SqlConnection conn = new SqlConnection(connString);  
  340. {  
  341. try  
  342. {  
  343. conn.Open();  
  344. SqlCommand cmd = new SqlCommand("spChkCategory", conn);  
  345. cmd.CommandType = CommandType.StoredProcedure;  
  346. ddlChkCategory1.DataSource = cmd.ExecuteReader();  
  347. ddlChkCategory1.DataTextField = "ChkCategory";  
  348. ddlChkCategory1.DataBind();  
  349. conn.Close();  
  350. }  
  351. catch (Exception)  
  352. {  
  353. // Handle the error  
  354. }  
  355. }  
  356. ddlChkCategory1.Items.Insert(0, new ListItem("Select Checklist Category""0"));  
  357. ddlChkDetails1.Enabled = false;  
  358. }  
  359. protected void GetChkCategory2()  
  360. {  
  361. SqlConnection conn = new SqlConnection(connString);  
  362. {  
  363. try  
  364. {  
  365. conn.Open();  
  366. SqlCommand cmd = new SqlCommand("spChkCategory", conn);  
  367. cmd.CommandType = CommandType.StoredProcedure;  
  368. ddlChkCategory2.DataSource = cmd.ExecuteReader();  
  369. ddlChkCategory2.DataTextField = "ChkCategory";  
  370. ddlChkCategory2.DataBind();  
  371. conn.Close();  
  372. }  
  373. catch (Exception)  
  374. {  
  375. // Handle the error  
  376. }  
  377. }  
  378. ddlChkCategory2.Items.Insert(0, new ListItem("Select Checklist Category""0"));  
  379. ddlChkDetails2.Enabled = false;  
  380. }  
  381. protected void GetChecklistDetails1(object sender, EventArgs e)  
  382. {  
  383. if (ddlChkCategory1.SelectedValue == "0")  
  384. {  
  385. ddlChkDetails1.Enabled = false;  
  386. }  
  387. else  
  388. {  
  389. ddlChkDetails1.Enabled = true;  
  390. GetChkDetails1();  
  391. }  
  392. }  
  393. protected void GetChecklistDetails2(object sender, EventArgs e)  
  394. {  
  395. if (ddlChkCategory2.SelectedValue == "0")  
  396. {  
  397. ddlChkDetails2.Enabled = false;  
  398. }  
  399. else  
  400. {  
  401. ddlChkDetails2.Enabled = true;  
  402. GetChkDetails2();  
  403. }  
  404. }  
  405. protected void GetChkDetails1()  
  406. {  
  407. SqlConnection conn = new SqlConnection(connString);  
  408. {  
  409. try  
  410. {  
  411. conn.Open();  
  412. SqlCommand cmd = new SqlCommand("spChkDetails", conn);  
  413. cmd.CommandType = CommandType.StoredProcedure;  
  414. cmd.Parameters.AddWithValue("@ChkCategory", ddlChkCategory1.SelectedValue);  
  415. ddlChkDetails1.DataSource = cmd.ExecuteReader();  
  416. ddlChkDetails1.DataTextField = "ChkDetails";  
  417. ddlChkDetails1.DataBind();  
  418. conn.Close();  
  419. }  
  420. catch (Exception)  
  421. {  
  422. // Handle the error  
  423. }  
  424. }  
  425. ddlChkDetails1.Items.Insert(0, new ListItem("Select Checklist Details""0"));  
  426. }  
  427. protected void GetChkDetails2()  
  428. {  
  429. SqlConnection conn = new SqlConnection(connString);  
  430. {  
  431. try  
  432. {  
  433. conn.Open();  
  434. SqlCommand cmd = new SqlCommand("spChkDetails", conn);  
  435. cmd.CommandType = CommandType.StoredProcedure;  
  436. cmd.Parameters.AddWithValue("@ChkCategory", ddlChkCategory2.SelectedValue);  
  437. ddlChkDetails2.DataSource = cmd.ExecuteReader();  
  438. ddlChkDetails2.DataTextField = "ChkDetails";  
  439. ddlChkDetails2.DataBind();  
  440. conn.Close();  
  441. }  
  442. catch (Exception)  
  443. {  
  444. // Handle the error  
  445. }  
  446. }  
  447. ddlChkDetails2.Items.Insert(0, new ListItem("Select Checklist Details""0"));  
  448. }  
  449. protected void GetDivisionName()  
  450. {  
  451. SqlConnection conn = new SqlConnection(connString);  
  452. {  
  453. try  
  454. {  
  455. conn.Open();  
  456. SqlCommand cmd = new SqlCommand("spDivision", conn);  
  457. cmd.CommandType = CommandType.StoredProcedure;  
  458. ddlDivision.DataSource = cmd.ExecuteReader();  
  459. ddlDivision.DataTextField = "Division";  
  460. ddlDivision.DataBind();  
  461. conn.Close();  
  462. }  
  463. catch (Exception)  
  464. {  
  465. // Handle the error  
  466. }  
  467. }  
  468. ddlDivision.Items.Insert(0, new ListItem("Select Division""0"));  
  469. ddlUnit.Enabled = false;  
  470. }  
  471. protected void GetDivisionDetails(object sender, EventArgs e)  
  472. {  
  473. if (ddlDivision.SelectedValue == "0")  
  474. {  
  475. ddlUnit.Enabled = false;  
  476. }  
  477. else  
  478. {  
  479. ddlUnit.Enabled = true;  
  480. GetUnitName();  
  481. }  
  482. }  
  483. protected void GetUnitName()  
  484. {  
  485. SqlConnection conn = new SqlConnection(connString);  
  486. {  
  487. try  
  488. {  
  489. conn.Open();  
  490. SqlCommand cmd = new SqlCommand("spUnit", conn);  
  491. cmd.CommandType = CommandType.StoredProcedure;  
  492. cmd.Parameters.Add("@Division", SqlDbType.VarChar).Value = ddlDivision.SelectedValue;  
  493. ddlUnit.DataSource = cmd.ExecuteReader();  
  494. ddlUnit.DataTextField = "Unit";  
  495. ddlUnit.DataBind();  
  496. conn.Close();  
  497. }  
  498. catch (Exception)  
  499. {  
  500. // Handle the error  
  501. }  
  502. ddlUnit.Items.Insert(0, new ListItem("Select Unit""0"));  
  503. }  
  504. }  
  505. protected void GetData(object sender, EventArgs e)  
  506. {  
  507. if (String.IsNullOrEmpty(tmpWAPNo.Text))  
  508. {  
  509. ScriptManager.RegisterClientScriptBlock(thisthis.GetType(), "alertMessage""alert('Enter WAP No')"true);  
  510. }  
  511. else  
  512. {  
  513. CheckWAP();  
  514. GetWAPData();  
  515. }  
  516. }  
  517. protected void CheckWAP()  
  518. {  
  519. string sqlQuery = "SELECT Count(*) as result FROM WAPData WHERE WAPNo=@WAPNo";  
  520. using (SqlConnection conn = new SqlConnection(connString))  
  521. {  
  522. using (SqlCommand cmd = new SqlCommand(sqlQuery, conn))  
  523. {  
  524. cmd.CommandType = CommandType.Text;  
  525. cmd.Parameters.AddWithValue("@WAPNo", tmpWAPNo.Text);  
  526. conn.Open();  
  527. int result = (int)cmd.ExecuteScalar();  
  528. if (result > 0)  
  529. {  
  530. GetWAPData();  
  531. GetJobTaskNew();  
  532. ReviewExisting.Visible = true;  
  533. Button2.Enabled = true;  
  534. }  
  535. else  
  536. {  
  537. ScriptManager.RegisterClientScriptBlock(thisthis.GetType(), "alertMessage""alert('Data not exisiting for this WAP No')"true);  
  538. ReviewNew.Visible = true;  
  539. }  
  540. }  
  541. }  
  542. }  
  543. protected void GetWAPData()  
  544. {  
  545. string sqlQuery = "SELECT * FROM WAPData WHERE WAPNo=@WAPNo";  
  546. using (SqlConnection conn = new SqlConnection(connString))  
  547. {  
  548. using (SqlCommand cmd = new SqlCommand(sqlQuery, conn))  
  549. {  
  550. cmd.CommandType = CommandType.Text;  
  551. cmd.Parameters.AddWithValue("@WAPNo", tmpWAPNo.Text);  
  552. conn.Open();  
  553. using (SqlDataReader rdr = cmd.ExecuteReader())  
  554. {  
  555. while (rdr.Read())  
  556. {  
  557. txtIssueDT1.Text = rdr["IssueDT"].ToString();  
  558. txtJobType.Text = rdr["JobType"].ToString();  
  559. txtWAPType.Text = rdr["WAPType"].ToString();  
  560. txtWellNo1.Text = rdr["WellNo"].ToString();  
  561. txtDivision.Text = rdr["Division"].ToString();  
  562. txtUnit.Text = rdr["Unit"].ToString();  
  563. txtContractor.Text = rdr["Contractor"].ToString();  
  564. }  
  565. }  
  566. }  
  567. }  
  568. }  
  569. public void GetTaskData()  
  570. {  
  571. string sqlQuery = "SELECT * FROM WAPTask WHERE WAPNo=@WAPNo And JobType=@JobType And JobTask=@JobTask And Status=1";  
  572. using (SqlConnection conn = new SqlConnection(connString))  
  573. {  
  574. using (SqlCommand cmd = new SqlCommand(sqlQuery, conn))  
  575. {  
  576. cmd.CommandType = CommandType.Text;  
  577. cmd.Parameters.AddWithValue("@WAPNo", tmpWAPNo.Text);  
  578. cmd.Parameters.AddWithValue("@JobType", txtJobType.Text);  
  579. cmd.Parameters.AddWithValue("@JobTask", ddlJobTask1.SelectedValue);  
  580. conn.Open();  
  581. using (SqlDataReader rdr = cmd.ExecuteReader())  
  582. {  
  583. while (rdr.Read())  
  584. {  
  585. txtIssuerBN1.Text = rdr["IssuerBN"].ToString();  
  586. txtIssuerName1.Text = rdr["IssuerName"].ToString();  
  587. txtReceiverCN1.Text = rdr["ReceiverCN"].ToString();  
  588. txtReceiverName1.Text = rdr["ReceiverName"].ToString();  
  589. }  
  590. }  
  591. }  
  592. }  
  593. }  
  594. }  
  595. }  
 
 
 
 
 

Answers (2)