protected void btn_submit_Click(object sender, EventArgs e) { try { if (rcmb_BusinessUnit.SelectedIndex <= 0) { BLL.ShowMessage(this, "Please Select Business Unit"); return; } else if (rcmb_SalaryStructure.SelectedIndex <= 0) { BLL.ShowMessage(this, "please select Salary structure"); } string errorMsg = string.Empty; DataTable dtGetVoteCode = GetVoteCode(out errorMsg); if (!string.IsNullOrEmpty(errorMsg)) { BLL.ShowMessage(this, errorMsg); return; } SMHR_VOTECODEENTRY VOTECODE = new SMHR_VOTECODEENTRY(); VOTECODE.VOTECODE_GRIDDATA = dtGetVoteCode; VOTECODE.VOTECODE_ORG_ID = Convert.ToInt32(Session["ORG_ID"]); VOTECODE.VOTECODE_BU_ID = Convert.ToInt32(rcmb_BusinessUnit.SelectedValue); VOTECODE.VOTECODE_SALSTRUCT_ID = Convert.ToInt32(rcmb_SalaryStructure.SelectedValue); VOTECODE.VOTECODE_CREATEDBY = Convert.ToInt32(Session["USER_ID"]); VOTECODE.VOTECODE_CREATEDDATE = DateTime.Now; VOTECODE.VOTECODE_LASTMDFBY = Convert.ToInt32(Session["USER_ID"]); VOTECODE.VOTECODE_LASTMDFDATE = DateTime.Now; switch (((Button)sender).Text.ToUpper()) { case "SAVE": VOTECODE.OPERATION = operation.Insert; if (BLL.Set_VoteCodeEntry(VOTECODE)) { BLL.ShowMessage(this, "Information Saved Successfully"); } else { BLL.ShowMessage(this, "Information Not Saved"); } break; default: break; } rcmb_SalaryStructure.ClearSelection(); rcmb_SalaryStructure.Text = string.Empty; rcmb_BusinessUnit.ClearSelection(); rcmb_BusinessUnit.Text = string.Empty; RG_VoteCodeEntry.Visible = false; btn_submit.Visible = false; btn_Cancel.Visible = false; } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "VoteCodeEntry", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }
private DataTable GetVoteCode(out string errorMsg) { errorMsg = string.Empty; DataTable dt = GetGridDataTable(); try { RadTextBox txtVoteName, txtVoteCode; SMHR_VOTECODEENTRY votecodeentry = new SMHR_VOTECODEENTRY(); votecodeentry.OPERATION = operation.Select; votecodeentry.VOTECODE_ORG_ID = Convert.ToInt32(Session["ORG_ID"]); DataTable dtVoteCode = BLL.Get_VoteCodeEntry(votecodeentry); foreach (GridDataItem d in RG_VoteCodeEntry.Items) { txtVoteName = new RadTextBox(); txtVoteName = d.FindControl("txtVoteName") as RadTextBox; txtVoteCode = new RadTextBox(); txtVoteCode = d.FindControl("txtVoteCode") as RadTextBox; //if (dtVoteCode.Rows.Count > 0 && !string.IsNullOrEmpty(txtVoteCode.Text)) //{ // //&& v.Field<int>("VOTECODE_BU_ID") == Convert.ToInt32(rcmb_BusinessUnit.SelectedItem.Value) // DataRow[] dts = dtVoteCode.AsEnumerable().Where(v => v.Field<string>("VOTECODE_CODE") == txtVoteCode.Text && v.Field<int>("VOTECODE_BU_ID") == Convert.ToInt32(rcmb_SalaryStructure.SelectedItem.Value)).ToArray(); // if(dts.Count()>0) // { // foreach(DataRow dr in dts) // { // //if (dr["VOTECODE_PAYITEM_ID"].ToString() != d.Cells[2].Text || dr["VOTECODE_BU_ID"].ToString() != rcmb_BusinessUnit.SelectedItem.Value) // { // errorMsg = "Vote Code " + txtVoteCode.Text + " already exists."; // return null; // } // } // } // //DataRow[] dtcurrent = dt.AsEnumerable().Where(v => v.Field<string>("VOTECODE_CODE") == txtVoteCode.Text).ToArray(); // //if (dtcurrent.Count() > 0) // //{ // // errorMsg = "Vote Code " + txtVoteCode.Text + " already exists."; // // return null; // //} //} dt.Rows.Add(Convert.ToInt32(Session["ORG_ID"]), Convert.ToInt32(rcmb_BusinessUnit.SelectedValue), Convert.ToInt32(rcmb_SalaryStructure.SelectedValue), Convert.ToInt32(d.Cells[2].Text), txtVoteCode.Text, txtVoteName.Text); } } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "VoteCodeEntry", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } return(dt); }
protected void rcmb_SalaryStructure_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) { try { if (rcmb_SalaryStructure.SelectedIndex > 0) { if (rcmb_BusinessUnit.SelectedIndex > 0) { RG_VoteCodeEntry.Visible = true; btn_submit.Visible = true; btn_Cancel.Visible = true; SMHR_VOTECODEENTRY votecodeentry = new SMHR_VOTECODEENTRY(); votecodeentry.OPERATION = operation.GET; votecodeentry.VOTECODE_BU_ID = Convert.ToInt32(rcmb_BusinessUnit.SelectedValue); votecodeentry.VOTECODE_SALSTRUCT_ID = Convert.ToInt32(rcmb_SalaryStructure.SelectedValue); votecodeentry.VOTECODE_ORG_ID = Convert.ToInt32(Session["ORG_ID"]); DataTable dt = BLL.Get_VoteCodeEntry(votecodeentry); RG_VoteCodeEntry.DataSource = dt; RG_VoteCodeEntry.DataBind(); } else { rcmb_SalaryStructure.SelectedIndex = 0; BLL.ShowMessage(this, "Please Select Business Unit"); return; } } else { RG_VoteCodeEntry.Visible = false; RG_VoteCodeEntry.DataSource = null; RG_VoteCodeEntry.DataBind(); btn_submit.Visible = btn_Cancel.Visible = false; rcmb_SalaryStructure.SelectedIndex = 0; } } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "VoteCodeEntry", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); return; } }
protected void btn_save_Click(object sender, EventArgs e) { try { Label lblPtmID; RadTextBox txtVoteName; RadTextBox txtVoteCode; if (rcmb_BusinessUnit.SelectedIndex <= 0) { BLL.ShowMessage(this, "Please Select Business Unit"); return; } else if (rcmb_SalaryStructure.SelectedIndex <= 0) { BLL.ShowMessage(this, "please select Salary structure"); } string errorMsg = string.Empty; DataTable dtGetVoteCode = GetVoteCode(out errorMsg); if (!string.IsNullOrEmpty(errorMsg)) { BLL.ShowMessage(this, errorMsg); return; } //for (int i = 0; i < RG_VoteCodeEntry.Items.Count; i++) //{ // lblPtmID = RG_VoteCodeEntry.Items[i].FindControl("lblPtmID") as Label; // txtVoteName = RG_VoteCodeEntry.Items[i].FindControl("txtVoteName") as RadTextBox; // txtVoteCode = RG_VoteCodeEntry.Items[i].FindControl("txtVoteCode") as RadTextBox; // if ((txtVoteName.Text == string.Empty && txtVoteCode.Text != string.Empty) || (txtVoteName.Text != string.Empty && txtVoteCode.Text == string.Empty)) // { // if (txtVoteName.Text == string.Empty) // { // BLL.ShowMessage(this, "Kindly enter Account Name for the Pay Item - " + lblPtmID.Text); // txtVoteName.Focus(); // } // if (txtVoteCode.Text == string.Empty) // { // BLL.ShowMessage(this, "Kindly enter Account Code for the Pay Item - " + lblPtmID.Text); // txtVoteCode.Focus(); // } // return; // } //} SMHR_VOTECODEENTRY VOTECODE = new SMHR_VOTECODEENTRY(); VOTECODE.VOTECODE_ORG_ID = Convert.ToInt32(Session["ORG_ID"]); VOTECODE.VOTECODE_BU_ID = Convert.ToInt32(rcmb_BusinessUnit.SelectedValue); VOTECODE.VOTECODE_SALSTRUCT_ID = Convert.ToInt32(rcmb_SalaryStructure.SelectedValue); VOTECODE.VOTECODE_CREATEDBY = Convert.ToInt32(Session["USER_ID"]); VOTECODE.VOTECODE_CREATEDDATE = DateTime.Now; VOTECODE.VOTECODE_LASTMDFBY = Convert.ToInt32(Session["USER_ID"]); VOTECODE.VOTECODE_LASTMDFDATE = DateTime.Now; VOTECODE.OPERATION = operation.Insert1; for (int i = 0; i < RG_VoteCodeEntry.Items.Count; i++) { lblPtmID = RG_VoteCodeEntry.Items[i].FindControl("lblPtmID") as Label; txtVoteName = RG_VoteCodeEntry.Items[i].FindControl("txtVoteName") as RadTextBox; txtVoteCode = RG_VoteCodeEntry.Items[i].FindControl("txtVoteCode") as RadTextBox; if (txtVoteName.Text != string.Empty && txtVoteCode.Text != string.Empty && lblPtmID.Text != string.Empty) { VOTECODE.VOTECODE_PAYITEM_ID = Convert.ToInt32(lblPtmID.Text); VOTECODE.VOTECODE_NAME = txtVoteName.Text; VOTECODE.VOTECODE_CODE = txtVoteCode.Text; BLL.Set_VoteCodeEntry(VOTECODE); } } BLL.ShowMessage(this, "Information Saved Successfully"); rcmb_SalaryStructure.ClearSelection(); rcmb_SalaryStructure.Text = string.Empty; rcmb_BusinessUnit.ClearSelection(); rcmb_BusinessUnit.Text = string.Empty; RG_VoteCodeEntry.Visible = false; btn_submit.Visible = false; btn_Cancel.Visible = false; } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "VoteCodeEntry", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }