Hi lingers,
Refer below modified code.
SqlCommand cmd11 = new SqlCommand();
SqlCommand cmd1 = new SqlCommand();
SqlCommand cmd12 = new SqlCommand();
SqlConnection dbConn12 = new SqlConnection();
SqlConnection dbConn11 = new SqlConnection();
SqlConnection dbConn = new SqlConnection();
SqlConnection dbConn1 = new SqlConnection();
SqlConnection dbConn2 = new SqlConnection();
SqlDataReader dr, dr2, dr1, dr3, dr11, dr12;
string selectSQL, updateSQL, selectSQL1;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindUserDetails();
MainView.ActiveViewIndex = 0;
Tab1.CssClass = "Clicked";
}
}
protected void Tab1_Click(object sender, EventArgs e)
{
Tab1.CssClass = "Clicked";
Tab5.CssClass = "Initial";
Tab7.CssClass = "Initial";
MainView.ActiveViewIndex = 0;
gvDetails.UseAccessibleHeader = true;
gvDetails.HeaderRow.TableSection = TableRowSection.TableHeader;
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup()", true);
SqlConnection con = new SqlConnection("data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;");
SqlCommand cm = new SqlCommand();
cm.Connection = con;
con.Open();
cm.CommandType = CommandType.Text;
cm.CommandText = "SELECT pid FROM job WHERE id=@id";
cm.Parameters.AddWithValue("@id", Convert.ToInt32(Session["DatakeyValue"]));
Label1.Text = Convert.ToString(cm.ExecuteScalar());
con.Close();
selectSQL = " SELECT * FROM job where pid ='" + Label1.Text + "' ";
dbConn1.ConnectionString = "data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;";
cmd1.Connection = dbConn1;
cmd1.CommandText = selectSQL;
cmd1.CommandType = CommandType.Text;
try
{
dbConn1.Open();
dr1 = cmd1.ExecuteReader();
if (dr1.Read())
{
TextBox7.Text = dr1["pid"].ToString();
TextBox8.Text = dr1["description"].ToString();
TextBox9.Text = dr1["variant"].ToString();
TextBox10.Text = dr1["country"].ToString();
TextBox11.Text = dr1["pack"].ToString();
TextBox12.Text = dr1["customer"].ToString();
TextBox13.Text = dr1["jobnumber"].ToString();
TextBox14.Text = dr1["templateno"].ToString();
TextBox15.Text = dr1["artworkdate"].ToString();
TextBox16.Text = dr1["reprodate"].ToString();
TextBox17.Text = dr1["artworknumber"].ToString();
TextBox18.Text = dr1["nampak"].ToString();
TextBox19.Text = dr1["reproapproveddate"].ToString();
TextBox20.Text = dr1["artworkreceiveddate"].ToString();
TextBox21.Text = dr1["yields"].ToString();
TextBox22.Text = dr1["qtyaround"].ToString();
TextBox23.Text = dr1["qtyacross"].ToString();
TextBox24.Text = dr1["stretchdoublecut"].ToString();
TextBox25.Text = dr1["qtyperrevolution"].ToString();
TextBox26.Text = dr1["printtype"].ToString();
}
dr1.Close();
}
catch (Exception err)
{
Response.Write(err.ToString());
}
finally
{
dbConn1.Close();
}
}
protected void Tab5_Click(object sender, EventArgs e)
{
Tab1.CssClass = "Initial";
Tab5.CssClass = "Clicked";
Tab7.CssClass = "Initial";
MainView.ActiveViewIndex = 1;
gvDetails.UseAccessibleHeader = true;
gvDetails.HeaderRow.TableSection = TableRowSection.TableHeader;
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup()", true);
SqlConnection con = new SqlConnection("data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;");
SqlCommand cm = new SqlCommand();
cm.Connection = con;
con.Open();
cm.CommandType = CommandType.Text;
cm.CommandText = "SELECT pid FROM job WHERE id=@id";
cm.Parameters.AddWithValue("@id", Convert.ToInt32(Session["DatakeyValue"]));
Label1.Text = Convert.ToString(cm.ExecuteScalar());
con.Close();
string selectSQL11;
selectSQL11 = " SELECT * FROM job_emboss where ppid ='" + Label1.Text + "' ";
dbConn11.ConnectionString = "data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;";
cmd11.Connection = dbConn11;
cmd11.CommandText = selectSQL11;
cmd11.CommandType = CommandType.Text;
try
{
dbConn11.Open();
dr11 = cmd11.ExecuteReader();
if (dr11.Read())
{
TextBox393.Text = dr11["embid"].ToString();
TextBox394.Text = dr11["mandrel"].ToString();
TextBox395.Text = dr11["type"].ToString();
TextBox419.Text = dr11["circmale"].ToString();
TextBox396.Text = dr11["circfemale"].ToString();
TextBox397.Text = dr11["diameter"].ToString();
TextBox398.Text = dr11["supplier"].ToString();
TextBox399.Text = dr11["supplierno"].ToString();
TextBox400.Text = dr11["depth"].ToString();
TextBox420.Text = dr11["height"].ToString();
TextBox401.Text = dr11["artworknumber"].ToString();
TextBox402.Text = dr1["calyear"].ToString();
TextBox403.Text = dr1["month"].ToString();
TextBox404.Text = dr1["datereceived"].ToString();
TextBox405.Text = dr11["artworkdate"].ToString();
TextBox421.Text = dr11["country"].ToString();
TextBox402.Text = dr11["comment"].ToString();
}
dr11.Close();
}
catch (Exception err)
{
Response.Write(err.ToString());
}
finally
{
dbConn11.Close();
}
}
protected void Tab7_Click(object sender, EventArgs e)
{
Tab1.CssClass = "Initial";
Tab5.CssClass = "Initial";
Tab7.CssClass = "Clicked";
MainView.ActiveViewIndex = 2;
gvDetails.UseAccessibleHeader = true;
gvDetails.HeaderRow.TableSection = TableRowSection.TableHeader;
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup()", true);
SqlConnection con = new SqlConnection("data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;");
SqlCommand cm = new SqlCommand();
cm.Connection = con;
con.Open();
cm.CommandType = CommandType.Text;
cm.CommandText = "SELECT id FROM job WHERE id=@id";
cm.Parameters.AddWithValue("@id", Convert.ToInt32(Session["DatakeyValue"]));
Label1.Text = Convert.ToString(cm.ExecuteScalar());
con.Close();
string selectSQL12;
selectSQL12 = " SELECT * FROM job where id ='" + Label1.Text + "' ";
dbConn12.ConnectionString = "data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;";
cmd12.Connection = dbConn12;
cmd12.CommandText = selectSQL12;
cmd12.CommandType = CommandType.Text;
try
{
dbConn12.Open();
dr12 = cmd12.ExecuteReader();
if (dr12.Read())
{
// This columns are in the job table
TextBox445.Text = dr12["gietzdieref"].ToString();
TextBox446.Text = dr12["packingperpallet"].ToString();
TextBox447.Text = dr12["status"].ToString();
TextBox448.Text = dr12["cadgietzdie"].ToString();
TextBox449.Text = dr12["hotfoilcoverage"].ToString();
TextBox450.Text = dr12["blockspersheet"].ToString();
TextBox451.Text = dr12["blockspercarton"].ToString();
TextBox452.Text = dr12["foilarea"].ToString();
TextBox453.Text = dr12["foilsqm"].ToString();
TextBox454.Text = dr12["sheetlength"].ToString();
TextBox455.Text = dr12["sheetwidth"].ToString();
}
dr12.Close();
}
catch (Exception err)
{
Response.Write(err.ToString());
}
finally
{
dbConn12.Close();
}
}
protected void BindUserDetails()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlDataAdapter sda = new SqlDataAdapter(" SELECT CustomerId id, CustomerId pid, Name description, Name variant, country,Name pack, Name customer, CustomerId jobnumber, CustomerId artworkdate, CustomerId reprodate, CustomerId artworknumber, CustomerId templateno, CustomerId printtype FROM Customers ORDER BY CustomerId DESC", con))
{
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
gvDetails.DataSource = dt;
gvDetails.DataSource = dt;
gvDetails.DataBind();
}
}
}
//Required for jQuery DataTables to work.
gvDetails.UseAccessibleHeader = true;
gvDetails.HeaderRow.TableSection = TableRowSection.TableHeader;
}
//for get record
protected void Inkview_Click(object sender, EventArgs e)
{
int rowIndex = ((sender as Button).NamingContainer as GridViewRow).RowIndex;
int lbl1 = Convert.ToInt32(gvDetails.DataKeys[rowIndex].Values[0]);
Session["DatakeyValue"] = lbl1;
SqlConnection con = new SqlConnection("data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;");
SqlCommand cm = new SqlCommand();
cm.Connection = con;
con.Open();
cm.CommandType = CommandType.Text;
cm.CommandText = "SELECT pid FROM job WHERE id=@id";
cm.Parameters.AddWithValue("@id", Convert.ToInt32(Session["DatakeyValue"]));
Label1.Text = Convert.ToString(cm.ExecuteScalar());
con.Close();
MainView.ActiveViewIndex = 0;
Tab1.CssClass = "Clicked";
Tab5.CssClass = "Initial";
Tab7.CssClass = "Initial";
gvDetails.UseAccessibleHeader = true;
gvDetails.HeaderRow.TableSection = TableRowSection.TableHeader;
ScriptManager.RegisterStartupScript((sender as Control), this.GetType(), "Popup", "ShowPopup();", true);
selectSQL = " SELECT * FROM job where pid ='" + Label1.Text + "' ";
dbConn1.ConnectionString = "data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;";
cmd1.Connection = dbConn1;
cmd1.CommandText = selectSQL;
cmd1.CommandType = CommandType.Text;
try
{
dbConn1.Open();
dr1 = cmd1.ExecuteReader();
if (dr1.Read())
{
TextBox7.Text = dr1["pid"].ToString();
TextBox8.Text = dr1["description"].ToString();
TextBox9.Text = dr1["variant"].ToString();
TextBox10.Text = dr1["country"].ToString();
TextBox11.Text = dr1["pack"].ToString();
TextBox12.Text = dr1["customer"].ToString();
TextBox13.Text = dr1["jobnumber"].ToString();
TextBox14.Text = dr1["templateno"].ToString();
TextBox15.Text = dr1["artworkdate"].ToString();
TextBox16.Text = dr1["reprodate"].ToString();
TextBox17.Text = dr1["artworknumber"].ToString();
TextBox18.Text = dr1["nampak"].ToString();
TextBox19.Text = dr1["reproapproveddate"].ToString();
TextBox20.Text = dr1["artworkreceiveddate"].ToString();
TextBox21.Text = dr1["yields"].ToString();
TextBox22.Text = dr1["qtyaround"].ToString();
TextBox23.Text = dr1["qtyacross"].ToString();
TextBox24.Text = dr1["stretchdoublecut"].ToString();
TextBox25.Text = dr1["qtyperrevolution"].ToString();
TextBox26.Text = dr1["printtype"].ToString();
}
dr1.Close();
}
catch (Exception err)
{
Response.Write(err.ToString());
}
finally
{
dbConn1.Close();
}
}
protected void Inkview_Click1(object sender, EventArgs e)
{
}
protected void ImageButton3_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvrow in gvDetails.Rows)
{
//Finiding checkbox control in gridview for particular row
CheckBox chkdelete = (CheckBox)gvrow.FindControl("chkSelect");
//Condition to check checkbox selected or not
if (chkdelete.Checked)
{
//Getting UserId of particular row using datakey value
int usrid = Convert.ToInt32(gvDetails.DataKeys[gvrow.RowIndex].Value);
using (SqlConnection con = new SqlConnection("data source=PRESS\\EXPRESS01; Initial Catalog=Trial;Integrated Security=True;"))
{
con.Open();
SqlCommand cmd = new SqlCommand("delete from Job where id=" + usrid, con);
cmd.ExecuteNonQuery();
con.Close();
}
}
}
BindUserDetails();
}
protected void ImageButton1_Click(object sender, object e)
{
Response.Redirect("aaaaaa.aspx");
}