public static List <ATTJudgeWorkInspectionDetails> GetJudgeWorkInspectionDetails(int?empId, string fiscalYear) { List <ATTJudgeWorkInspectionDetails> LstJudgeWorkInspectionDetails = new List <ATTJudgeWorkInspectionDetails>(); try { foreach (DataRow row in DLLJudgeWorkInspectionDetails.GetJudgeWorkInspectionDetails(empId, fiscalYear).Rows) { ATTJudgeWorkInspectionDetails ObjJudgeWorkInspectionDetails = new ATTJudgeWorkInspectionDetails(); ObjJudgeWorkInspectionDetails.EmployeeID = int.Parse(row["EMP_ID"].ToString()); ObjJudgeWorkInspectionDetails.FiscalYear = row["FISCAL_YEAR"].ToString(); ObjJudgeWorkInspectionDetails.JwcID = int.Parse(row["JWC_ID"].ToString()); ObjJudgeWorkInspectionDetails.WorkDone = (row["WORKDONE"].ToString() == "Y") ? true : false; ObjJudgeWorkInspectionDetails.NoOfCase = (row["NOOFCASE"].ToString() == "" ? 0 : int.Parse(row["NOOFCASE"].ToString())); ObjJudgeWorkInspectionDetails.NoDoneReason = (row["NODONE_REASON"] == DBNull.Value) ? "" : row["NODONE_REASON"].ToString(); ObjJudgeWorkInspectionDetails.IsReasonValid = (row["ISREASONVAILID"].ToString() == "Y") ? true : false; ObjJudgeWorkInspectionDetails.Remarks = (row["REMARKS"] == DBNull.Value) ? "" : row["REMARKS"].ToString(); ObjJudgeWorkInspectionDetails.InspectionCaseNo = (row["INSP_CASENO"].ToString() == "" ? 0 : int.Parse(row["INSP_CASENO"].ToString())); //ObjJudgeWorkInspectionDetails.Action = ""; ObjJudgeWorkInspectionDetails.EntryBy = ""; ObjJudgeWorkInspectionDetails.JwcName = row["JWC_NAME"].ToString(); LstJudgeWorkInspectionDetails.Add(ObjJudgeWorkInspectionDetails); } return(LstJudgeWorkInspectionDetails); } catch (Exception ex) { throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { try { if (grdWorkInspectionDetails.Rows.Count < 1) { return; } int i = 0; string errmessage = "<P><b><U>! Attention </U></b></P>"; if (ddlJudgeList.SelectedIndex < 1) { i++; errmessage += i.ToString() + ") Select Judge <br />"; } if (!txtInspection.HasAttributes || txtInspection.Text == "") { i++; errmessage += i.ToString() + ") Inspector Missing <br />"; } if (txtInspectionDate.Text == "") { i++; errmessage += i.ToString() + ") Inspection Date Missing <br />"; } else { try { DateTime dt = DateTime.Parse(txtInspectionDate.Text); } catch (Exception) { i++; errmessage += i.ToString() + ") Invalid Date <br />"; } } if (i > 0) { this.lblStatusMessage.Text = errmessage; this.programmaticModalPopup.Show(); return; } InspectionListInsert = new List <ATTJudgeWorkInspectionDetails>(); int j = 0; foreach (ATTJudgeWorkList work in (List <ATTJudgeWorkList>)Session["WorkList"]) { if (j > 0) { ATTJudgeWorkInspectionDetails inspdet = new ATTJudgeWorkInspectionDetails(); inspdet.JwcID = int.Parse(work.JwcID.ToString()); inspdet.JwcName = work.JwcName; inspdet.Action = (Session["AddEdit"].ToString() == "A" ? "A" : ""); inspdet.EmployeeID = int.Parse(ddlJudgeList.SelectedValue); inspdet.EntryBy = entryBy; inspdet.EntryOn = DateTime.Now; inspdet.FiscalYear = txtFiscalYear.Text; inspdet.InspectionCaseNo = null; inspdet.IsReasonValid = null; inspdet.NoDoneReason = ""; inspdet.NoOfCase = null; inspdet.Remarks = ""; inspdet.WorkDone = false; InspectionListInsert.Add(inspdet); } j++; } foreach (ATTJudgeWorkInspectionDetails inspDetails in (List <ATTJudgeWorkInspectionDetails>)Session["WorkDetailsLst"]) { int k = InspectionListInsert.FindIndex(delegate(ATTJudgeWorkInspectionDetails detail) { return(detail.JwcID == inspDetails.JwcID); }); InspectionListInsert[k] = inspDetails; } ATTJudgeWorkInspection workInspection = new ATTJudgeWorkInspection(); workInspection.EmployeeID = int.Parse(ddlJudgeList.SelectedValue); workInspection.FiscalYear = txtFiscalYear.Text; string st = txtInspection.Attributes["InspectorID"].ToString(); workInspection.InspEmpID = int.Parse(txtInspection.Attributes["InspectorID"].ToString()); workInspection.InspectionDate = DateTime.Parse(txtInspectionDate.Text); workInspection.EntryBy = entryBy; workInspection.Details = InspectionListInsert; workInspection.Action = Session["AddEdit"].ToString(); if (BLLJudgeWorkInspection.SaveJudgeWorkInspection(workInspection)) { ClearControls(true); btnSave.Visible = true; btnCancel.Visible = true; this.lblStatusMessage.Text = "Information Saved."; this.programmaticModalPopup.Show(); } else { this.lblStatusMessage.Text = "Problem Saving Information ."; this.programmaticModalPopup.Show(); } } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message.ToString(); this.programmaticModalPopup.Show(); } }
protected void btnAdd_Click(object sender, EventArgs e) { try { int i = 0; string errmessage = "<P><b><U>! Attention </U></b></P>"; if (ddlJudgeList.SelectedIndex < 1) { i++; errmessage += i.ToString() + ") Select Judge <br />"; } if (ddlWorkList.SelectedIndex < 1) { i++; errmessage += i.ToString() + ") Work Missing <br />"; } if (!chkDone.Checked) { if (txtNoOfCases.Text == "") { i++; errmessage += i.ToString() + ") No Of Cases Missing <br />"; } } if (txtInspectionCaseNo.Text == "") { i++; errmessage += i.ToString() + ") Inspection Case No Missing <br />"; } if (txtremarks.Text == "") { i++; errmessage += i.ToString() + ") Remarks Missing <br />"; } if (i > 0) { this.lblStatusMessage.Text = errmessage; this.programmaticModalPopup.Show(); return; } List <ATTJudgeWorkInspectionDetails> WorkDetailsLst = (List <ATTJudgeWorkInspectionDetails>)Session["WorkDetailsLst"]; if (grdWorkInspectionDetails.SelectedIndex >= 0) { WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].EmployeeID = int.Parse(ddlJudgeList.SelectedValue); WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].FiscalYear = txtFiscalYear.Text; WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].JwcID = int.Parse(ddlWorkList.SelectedValue); WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].JwcName = ddlWorkList.SelectedItem.ToString(); WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].WorkDone = chkDone.Checked; WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].NoOfCase = (!chkDone.Checked) ? int.Parse(txtNoOfCases.Text) : 0; WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].InspectionCaseNo = int.Parse(txtInspectionCaseNo.Text); WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].NoDoneReason = Server.HtmlDecode(txtNoDoneReason.Text); WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].IsReasonValid = chkIsReasonValid.Checked; WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].Remarks = txtremarks.Text; string action = ""; string actionAll = Session["AddEdit"].ToString(); if (actionAll == "A") { action = "A"; } else if (actionAll == "E") { action = (WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].Action == "") ? "E" : "EA"; } WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].Action = ""; WorkDetailsLst[grdWorkInspectionDetails.SelectedIndex].EntryBy = entryBy; } else { if (WorkDetailsLst == null) { WorkDetailsLst = new List <ATTJudgeWorkInspectionDetails>(); } if (WorkDetailsLst.Count > 0) { foreach (ATTJudgeWorkInspectionDetails work in WorkDetailsLst) { if (work.JwcID == int.Parse(ddlWorkList.SelectedValue)) { i++; this.lblStatusMessage.Text = errmessage + i.ToString() + ") This Work Already Exists. Please Try Another."; this.programmaticModalPopup.Show(); return; } } } ATTJudgeWorkInspectionDetails obj = new ATTJudgeWorkInspectionDetails(); obj.EmployeeID = int.Parse(ddlJudgeList.SelectedValue); obj.FiscalYear = txtFiscalYear.Text; obj.JwcID = int.Parse(ddlWorkList.SelectedValue); obj.JwcName = ddlWorkList.SelectedItem.ToString(); obj.WorkDone = chkDone.Checked; obj.NoOfCase = (!chkDone.Checked) ? int.Parse(txtNoOfCases.Text) : 0; obj.InspectionCaseNo = int.Parse(txtInspectionCaseNo.Text); obj.NoDoneReason = txtNoDoneReason.Text; obj.IsReasonValid = chkIsReasonValid.Checked; obj.Remarks = txtremarks.Text; string action = ""; string actionAll = Session["AddEdit"].ToString(); if (actionAll == "A") { action = "A"; } else if (actionAll == "E") { action = "EA"; } obj.Action = action; obj.EntryBy = entryBy; WorkDetailsLst.Add(obj); } Session["WorkDetailsLst"] = WorkDetailsLst; grdWorkInspectionDetails.DataSource = null; grdWorkInspectionDetails.DataBind(); grdWorkInspectionDetails.DataSource = WorkDetailsLst; grdWorkInspectionDetails.DataBind(); grdWorkInspectionDetails.SelectedIndex = -1; ClearControls(false); btnSave.Visible = true; btnCancel.Visible = true; } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message.ToString(); this.programmaticModalPopup.Show(); } }