protected void btnAdd_Click(object sender, EventArgs e) { List <ATTEmployeeMedicalExp> EmpMedExpList = (List <ATTEmployeeMedicalExp>)Session["EmpMedExpList"]; string strAction = ""; double empID = double.Parse(this.txtEmpID.Text.Trim()); int seqNo = 0; if (this.grdMedicalExp.SelectedIndex > -1) { seqNo = int.Parse(this.grdMedicalExp.Rows[this.grdMedicalExp.SelectedIndex].Cells[1].Text); strAction = "E"; } else { strAction = "A"; } List <ATTEmployeeMedicalExp> lst = new List <ATTEmployeeMedicalExp>(); try { ATTEmployeeMedicalExp obj = new ATTEmployeeMedicalExp(empID, seqNo, this.txtParticulars_Rqd.Text.Trim(), this.txtDateTaken_RDT.Text.Trim(), double.Parse(this.txtAmountTaken_Rqd.Text.Trim())); obj.EntryBy = Session["UserName"].ToString(); obj.Action = strAction; lst.Add(obj); BLLEmployeeMedicalExp.SaveEmployeeMedicalExp(lst); if (this.grdMedicalExp.SelectedIndex <= -1) { EmpMedExpList.Add(obj); } else { EmpMedExpList[this.grdMedicalExp.SelectedIndex] = obj; } this.grdMedicalExp.DataSource = EmpMedExpList; this.grdMedicalExp.DataBind(); if (this.grdMedicalExp.SelectedIndex <= -1) { this.lblStatusMessage.Text = "Employee Medical Expenses Successfully Saved."; } else { this.lblStatusMessage.Text = "Employee Medical Expenses Successfully Modified."; } this.programmaticModalPopup.Show(); this.grdMedicalExp.SelectedIndex = -1; this.txtParticulars_Rqd.Text = ""; this.txtDateTaken_RDT.Text = ""; this.txtAmountTaken_Rqd.Text = ""; } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }
protected void btnAdd_Click(object sender, EventArgs e) { string msg = ""; int count = 0; if (this.txtEmpName_Rqd.Text.Trim() == "") { msg += "**र्कपया कर्मचारी छान्नुहोस्</br>"; count++; } if (this.txtParticulars_Rqd.Text.Trim() == "") { msg += "**र्कपया विवरण भर्नुहोस्</br>"; count++; } if (this.txtDateTaken_RDT.Text.Trim() == "") { msg += "**र्कपया लिएको मिति भर्नुहोस्</br>"; count++; } if (this.txtAmountTaken_Rqd.Text.Trim() == "") { msg += "**र्कपया रकम भर्नुहोस्</br>"; count++; } if (count > 0) { this.lblStatusMessage.Text = msg; this.programmaticModalPopup.Show(); return; } foreach (GridViewRow row in this.grdMedicalExp.Rows) { if (int.Parse(row.Cells[0].Text) == int.Parse(this.txtEmpID.Text) && row.Cells[2].Text == this.txtParticulars_Rqd.Text && row.Cells[3].Text == this.txtDateTaken_RDT.Text && int.Parse(row.Cells[4].Text) == int.Parse(this.txtAmountTaken_Rqd.Text)) { this.lblStatusMessage.Text = "औषधि खर्चको विवरण पहिले नै उपलब्द छ"; this.programmaticModalPopup.Show(); return; } } List <ATTEmployeeMedicalExp> EmpMedExpList = (List <ATTEmployeeMedicalExp>)Session["EmpMedExpList"]; string strAction = ""; double empID = double.Parse(this.txtEmpID.Text.Trim()); int seqNo = 0; if (this.grdMedicalExp.SelectedIndex > -1) { seqNo = int.Parse(this.grdMedicalExp.Rows[this.grdMedicalExp.SelectedIndex].Cells[1].Text); strAction = "E"; } else { strAction = "A"; } List <ATTEmployeeMedicalExp> lst = new List <ATTEmployeeMedicalExp>(); try { ATTEmployeeMedicalExp obj = new ATTEmployeeMedicalExp(empID, seqNo, this.txtParticulars_Rqd.Text.Trim(), this.txtDateTaken_RDT.Text.Trim(), double.Parse(this.txtAmountTaken_Rqd.Text.Trim())); obj.EntryBy = Session["UserName"].ToString(); obj.Action = strAction; lst.Add(obj); BLLEmployeeMedicalExp.SaveEmployeeMedicalExp(lst); if (this.grdMedicalExp.SelectedIndex <= -1) { EmpMedExpList.Add(obj); } else { EmpMedExpList[this.grdMedicalExp.SelectedIndex] = obj; } this.grdMedicalExp.DataSource = EmpMedExpList; this.grdMedicalExp.DataBind(); if (this.grdMedicalExp.SelectedIndex <= -1) { this.lblStatusMessage.Text = "Employee Medical Expenses Saved Successfully."; } else { this.lblStatusMessage.Text = "Employee Medical Expenses Modified Successfully."; } this.programmaticModalPopup.Show(); this.grdMedicalExp.SelectedIndex = -1; this.txtParticulars_Rqd.Text = ""; this.txtDateTaken_RDT.Text = ""; this.txtAmountTaken_Rqd.Text = ""; this.grdEmployee.SelectedIndex = -1; this.txtParticulars_Rqd.Focus(); } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }