protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { DateTimeFormatInfo date = new DateTimeFormatInfo(); date.ShortDatePattern = "dd/MM/yyyy"; lbWritten.Visible = false; lbTechnical.Visible = false; lbHR.Visible = false; ITestStatusManager objTestStatusManager = TestStatusManagerFactory.Create_TestStatusManager(); Label lbcandidateID = (Label)gv.Rows[e.RowIndex].FindControl("lbCandidateID"); TextBox tb1 = (TextBox)gv.Rows[e.RowIndex].FindControl("tbWrittenTestDate"); int intcandidate = Convert.ToInt32(lbcandidateID.Text); TextBox tbTechnicalDate = (TextBox)gv.Rows[e.RowIndex].FindControl("tbTechnicalInterviewDate"); TextBox tb3 = (TextBox)gv.Rows[e.RowIndex].FindControl("tbHRInterviewDate"); Label lbWrittenStatus = (Label)gv.Rows[e.RowIndex].FindControl("lbWrittenTestStatus"); Label lbTechnicalStatus = (Label)gv.Rows[e.RowIndex].FindControl("lbTechnicalInterviewStatus"); Label lbHRStatus = (Label)gv.Rows[e.RowIndex].FindControl("lbHRInterviewStatus"); DateTime dtWritten, dtTechnical, dtHR; if (tb1.Text != "" && tbTechnicalDate.Text != "" && tb3.Text != "") { dtWritten = Convert.ToDateTime(tb1.Text, date); dtTechnical = Convert.ToDateTime(tbTechnicalDate.Text, date); dtHR = Convert.ToDateTime(tb3.Text, date); if (tb1.Text == tbTechnicalDate.Text || tbTechnicalDate.Text == tb3.Text || tb3.Text == tb1.Text) { string script2 = "alert('Test Dates cannot be same.');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } else if (dtWritten < dtTechnical && dtTechnical < dtHR) { if (lbHRStatus.Text == "pending") { bool st = objTestStatusManager.validateTest(Convert.ToInt32(ddlVacancyID.SelectedValue), Convert.ToInt32(lbcandidateID.Text), dtHR); if (st == false) { string script2 = "alert('Please check HR interview date.');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } else { if (compare(intcandidate, "HR") != dtHR) { lbHR.Visible = true; } objTestStatusManager.updatetest(Convert.ToInt32(ddlVacancyID.SelectedValue), Convert.ToInt32(lbcandidateID.Text), "HR", dtHR); if (lbTechnicalStatus.Text == "pending") { bool st1 = objTestStatusManager.validateTest(Convert.ToInt32(ddlVacancyID.SelectedItem.Text), Convert.ToInt32(lbcandidateID.Text), dtTechnical); if (st1 == false) { string script = "alert('Please check the Technical interview date');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true); } else { if (compare(intcandidate, "tech") != dtTechnical) { lbTechnical.Visible = true; } objTestStatusManager.updatetest(Convert.ToInt32(ddlVacancyID.SelectedItem.Text), Convert.ToInt32(lbcandidateID.Text), "technical", dtTechnical); if (lbWrittenStatus.Text == "pending") { bool st2 = objTestStatusManager.validateTest(Convert.ToInt32(ddlVacancyID.SelectedItem.Text), Convert.ToInt32(lbcandidateID.Text), dtWritten); if (st2 == false) { string script = "alert('Please check the written test date');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true); } else { if (compare(intcandidate, "written") != dtWritten) { lbWritten.Visible = true; } objTestStatusManager.updatetest(Convert.ToInt32(ddlVacancyID.SelectedItem.Text), Convert.ToInt32(lbcandidateID.Text), "written", dtWritten); } } else { string script5 = "alert('The written test status is cleared!');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script5, true); } } } else { string script6 = "alert('The technical Interview status is cleared !');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script6, true); } } } else { string script2 = "alert('The HR interview status is cleared !');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } } else { string script2 = "alert('Please check the entered dates');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } } else { string script2 = "alert('Please give valid details');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } gv.EditIndex = -1; showgrid(); } catch (Exception) { string script2 = "alert('Please give valid details');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } }
protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { DateTimeFormatInfo w = new DateTimeFormatInfo(); w.ShortDatePattern = "dd/MM/yyyy"; lbWritten.Visible = false; lbTechnical.Visible = false; lbHR.Visible = false; ITestStatusManager objTestStatusManager = TestStatusManagerFactory.Create_TestStatusManager(); Label l1 = (Label)gv.Rows[e.RowIndex].FindControl("CandidateID"); TextBox tb1 = (TextBox)gv.Rows[e.RowIndex].FindControl("WrittenTestDate"); int c = Convert.ToInt32(l1.Text); TextBox tb2 = (TextBox)gv.Rows[e.RowIndex].FindControl("TechnicalInterviewDate"); TextBox tb3 = (TextBox)gv.Rows[e.RowIndex].FindControl("HRInterviewDate"); Label l2 = (Label)gv.Rows[e.RowIndex].FindControl("WrittenTestStatus"); Label l3 = (Label)gv.Rows[e.RowIndex].FindControl("TechnicalInterviewStatus"); Label l4 = (Label)gv.Rows[e.RowIndex].FindControl("HRInterviewStatus"); DateTime written, tech, hr; if (tb1.Text != "" && tb2.Text != "" && tb3.Text != "") { written = Convert.ToDateTime(tb1.Text, w); tech = Convert.ToDateTime(tb2.Text, w); hr = Convert.ToDateTime(tb3.Text, w); if (tb1.Text == tb2.Text || tb2.Text == tb3.Text || tb3.Text == tb1.Text) { string script2 = "alert('No two test or interview dates can be same');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } else if (written < tech && tech < hr) { if (l4.Text == "pending") { bool st = objTestStatusManager.validateTest(Convert.ToInt32(ddlVacancyID.SelectedValue), Convert.ToInt32(l1.Text), hr); if (st == false) { string script2 = "alert('HR interview date cannot be rescheduled more than 3 days from the scheduled date.');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } else { if (compare(c, "HR") != hr) { lbHR.Visible = true; } objTestStatusManager.updatetest(Convert.ToInt32(ddlVacancyID.SelectedValue), Convert.ToInt32(l1.Text), "HR", hr); if (l3.Text == "pending") { bool st1 = objTestStatusManager.validateTest(Convert.ToInt32(ddlVacancyID.SelectedItem.Text), Convert.ToInt32(l1.Text), tech); if (st1 == false) { string script = "alert('Technical interview date cannot be rescheduled more than 3 days from the scheduled date.');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true); } else { if (compare(c, "tech") != tech) { lbTechnical.Visible = true; } objTestStatusManager.updatetest(Convert.ToInt32(ddlVacancyID.SelectedItem.Text), Convert.ToInt32(l1.Text), "technical", tech); if (l2.Text == "pending") { bool st2 = objTestStatusManager.validateTest(Convert.ToInt32(ddlVacancyID.SelectedItem.Text), Convert.ToInt32(l1.Text), written); if (st2 == false) { string script = "alert(' Written test date cannot be rescheduled more than 3 days from the scheduled date.');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true); } else { if (compare(c, "written") != written) { lbWritten.Visible = true; } objTestStatusManager.updatetest(Convert.ToInt32(ddlVacancyID.SelectedItem.Text), Convert.ToInt32(l1.Text), "written", written); } } else { string script5 = "alert('The written test status is cleared for candidate with id: '" + l1.Text + ".');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script5, true); } } } else { string script6 = "alert('The technical Interview status is cleared for candidate with id: '" + l1.Text + ".');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script6, true); } } } else { string script2 = "alert('The HR interview status is cleared for the candidate with id: '" + l1.Text + ".');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } } else { string script2 = "alert('Please check the entered dates');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } } else { string script2 = "alert('Please enter the valid dates');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } gv.EditIndex = -1; showgrid(); } catch (Exception) { string script2 = "alert('Please enter the valid dates');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script2, true); } }