protected void btn_Update_Click(object sender, EventArgs e) { try { int i; int j = 0; for (i = 0; i <= RG_SalaryStruct.Items.Count - 1; i++) { Label lblCalMode = new Label(); TextBox txtgetVal = new TextBox(); CheckBox chkBox = new CheckBox(); txtgetVal = RG_SalaryStruct.Items[i].FindControl("txtNumber") as TextBox; lblCalMode = RG_SalaryStruct.Items[i].FindControl("lblCALMODE") as Label; chkBox = RG_SalaryStruct.Items[i].FindControl("chk_Select") as CheckBox; if (Convert.ToString(txtgetVal.Text) != "") { if (Convert.ToString(lblCalMode.Text).ToUpper() == "%AGE") { if (Convert.ToDouble(txtgetVal.Text) > 100) { BLL.ShowMessage(this, "Percentage Value should not exceed 100%"); return; } } if (chkBox.Checked == false) { BLL.ShowMessage(this, "Please Select the Element at Salary Structure"); return; } } else { j = j + 1; } } if (j == RG_SalaryStruct.Items.Count) { BLL.ShowMessage(this, "Please Enter Atleast one Value(s)"); return; } bool status = false; _obj_smhr_salaryStruct.OPERATION = operation.Check; _obj_smhr_salaryStruct.SALARYSTRUCT_CODE = Convert.ToString(txt_SalCode.Text); _obj_smhr_salaryStruct.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); dt_Det = BLL.get_SalaryHeaderDetails(_obj_smhr_salaryStruct); if (dt_Det.Rows.Count != 0) { _sal_struct_ID = Convert.ToString(dt_Det.Rows[0]["SALARYSTRUCT_ID"]); _obj_smhr_salaryStruct.SALARYSTRUCT_ID = Convert.ToInt32(_sal_struct_ID); _obj_smhr_salaryStruct.SALARYSTRUCT_NAME = Convert.ToString(txt_SalName.Text.Replace("'", "''")); _obj_smhr_salaryStruct.SALARYSTRUCT_STARTDATE = Convert.ToDateTime(txt_StartDate.SelectedDate); if (txt_EndDate.SelectedDate.HasValue) { _obj_smhr_salaryStruct.SALARYSTRUCT_ENDDATE = Convert.ToDateTime(txt_EndDate.SelectedDate); } else { _obj_smhr_salaryStruct.SALARYSTRUCT_ENDDATE = null; } _obj_smhr_salaryStruct.SALARYSTRUCT_TYPE = Convert.ToInt32(rcb_Type.SelectedItem.Value); _obj_smhr_salaryStruct.SALARYSTRUCT_ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); _obj_smhr_salaryStruct.SALARYSTRUCT_LASTMDFBY = Convert.ToInt32(Session["USER_ID"]); _obj_smhr_salaryStruct.SALARYSTRUCT_LASTMDFDATE = DateTime.Now; _obj_smhr_salaryStruct.OPERATION = operation.Update; status = BLL.set_SalaryHeaderDetails(_obj_smhr_salaryStruct); if (status == true) { //_obj_smhr_salaryStruct.OPERATION = operation.getEmp; _obj_smhr_salaryStruct.OPERATION = operation.GET; _obj_smhr_salaryStruct.SALARYSTRUCTDET_SALSTR_ID = Convert.ToInt32(_sal_struct_ID); DataTable dt = BLL.get_Saldata(_obj_smhr_salaryStruct); //oldIDs = string.Empty; //if (dt.Rows.Count > 0) //{ // for (int p = 0; p < dt.Rows.Count; p++) // oldIDs = oldIDs + Convert.ToString(dt.Rows[p]["SALARYSTRUCTDET_ID"]) + ","; // if (oldIDs != string.Empty) // oldIDs = oldIDs.Remove(oldIDs.Length - 1); //} //_obj_smhr_salaryStruct.OPERATION = operation.Delete; //_obj_smhr_salaryStruct.SALARYSTRUCT_ID = Convert.ToInt32(_sal_struct_ID); //status = BLL.set_SalaryDetails(_obj_smhr_salaryStruct); //if (status == true) //{ int index; newIDs = string.Empty; for (index = 0; index <= RG_SalaryStruct.Items.Count - 1; index++) { Label lblCode = new Label(); // Pay item Code Label lblMode = new Label(); // Pay item Mode Label lblSalary = new Label(); TextBox txtVal = new TextBox(); // Salary Structure Entered Value Label lblformula = new Label(); //Salary Structure Entered Formula CheckBox chkBox = new CheckBox(); // Check Box lblCode = RG_SalaryStruct.Items[index].FindControl("lblPAYITEM_ID") as Label; lblSalary = RG_SalaryStruct.Items[index].FindControl("lblSSDetID") as Label; lblMode = RG_SalaryStruct.Items[index].FindControl("lblCALMODE") as Label; txtVal = RG_SalaryStruct.Items[index].FindControl("txtNumber") as TextBox; lblformula = RG_SalaryStruct.Items[index].FindControl("lblformula") as Label; chkBox = RG_SalaryStruct.Items[index].FindControl("chk_Select") as CheckBox; if (Convert.ToString(txtVal.Text) != "") { if (chkBox.Checked) { _obj_smhr_salaryStruct.SALARYSTRUCT_ID = Convert.ToInt32(_sal_struct_ID); _obj_smhr_salaryStruct.SALARYSTRUCTDET_PAYITEM_ID = Convert.ToInt32(lblCode.Text); _obj_smhr_salaryStruct.SALARYSTRUCTDET_PAYMODE = Convert.ToString(lblMode.Text); _obj_smhr_salaryStruct.SALARYSTRUCTDET_PAYVALUE = Convert.ToString(txtVal.Text); _obj_smhr_salaryStruct.SALARYSTRUCTDET_FORMULA = ""; _obj_smhr_salaryStruct.SALARYSTRUCTDET_CHECKED = true; _obj_smhr_salaryStruct.OPERATION = operation.Insert_New; _obj_smhr_salaryStruct.SALARYSTRUCT_CREATEDBY = Convert.ToInt32(Session["USER_ID"]); _obj_smhr_salaryStruct.SALARYSTRUCT_CREATEDDATE = DateTime.Now; _obj_smhr_salaryStruct.SALARYSTRUCTDET_ID = Convert.ToInt32(lblSalary.Text); status = BLL.set_SalaryDetails(_obj_smhr_salaryStruct); if ((lblSalary.Text != string.Empty) && (lblSalary.Text != "-1")) { newIDs = newIDs + lblSalary.Text + ","; } } } } if (newIDs != string.Empty) { newIDs = newIDs.Remove(newIDs.Length - 1); } _obj_smhr_salaryStruct.OPERATION = operation.Delete1; _obj_smhr_salaryStruct.SDATE = newIDs; //for new IDs _obj_smhr_salaryStruct.EDATE = oldIDs; //for old IDs _obj_smhr_salaryStruct.SALARYSTRUCT_ID = Convert.ToInt32(_sal_struct_ID); _obj_smhr_salaryStruct.SALARYSTRUCT_CREATEDBY = Convert.ToInt32(Session["USER_ID"]); status = BLL.set_SalaryDetails(_obj_smhr_salaryStruct); //} BLL.ShowMessage(this, "Record Updated Successfully"); RMP_SalaryStruct.SelectedIndex = 0; LoadMainGrid(); RG_Salary.DataBind(); if (chk_Updateall.Checked)//updating these payitems for all employees who are under that salary structure { _obj_smhr_salaryStruct.SALARYSTRUCT_ID = Convert.ToInt32(_sal_struct_ID); _obj_smhr_salaryStruct.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); _obj_smhr_salaryStruct.OPERATION = operation.New;//For Dumping Each Pay Item To Employee Who Belongs To That Salary Structure status = BLL.set_SalaryDetails(_obj_smhr_salaryStruct); } clearItems(); return; } else { BLL.ShowMessage(this, "Error Occured While Doing the Process"); return; } } } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_SalaryStructure", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }
protected void btn_Save_Click(object sender, EventArgs e) { try { string Code = ""; int i; int j = 0; for (i = 0; i <= RG_SalaryStruct.Items.Count - 1; i++) { Label lblCalMode = new Label(); TextBox txtgetVal = new TextBox(); CheckBox chkBox = new CheckBox(); txtgetVal = RG_SalaryStruct.Items[i].FindControl("txtNumber") as TextBox; lblCalMode = RG_SalaryStruct.Items[i].FindControl("lblCALMODE") as Label; chkBox = RG_SalaryStruct.Items[i].FindControl("chk_Select") as CheckBox; if (Convert.ToString(txtgetVal.Text) != "") { if (Convert.ToString(lblCalMode.Text).ToUpper() == "%AGE") { if (Convert.ToDouble(txtgetVal.Text) > 100) { BLL.ShowMessage(this, "Percentage Value should not exceed 100%"); return; } } if (chkBox.Checked == false) { BLL.ShowMessage(this, "Please Select the Element at Salary Structure"); return; } } else { j = j + 1; } } if (j == RG_SalaryStruct.Items.Count) { BLL.ShowMessage(this, "Please Enter Atleast one Value(s)"); return; } _obj_smhr_salaryStruct = new SMHR_SALARYSTRUCT(); _obj_smhr_salaryStruct.SALARYSTRUCT_CODE = Convert.ToString(txt_SalCode.Text).Replace("'", "''"); _obj_smhr_salaryStruct.OPERATION = operation.Check; _obj_smhr_salaryStruct.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); DataTable dt = BLL.get_SalaryHeaderDetails(_obj_smhr_salaryStruct); if (dt.Rows.Count != 0) { BLL.ShowMessage(this, "Name Entered is already used"); return; } Code = Convert.ToString(txt_SalCode.Text).Replace("'", "''"); bool status = false; _obj_smhr_salaryStruct.SALARYSTRUCT_CODE = Convert.ToString(txt_SalCode.Text).Replace("'", "''"); _obj_smhr_salaryStruct.SALARYSTRUCT_NAME = Convert.ToString(txt_SalName.Text.Replace("'", "''")); _obj_smhr_salaryStruct.SALARYSTRUCT_STARTDATE = Convert.ToDateTime(txt_StartDate.SelectedDate); if (txt_EndDate.SelectedDate.HasValue) { _obj_smhr_salaryStruct.SALARYSTRUCT_ENDDATE = Convert.ToDateTime(txt_EndDate.SelectedDate); } else { _obj_smhr_salaryStruct.SALARYSTRUCT_ENDDATE = null; } _obj_smhr_salaryStruct.SALARYSTRUCT_TYPE = Convert.ToInt32(rcb_Type.SelectedItem.Value); _obj_smhr_salaryStruct.SALARYSTRUCT_ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); _obj_smhr_salaryStruct.SALARYSTRUCT_CREATEDBY = Convert.ToInt32(Session["USER_ID"]); _obj_smhr_salaryStruct.SALARYSTRUCT_CREATEDDATE = DateTime.Now; _obj_smhr_salaryStruct.OPERATION = operation.Insert; status = BLL.set_SalaryHeaderDetails(_obj_smhr_salaryStruct); if (status == true) { int index; _obj_smhr_salaryStruct.OPERATION = operation.Check; _obj_smhr_salaryStruct.SALARYSTRUCT_CODE = Convert.ToString(Code); _obj_smhr_salaryStruct.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); dt_Det = BLL.get_SalaryHeaderDetails(_obj_smhr_salaryStruct); if (dt_Det.Rows.Count != 0) { _sal_struct_ID = Convert.ToString(dt_Det.Rows[0][0]); } for (index = 0; index <= RG_SalaryStruct.Items.Count - 1; index++) { Label lblCode = new Label(); // Pay item Code Label lblMode = new Label(); // Pay item Mode TextBox txtVal = new TextBox(); // Salary Structure Entered Value Label lblformula = new Label(); //Salary Structure Entered Formula CheckBox chkBox = new CheckBox(); // Check Box lblCode = RG_SalaryStruct.Items[index].FindControl("lblPAYITEM_ID") as Label; lblMode = RG_SalaryStruct.Items[index].FindControl("lblCALMODE") as Label; txtVal = RG_SalaryStruct.Items[index].FindControl("txtNumber") as TextBox; lblformula = RG_SalaryStruct.Items[index].FindControl("lblformula") as Label; chkBox = RG_SalaryStruct.Items[index].FindControl("chk_Select") as CheckBox; if (Convert.ToString(txtVal.Text) != "") { if (chkBox.Checked) { _obj_smhr_salaryStruct.SALARYSTRUCT_ID = Convert.ToInt32(_sal_struct_ID); _obj_smhr_salaryStruct.SALARYSTRUCTDET_PAYITEM_ID = Convert.ToInt32(lblCode.Text); _obj_smhr_salaryStruct.SALARYSTRUCTDET_PAYMODE = Convert.ToString(lblMode.Text); _obj_smhr_salaryStruct.SALARYSTRUCTDET_PAYVALUE = Convert.ToString(txtVal.Text); _obj_smhr_salaryStruct.SALARYSTRUCTDET_FORMULA = ""; _obj_smhr_salaryStruct.SALARYSTRUCTDET_CHECKED = true; _obj_smhr_salaryStruct.SALARYSTRUCT_CREATEDBY = Convert.ToInt32(Session["USER_ID"]); _obj_smhr_salaryStruct.SALARYSTRUCT_CREATEDDATE = DateTime.Now; _obj_smhr_salaryStruct.OPERATION = operation.Insert; status = BLL.set_SalaryDetails(_obj_smhr_salaryStruct); } } } BLL.ShowMessage(this, "Record Saved Successfully"); RMP_SalaryStruct.SelectedIndex = 0; LoadMainGrid(); RG_Salary.DataBind(); clearItems(); return; } else { BLL.ShowMessage(this, "Error Occured While Doing the Process"); return; } } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_SalaryStructure", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }