TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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
<body>
<form id=
"form1"
runat=
"server"
>
<div id=
"NavigationBar"
>
<asp:SiteMapDataSource ID=
"navbar"
runat=
"server"
ShowStartingNode=
"false"
/>
<asp:Menu ID=
"NavMenu"
runat=
"server"
Orientation=
"Horizontal"
RenderingMode=
"List"
DataSourceID=
"navbar"
/>
</div>
<br /><br />
<asp:ScriptManager ID=
"ScriptManager1"
runat=
"server"
></asp:ScriptManager>
<div
class
=
"container"
>
<asp:Panel runat=
"server"
DefaultButton=
"Button1"
>
<p
class
=
"text-lg-left font-weight-bold"
style=
"font-size:14px"
>WAP Review</p>
<p
class
=
"text-success"
style=
"font-size:12px"
>Enter WAPNo to be reviewed</p>
<div
class
=
"row"
>
<div
class
=
"col-2"
>
<asp:TextBox ID=
"tmpWAPNo"
class
=
"form-control"
runat=
"server"
/>
<asp:RequiredFieldValidator id=
"val1"
runat=
"server"
style=
"display:none"
ControlToValidate=
"tmpWAPNo"
/>
</div>
<div
class
=
"col-2"
>
<asp:Button
class
=
"btn btn-link"
ID=
"Button1"
Text=
"Load Data"
runat=
"server"
OnClick=
"GetData"
UseSubmitBehavior=
"false"
/>
</div>
</div>
<hr /><br />
</asp:Panel>
<asp:Panel runat=
"server"
DefaultButton=
"Button3"
>
<div id=
"ReviewNew"
runat=
"server"
visible=
"false"
>
<div id=
"General2"
class
=
"row no-gutters"
>
<div
class
=
"col-2"
>
<asp:Label ID=
"Label39"
class
=
"form-control badge-primary"
Text=
"IssueDT"
runat=
"server"
/>
<asp:TextBox ID=
"txtIssueDT2"
class
=
"form-control"
runat=
"server"
/>
<asp:RequiredFieldValidator id=
"val2"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtIssueDT2"
/>
</div>
<div
class
=
"col-2"
>
<asp:Label ID=
"Label1"
class
=
"form-control badge-primary"
Text=
"WellNo"
runat=
"server"
/>
<asp:TextBox ID=
"txtWellNo2"
class
=
"form-control"
runat=
"server"
/>
<asp:RequiredFieldValidator id=
"RequiredFieldValidator1"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtWellNo2"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label ID=
"Label40"
class
=
"form-control badge-primary"
runat=
"server"
Text=
"Job Type"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlJobType"
runat=
"server"
DataTextField=
"JobType"
DataValueField=
"JobType"
AutoPostBack=
"True"
OnSelectedIndexChanged=
"GetJobDetails"
/>
<asp:RequiredFieldValidator id=
"val3"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlJobType"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label49"
runat=
"server"
Text=
"Job Task"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlJobTask2"
runat=
"server"
DataTextField=
"JobTask"
DataValueField=
"JobTask"
AutoPostBack=
"True"
/>
<asp:RequiredFieldValidator id=
"val12"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlJobTask2"
InitialValue=
"0"
/>
</div>
</div>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-4"
>
<asp:Label ID=
"Label42"
class
=
"form-control badge-primary"
runat=
"server"
Text=
"Division:"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlDivision"
runat=
"server"
DataTextField=
"Division"
DataValueField=
"Division"
AutoPostBack=
"True"
OnSelectedIndexChanged=
"GetDivisionDetails"
/>
<asp:RequiredFieldValidator id=
"val5"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlDivision"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label ID=
"Label43"
class
=
"form-control badge-primary"
runat=
"server"
Text=
"Unit:"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlUnit"
runat=
"server"
DataTextField=
"Unit"
DataValueField=
"Unit"
AutoPostBack=
"True"
/>
<asp:RequiredFieldValidator id=
"val6"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlUnit"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label ID=
"Label44"
class
=
"form-control badge-primary"
runat=
"server"
Text=
"Service Company"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlContractor"
runat=
"server"
DataTextField=
"Contractor"
DataValueField=
"Contractor"
/>
<asp:RequiredFieldValidator ID=
"val7"
runat=
"server"
ControlToValidate=
"ddlContractor"
InitialValue=
"0"
/>
</div>
</div>
<hr /><br />
<div id=
"Specific2"
class
=
"row no-gutters"
>
<div
class
=
"col-2"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label45"
runat=
"server"
Text=
"Date:"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtDate2"
runat=
"server"
ReadOnly=
"true"
/>
<asp:RequiredFieldValidator id=
"val8"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtDate2"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label46"
runat=
"server"
Text=
"Reviewer:"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtReviewer2"
runat=
"server"
ReadOnly=
"true"
/>
<asp:RequiredFieldValidator id=
"val9"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtReviewer2"
/>
</div>
<div
class
=
"col-3"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label47"
runat=
"server"
Text=
"Location/ Area:"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlLocation2"
runat=
"server"
DataTextField=
"WorkArea"
DataValueField=
"WorkArea"
/>
<asp:RequiredFieldValidator id=
"val10"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlLocation2"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-3"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label48"
runat=
"server"
Text=
"WAP Type"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlWAPType"
runat=
"server"
DataTextField=
"WAPType"
DataValueField=
"WAPType"
/>
<asp:RequiredFieldValidator id=
"val11"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlWAPType"
InitialValue=
"0"
/>
</div>
</div>
<hr /><br />
<div id=
"Issuer2"
class
=
"row no-gutters"
>
<div
class
=
"col"
>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-12"
>
<asp:Label
class
=
"form-control badge-success"
ID=
"Label50"
runat=
"server"
Text=
"Task Issuer"
/>
</div>
</div>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label52"
runat=
"server"
Text=
"Issuer BN"
/>
<asp:TextBox
class
=
"form-control"
ID=
"IssuerBN"
runat=
"server"
AutoPostBack=
"True"
OnTextChanged=
"GetIssuerName"
/>
<asp:RequiredFieldValidator id=
"val13"
runat=
"server"
style=
"display:none"
ControlToValidate=
"IssuerBN"
/>
</div>
<div
class
=
"col-8"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label53"
runat=
"server"
Text=
"Issuer Name"
/>
<asp:TextBox
class
=
"form-control"
ID=
"IssuerName"
runat=
"server"
ReadOnly=
"true"
/>
<asp:RequiredFieldValidator id=
"val14"
runat=
"server"
style=
"display:none"
ControlToValidate=
"IssuerName"
/>
</div>
</div>
</div>
<div
class
=
"col"
>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-12"
>
<asp:Label
class
=
"form-control badge-success"
ID=
"Label51"
runat=
"server"
Text=
"Task Receiver"
/>
</div>
</div>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label54"
runat=
"server"
Text=
"Receiver CN"
/>
<asp:TextBox
class
=
"form-control"
ID=
"ReceiverCN"
runat=
"server"
AutoPostBack=
"True"
OnTextChanged=
"GetReceiverName"
/>
<asp:RequiredFieldValidator id=
"val15"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ReceiverCN"
/>
</div>
<div
class
=
"col-8"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label55"
runat=
"server"
Text=
"Receiver Name"
/>
<asp:TextBox
class
=
"form-control"
ID=
"ReceiverName"
runat=
"server"
ReadOnly=
"true"
/>
<asp:RequiredFieldValidator id=
"val16"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ReceiverName"
/>
</div>
</div>
</div>
</div>
<hr /><br />
<div id=
"Checklist2"
class
=
"row no-gutters"
>
<div
class
=
"col-3"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label62"
runat=
"server"
Text=
"Checklist Category"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlChkCategory2"
runat=
"server"
DataTextField=
"ChkCategory"
DataValueField=
"ChkCategory"
AutoPostBack=
"True"
OnSelectedIndexChanged=
"GetChecklistDetails2"
/>
<asp:RequiredFieldValidator id=
"val17"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlChkCategory2"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-3"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label63"
runat=
"server"
Text=
"Checklist Details"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlChkDetails2"
runat=
"server"
DataTextField=
"ChkDetails"
DataValueField=
"ChkDetails"
/>
<asp:RequiredFieldValidator id=
"val18"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlChkDetails2"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-6"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label64"
runat=
"server"
Text=
"Remarks"
/>
<asp:TextBox
class
=
"form-control"
TextMode=
"MultiLine"
ID=
"txtRemarks2"
runat=
"server"
/>
<asp:RequiredFieldValidator id=
"val19"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtRemarks2"
/>
</div>
</div>
<asp:Button
class
=
"btn btn-link"
ID=
"Button3"
runat=
"server"
OnClick=
"ReviewNewWAP"
Text=
"Save Data"
/>
<hr /><br />
</div>
</asp:Panel>
<asp:Panel runat=
"server"
DefaultButton=
"Button4"
>
<div id=
"ReviewExisting"
runat=
"server"
visible=
"false"
>
<div id=
"General1"
class
=
"row no-gutters"
>
<div
class
=
"col-2"
>
<asp:Label ID=
"Label33"
class
=
"form-control badge-primary"
Text=
"IssueDT"
runat=
"server"
/>
<asp:TextBox ID=
"txtIssueDT1"
class
=
"form-control"
runat=
"server"
ReadOnly=
"true"
/>
</div>
<div
class
=
"col-2"
>
<asp:Label ID=
"Label35"
class
=
"form-control badge-primary"
Text=
"WellNo"
runat=
"server"
/>
<asp:TextBox ID=
"txtWellNo1"
class
=
"form-control"
runat=
"server"
ReadOnly=
"true"
/>
</div>
<div
class
=
"col-3"
>
<asp:Label ID=
"Label34"
class
=
"form-control badge-primary"
Text=
"Job Type"
runat=
"server"
/>
<asp:TextBox ID=
"txtJobType"
class
=
"form-control"
runat=
"server"
ReadOnly=
"true"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label81"
runat=
"server"
Text=
"Job Task"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlJobTask1"
runat=
"server"
DataTextField=
"JobTask"
DataValueField=
"JobTask"
/>
<asp:RequiredFieldValidator id=
"val21"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlJobTask1"
InitialValue=
"0"
/>
</div>
</div>
<hr /><br />
<div
class
=
"row no-gutters"
>
<div
class
=
"col-4"
>
<asp:Label ID=
"Label36"
class
=
"form-control badge-primary"
Text=
"Division"
runat=
"server"
/>
<asp:TextBox ID=
"txtDivision"
class
=
"form-control"
runat=
"server"
ReadOnly=
"true"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label ID=
"Label37"
class
=
"form-control badge-primary"
Text=
"Unit"
runat=
"server"
/>
<asp:TextBox ID=
"txtUnit"
class
=
"form-control"
runat=
"server"
ReadOnly=
"true"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label ID=
"Label38"
class
=
"form-control badge-primary"
Text=
"Service Company"
runat=
"server"
/>
<asp:TextBox ID=
"txtContractor"
class
=
"form-control"
runat=
"server"
ReadOnly=
"true"
/>
</div>
</div>
<hr /><br />
<div id=
"Specific1"
class
=
"row no-gutters"
>
<div
class
=
"col-2"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label77"
runat=
"server"
Text=
"Date:"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtDate1"
runat=
"server"
ReadOnly=
"true"
/>
</div>
<div
class
=
"col-2"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label78"
runat=
"server"
Text=
"Reviewer:"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtReviewer1"
runat=
"server"
ReadOnly=
"true"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label79"
runat=
"server"
Text=
"Location/ Area:"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlLocation1"
runat=
"server"
DataTextField=
"WorkArea"
DataValueField=
"WorkArea"
/>
<asp:RequiredFieldValidator id=
"val20"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlLocation1"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label80"
runat=
"server"
Text=
"WAP Type"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtWAPType"
runat=
"server"
ReadOnly=
"true"
/>
</div>
</div>
<hr /><br />
<asp:UpdatePanel ID=
"UpdatePanel1"
runat=
"server"
>
<ContentTemplate>
<div
class
=
"col-1"
>
<asp:Label
class
=
"form-control invisible"
ID=
"Label2"
runat=
"server"
Text=
"Job Task"
/>
<asp:Button
class
=
"btn btn-link"
ID=
"Button2"
Text=
"Load Task Data"
runat=
"server"
OnClick=
"LoadTaskData"
UseSubmitBehavior=
"false"
/>
</div>
<div id=
"Issuer1"
class
=
"row no-gutters"
>
<div
class
=
"col"
>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-12"
>
<asp:Label
class
=
"form-control badge-success"
ID=
"Label56"
runat=
"server"
Text=
"Task Issuer"
/>
</div>
</div>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label58"
runat=
"server"
Text=
"Issuer BN"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtIssuerBN1"
runat=
"server"
ReadOnly=
"true"
/>
<asp:RequiredFieldValidator id=
"val30"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtIssuerBN1"
/>
</div>
<div
class
=
"col-8"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label59"
runat=
"server"
Text=
"Issuer Name"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtIssuerName1"
runat=
"server"
ReadOnly=
"true"
/>
<asp:RequiredFieldValidator id=
"val31"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtIssuerName1"
/>
</div>
</div>
</div>
<div
class
=
"col"
>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-12"
>
<asp:Label
class
=
"form-control badge-success"
ID=
"Label57"
runat=
"server"
Text=
"Task Receiver"
/>
</div>
</div>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label60"
runat=
"server"
Text=
"Receiver CN"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtReceiverCN1"
runat=
"server"
ReadOnly=
"true"
/>
<asp:RequiredFieldValidator id=
"val32"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtReceiverCN1"
/>
</div>
<div
class
=
"col-8"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label61"
runat=
"server"
Text=
"Receiver Name"
/>
<asp:TextBox
class
=
"form-control"
ID=
"txtReceiverName1"
runat=
"server"
ReadOnly=
"true"
/><br />
<asp:RequiredFieldValidator id=
"val33"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtReceiverName1"
/>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div id=
"Checklist1"
class
=
"row no-gutters"
runat=
"server"
>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label94"
runat=
"server"
Text=
"Checklist Category"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlChkCategory1"
runat=
"server"
DataTextField=
"ChkCategory"
DataValueField=
"ChkCategory"
AutoPostBack=
"True"
OnSelectedIndexChanged=
"GetChecklistDetails1"
/>
<asp:RequiredFieldValidator id=
"val22"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlChkCategory1"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label95"
runat=
"server"
Text=
"Checklist Details"
/>
<asp:DropDownList
class
=
"form-control"
ID=
"ddlChkDetails1"
runat=
"server"
DataTextField=
"ChkDetails"
DataValueField=
"ChkDetails"
/>
<asp:RequiredFieldValidator id=
"val23"
runat=
"server"
style=
"display:none"
ControlToValidate=
"ddlChkDetails1"
InitialValue=
"0"
/>
</div>
<div
class
=
"col-4"
>
<asp:Label
class
=
"form-control badge-primary"
ID=
"Label96"
runat=
"server"
Text=
"Remarks"
/>
<asp:TextBox
class
=
"form-control"
TextMode=
"MultiLine"
ID=
"txtRemarks1"
runat=
"server"
/>
<asp:RequiredFieldValidator id=
"val24"
runat=
"server"
style=
"display:none"
ControlToValidate=
"txtRemarks1"
/><br />
</div>
</div>
<asp:Button
class
=
"btn btn-link"
ID=
"Button4"
runat=
"server"
OnClick=
"ReviewExistingWAP"
Text=
"Save Data"
/>
<hr /><br />
</div>
</asp:Panel>
Code behind
using
System;
using
System.Data;
using
System.Data.SqlClient;
using
System.Web.UI.WebControls;
using
System.Configuration;
using
System.Web.Services;
using
System.Collections.Generic;
using
System.Web.UI;
using
System.Drawing;
namespace
WAPReview
{
public
partial
class
ReviewWAP : System.Web.UI.Page
{
string
connString = Properties.Settings.Default.ConnectionString.ToString();
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(Users.UserRole !=
"Admin"
& Users.UserRole !=
"Reviewer"
)
{
Response.Redirect(
"/HomePage.aspx"
,
false
);
}
if
(!IsPostBack)
{
GetWAPData();
GetDivisionName();
GetLocation1();
GetLocation2();
GetWAPType();
GetServiceCompany();
GetJobType();
GetChkCategory1();
GetChkCategory2();
}
Button2.Enabled =
false
;
Button3.Enabled =
false
;
Button4.Enabled =
false
;
Checklist1.Visible =
false
;
string
UserName = Environment.UserName;
FillUserDetails FS =
new
FillUserDetails();
FS.fillUser(UserName);
txtReviewer1.Text = Users.FullName;
txtReviewer2.Text = Users.FullName;
txtDate1.Text = DateTime.Now.ToString();
txtDate2.Text = DateTime.Now.ToString();
}
protected
void
ReviewNewWAP(
object
sender, EventArgs e)
{
AddWAPReviewDataNew();
}
protected
void
ReviewExistingWAP(
object
sender, EventArgs e)
{
AddWAPReviewDataExisting();
}
protected
void
LoadTaskData(
object
sender, EventArgs e)
{
if
(ddlJobTask1.DataValueField ==
"0"
)
{
ddlJobTask1.Attributes.Add(
"class"
,
"border-warning"
);
return
;
}
else
{
GetTaskData();
Button3.Enabled =
true
;
Button4.Enabled =
true
;
Checklist1.Visible =
true
;
}
}
protected
void
AddWAPReviewDataNew()
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
using
(SqlCommand cmd =
new
SqlCommand(
"WAPReviewInsert"
))
{
cmd.CommandType = CommandType.StoredProcedure;
{
cmd.Parameters.AddWithValue(
"@WAPNo"
, tmpWAPNo.Text);
cmd.Parameters.AddWithValue(
"@ReviewDate"
, txtDate2.Text);
cmd.Parameters.AddWithValue(
"@WorkArea"
, ddlLocation2.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@Reviewer"
, txtReviewer2.Text);
cmd.Parameters.AddWithValue(
"@Division"
, ddlDivision.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@Unit"
, ddlUnit.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@Contractor"
, ddlContractor.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@WAPType"
, ddlWAPType.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@JobType"
, ddlJobType.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@JobTask"
, ddlJobTask2.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@IssuerBN"
, IssuerBN.Text);
cmd.Parameters.AddWithValue(
"@IssuerName"
, IssuerName.Text);
cmd.Parameters.AddWithValue(
"@ReceiverCN"
, ReceiverCN.Text);
cmd.Parameters.AddWithValue(
"@ReceiverName"
, ReceiverName.Text);
cmd.Parameters.AddWithValue(
"@ChkCategory"
, ddlChkCategory2.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@ChkDetails"
, ddlChkDetails2.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@Remarks"
, txtRemarks2.Text);
cmd.Connection = conn;
conn.Open();
int
result = cmd.ExecuteNonQuery();
if
(result > 0)
{
ScriptManager.RegisterClientScriptBlock(
this
,
this
.GetType(),
"alertMessage"
,
"alert('Record Inserted Successfully')"
,
true
);
}
}
}
}
}
protected
void
AddWAPReviewDataExisting()
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
using
(SqlCommand cmd =
new
SqlCommand(
"WAPReviewInsert"
))
{
cmd.CommandType = CommandType.StoredProcedure;
{
cmd.Parameters.AddWithValue(
"@WAPNo"
, tmpWAPNo.Text);
cmd.Parameters.AddWithValue(
"@ReviewDate"
, txtDate1.Text);
cmd.Parameters.AddWithValue(
"@WorkArea"
, ddlLocation1.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@Reviewer"
, txtReviewer1.Text);
cmd.Parameters.AddWithValue(
"@Division"
, txtDivision.Text);
cmd.Parameters.AddWithValue(
"@Unit"
, txtUnit.Text);
cmd.Parameters.AddWithValue(
"@Contractor"
, txtContractor.Text);
cmd.Parameters.AddWithValue(
"@WAPType"
, txtWAPType.Text);
cmd.Parameters.AddWithValue(
"@JobType"
, txtJobType.Text);
cmd.Parameters.AddWithValue(
"@JobTask"
, ddlJobTask1.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@IssuerBN"
, txtIssuerBN1.Text);
cmd.Parameters.AddWithValue(
"@IssuerName"
, txtIssuerName1.Text);
cmd.Parameters.AddWithValue(
"@ReceiverCN"
, txtReceiverCN1.Text);
cmd.Parameters.AddWithValue(
"@ReceiverName"
, txtReceiverName1.Text);
cmd.Parameters.AddWithValue(
"@ChkCategory"
, ddlChkCategory1.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@ChkDetails"
, ddlChkDetails1.SelectedItem.Value);
cmd.Parameters.AddWithValue(
"@Remarks"
, txtRemarks1.Text);
cmd.Connection = conn;
conn.Open();
int
result = cmd.ExecuteNonQuery();
if
(result > 0)
{
ScriptManager.RegisterClientScriptBlock(
this
,
this
.GetType(),
"alertMessage"
,
"alert('Record Inserted Successfully')"
,
true
);
}
}
}
}
}
protected
void
GetIssuerName(
object
sender, EventArgs e)
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
try
{
SqlCommand cmd =
new
SqlCommand(
"selectIssuerName"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@IssuerBN"
, IssuerBN.Text);
cmd.Connection = conn;
conn.Open();
using
(SqlDataReader rdr = cmd.ExecuteReader())
{
while
(rdr.Read())
{
IssuerName.Text = rdr.GetValue(0).ToString();
}
}
}
catch
{
}
finally
{
conn.Close();
}
}
}
protected
void
GetReceiverName(
object
sender, EventArgs e)
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
try
{
SqlCommand cmd =
new
SqlCommand(
"selectReceiverName"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@ReceiverCN"
, ReceiverCN.Text);
cmd.Connection = conn;
conn.Open();
using
(SqlDataReader rdr = cmd.ExecuteReader())
{
while
(rdr.Read())
{
ReceiverName.Text = rdr.GetValue(0).ToString();
}
}
}
catch
{
}
finally
{
conn.Close();
}
}
}
protected
void
GetLocation1()
{
SqlConnection conn =
new
SqlConnection(connString);
{
try
{
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"spLocation"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
ddlLocation1.DataSource = cmd.ExecuteReader();
ddlLocation1.DataTextField =
"WorkArea"
;
ddlLocation1.DataBind();
conn.Close();
}
catch
(Exception)
{
// Handle the error
}
}
ddlLocation2.Items.Insert(0,
new
ListItem(
""
,
"0"
));
if
(ddlLocation1.SelectedValue ==
"OTHER"
)
{
//now handled with javascript
}
}
protected
void
GetLocation2()
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
using
(SqlCommand cmd =
new
SqlCommand(
"spLocation"
, conn))
{
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
ddlLocation2.DataSource = cmd.ExecuteReader();
ddlLocation2.DataTextField =
"WorkArea"
;
ddlLocation2.DataBind();
}
}
ddlLocation2.Items.Insert(0,
new
ListItem(
""
,
"0"
));
}
protected
void
GetWAPType()
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
using
(SqlCommand cmd =
new
SqlCommand(
"spWAPType"
, conn))
{
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
ddlWAPType.DataSource = cmd.ExecuteReader();
ddlWAPType.DataTextField =
"WAPType"
;
ddlWAPType.DataBind();
}
}
ddlWAPType.Items.Insert(0,
new
ListItem(
"Select WAP Type"
,
"0"
));
}
protected
void
GetServiceCompany()
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
string
sqlQuery =
"select * from tblContractor"
;
using
(SqlCommand cmd =
new
SqlCommand(sqlQuery, conn))
{
cmd.CommandType = CommandType.Text;
conn.Open();
ddlContractor.DataSource = cmd.ExecuteReader();
ddlContractor.DataTextField =
"Contractor"
;
ddlContractor.DataBind();
conn.Close();
}
}
ddlContractor.Items.Insert(0,
new
ListItem(
"Select Service Company"
,
"0"
));
}
protected
void
GetJobType()
{
SqlConnection conn =
new
SqlConnection(connString);
{
try
{
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"spJobType"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
ddlJobType.DataSource = cmd.ExecuteReader();
ddlJobType.DataTextField =
"JobType"
;
ddlJobType.DataBind();
conn.Close();
}
catch
(Exception)
{
// Handle the error
}
}
ddlJobType.Items.Insert(0,
new
ListItem(
"Select Job Type"
,
"0"
));
ddlJobTask2.Enabled =
false
;
}
protected
void
GetJobDetails(
object
sender, EventArgs e)
{
if
(ddlJobType.SelectedValue ==
"0"
)
{
ddlJobTask2.Enabled =
false
;
}
else
{
ddlJobTask2.Enabled =
true
;
GetJobTask();
}
}
protected
void
GetJobTask()
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
string
sqlQuery =
"SELECT JobTask FROM tblActivity WHERE JobType=@JobType"
;
using
(SqlCommand cmd =
new
SqlCommand(sqlQuery, conn))
{
conn.Open();
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue(
"@JobType"
, ddlJobType.SelectedValue);
ddlJobTask2.DataSource = cmd.ExecuteReader();
ddlJobTask2.DataTextField =
"JobTask"
;
ddlJobTask2.DataBind();
}
}
ddlJobTask2.Items.Insert(0,
new
ListItem(
"Select Job Task"
,
"0"
));
}
protected
void
GetJobTaskNew()
{
using
(SqlConnection conn =
new
SqlConnection(connString))
{
string
sqlQuery =
"SELECT JobTask FROM WAPTask WHERE WAPNo=@WAPNo And JobType=@JobType And Status=1"
;
using
(SqlCommand cmd =
new
SqlCommand(sqlQuery, conn))
{
conn.Open();
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue(
"@WAPNo"
, tmpWAPNo.Text);
cmd.Parameters.AddWithValue(
"@JobType"
, txtJobType.Text);
ddlJobTask1.DataSource = cmd.ExecuteReader();
ddlJobTask1.DataTextField =
"JobTask"
;
ddlJobTask1.DataBind();
}
}
ddlJobTask1.Items.Insert(0,
new
ListItem(
"Select Job Task"
,
"0"
));
}
protected
void
GetChkCategory1()
{
SqlConnection conn =
new
SqlConnection(connString);
{
try
{
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"spChkCategory"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
ddlChkCategory1.DataSource = cmd.ExecuteReader();
ddlChkCategory1.DataTextField =
"ChkCategory"
;
ddlChkCategory1.DataBind();
conn.Close();
}
catch
(Exception)
{
// Handle the error
}
}
ddlChkCategory1.Items.Insert(0,
new
ListItem(
"Select Checklist Category"
,
"0"
));
ddlChkDetails1.Enabled =
false
;
}
protected
void
GetChkCategory2()
{
SqlConnection conn =
new
SqlConnection(connString);
{
try
{
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"spChkCategory"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
ddlChkCategory2.DataSource = cmd.ExecuteReader();
ddlChkCategory2.DataTextField =
"ChkCategory"
;
ddlChkCategory2.DataBind();
conn.Close();
}
catch
(Exception)
{
// Handle the error
}
}
ddlChkCategory2.Items.Insert(0,
new
ListItem(
"Select Checklist Category"
,
"0"
));
ddlChkDetails2.Enabled =
false
;
}
protected
void
GetChecklistDetails1(
object
sender, EventArgs e)
{
if
(ddlChkCategory1.SelectedValue ==
"0"
)
{
ddlChkDetails1.Enabled =
false
;
}
else
{
ddlChkDetails1.Enabled =
true
;
GetChkDetails1();
}
}
protected
void
GetChecklistDetails2(
object
sender, EventArgs e)
{
if
(ddlChkCategory2.SelectedValue ==
"0"
)
{
ddlChkDetails2.Enabled =
false
;
}
else
{
ddlChkDetails2.Enabled =
true
;
GetChkDetails2();
}
}
protected
void
GetChkDetails1()
{
SqlConnection conn =
new
SqlConnection(connString);
{
try
{
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"spChkDetails"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@ChkCategory"
, ddlChkCategory1.SelectedValue);
ddlChkDetails1.DataSource = cmd.ExecuteReader();
ddlChkDetails1.DataTextField =
"ChkDetails"
;
ddlChkDetails1.DataBind();
conn.Close();
}
catch
(Exception)
{
// Handle the error
}
}
ddlChkDetails1.Items.Insert(0,
new
ListItem(
"Select Checklist Details"
,
"0"
));
}
protected
void
GetChkDetails2()
{
SqlConnection conn =
new
SqlConnection(connString);
{
try
{
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"spChkDetails"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@ChkCategory"
, ddlChkCategory2.SelectedValue);
ddlChkDetails2.DataSource = cmd.ExecuteReader();
ddlChkDetails2.DataTextField =
"ChkDetails"
;
ddlChkDetails2.DataBind();
conn.Close();
}
catch
(Exception)
{
// Handle the error
}
}
ddlChkDetails2.Items.Insert(0,
new
ListItem(
"Select Checklist Details"
,
"0"
));
}
protected
void
GetDivisionName()
{
SqlConnection conn =
new
SqlConnection(connString);
{
try
{
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"spDivision"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
ddlDivision.DataSource = cmd.ExecuteReader();
ddlDivision.DataTextField =
"Division"
;
ddlDivision.DataBind();
conn.Close();
}
catch
(Exception)
{
// Handle the error
}
}
ddlDivision.Items.Insert(0,
new
ListItem(
"Select Division"
,
"0"
));
ddlUnit.Enabled =
false
;
}
protected
void
GetDivisionDetails(
object
sender, EventArgs e)
{
if
(ddlDivision.SelectedValue ==
"0"
)
{
ddlUnit.Enabled =
false
;
}
else
{
ddlUnit.Enabled =
true
;
GetUnitName();
}
}
protected
void
GetUnitName()
{
SqlConnection conn =
new
SqlConnection(connString);
{
try
{
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"spUnit"
, conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(
"@Division"
, SqlDbType.VarChar).Value = ddlDivision.SelectedValue;
ddlUnit.DataSource = cmd.ExecuteReader();
ddlUnit.DataTextField =
"Unit"
;
ddlUnit.DataBind();
conn.Close();
}
catch
(Exception)
{
// Handle the error
}
ddlUnit.Items.Insert(0,
new
ListItem(
"Select Unit"
,
"0"
));
}
}
protected
void
GetData(
object
sender, EventArgs e)
{
if
(String.IsNullOrEmpty(tmpWAPNo.Text))
{
ScriptManager.RegisterClientScriptBlock(
this
,
this
.GetType(),
"alertMessage"
,
"alert('Enter WAP No')"
,
true
);
}
else
{
CheckWAP();
GetWAPData();
}
}
protected
void
CheckWAP()
{
string
sqlQuery =
"SELECT Count(*) as result FROM WAPData WHERE WAPNo=@WAPNo"
;
using
(SqlConnection conn =
new
SqlConnection(connString))
{
using
(SqlCommand cmd =
new
SqlCommand(sqlQuery, conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue(
"@WAPNo"
, tmpWAPNo.Text);
conn.Open();
int
result = (
int
)cmd.ExecuteScalar();
if
(result > 0)
{
GetWAPData();
GetJobTaskNew();
ReviewExisting.Visible =
true
;
Button2.Enabled =
true
;
}
else
{
ScriptManager.RegisterClientScriptBlock(
this
,
this
.GetType(),
"alertMessage"
,
"alert('Data not exisiting for this WAP No')"
,
true
);
ReviewNew.Visible =
true
;
}
}
}
}
protected
void
GetWAPData()
{
string
sqlQuery =
"SELECT * FROM WAPData WHERE WAPNo=@WAPNo"
;
using
(SqlConnection conn =
new
SqlConnection(connString))
{
using
(SqlCommand cmd =
new
SqlCommand(sqlQuery, conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue(
"@WAPNo"
, tmpWAPNo.Text);
conn.Open();
using
(SqlDataReader rdr = cmd.ExecuteReader())
{
while
(rdr.Read())
{
txtIssueDT1.Text = rdr[
"IssueDT"
].ToString();
txtJobType.Text = rdr[
"JobType"
].ToString();
txtWAPType.Text = rdr[
"WAPType"
].ToString();
txtWellNo1.Text = rdr[
"WellNo"
].ToString();
txtDivision.Text = rdr[
"Division"
].ToString();
txtUnit.Text = rdr[
"Unit"
].ToString();
txtContractor.Text = rdr[
"Contractor"
].ToString();
}
}
}
}
}
public
void
GetTaskData()
{
string
sqlQuery =
"SELECT * FROM WAPTask WHERE WAPNo=@WAPNo And JobType=@JobType And JobTask=@JobTask And Status=1"
;
using
(SqlConnection conn =
new
SqlConnection(connString))
{
using
(SqlCommand cmd =
new
SqlCommand(sqlQuery, conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue(
"@WAPNo"
, tmpWAPNo.Text);
cmd.Parameters.AddWithValue(
"@JobType"
, txtJobType.Text);
cmd.Parameters.AddWithValue(
"@JobTask"
, ddlJobTask1.SelectedValue);
conn.Open();
using
(SqlDataReader rdr = cmd.ExecuteReader())
{
while
(rdr.Read())
{
txtIssuerBN1.Text = rdr[
"IssuerBN"
].ToString();
txtIssuerName1.Text = rdr[
"IssuerName"
].ToString();
txtReceiverCN1.Text = rdr[
"ReceiverCN"
].ToString();
txtReceiverName1.Text = rdr[
"ReceiverName"
].ToString();
}
}
}
}
}
}
}
Reply
Answers (
2
)
About that scenario (Many branches,many mangers)
How to download and install an application in toolbar