protected void lnk_Edit_Command(object sender, CommandEventArgs e) { try { //to clear controls ClearControls(); rcmb_FinancialYear.Enabled = false; LoadFinancialPeriods(); //To load financial periods //To fetch data based on CommandArgument SMHR_PNCN_INTRST _objPNCNIntrst = new SMHR_PNCN_INTRST(); _objPNCNIntrst.PNCN_ID = Convert.ToInt32(e.CommandArgument); _objPNCNIntrst.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); _objPNCNIntrst.OPERATION = operation.Get; DataTable dtPensionCbn = BLL.get_PensionContributionInterest(_objPNCNIntrst); if (dtPensionCbn.Rows.Count > 0) //If data exists, fill the data in respective controls { lblPNCN_ID.Text = Convert.ToString(dtPensionCbn.Rows[0]["PNCN_ID"]); rcmb_FinancialYear.SelectedIndex = rcmb_FinancialYear.Items.FindItemIndexByValue(Convert.ToString(dtPensionCbn.Rows[0]["PNCN_PERIOD_ID"])); rcmb_FinancialYear_SelectedIndexChanged(null, null); rtxt_Qrtr1.Text = Convert.ToString(dtPensionCbn.Rows[0]["PNCN_QRTR1"]); rtxt_Qrtr2.Text = Convert.ToString(dtPensionCbn.Rows[0]["PNCN_QRTR2"]); rtxt_Qrtr3.Text = Convert.ToString(dtPensionCbn.Rows[0]["PNCN_QRTR3"]); rtxt_Qrtr4.Text = Convert.ToString(dtPensionCbn.Rows[0]["PNCN_QRTR4"]); rtxt_YearlyInterest.Text = Convert.ToString(dtPensionCbn.Rows[0]["PNCN_YEARLY_INTEREST"]); } else { ClearControls(); } if (Convert.ToInt32(Session["WRITEFACILITY"]) == 2) { btn_Update.Visible = false; } else { btn_Update.Visible = true; } btn_Save.Visible = false; //hide save button as the user clicks on Edit RMP_IntrstOnNormalContributions.SelectedIndex = 1; } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_IntrstOnNormlContribution", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }
private void LoadGrid() { try { SMHR_PNCN_INTRST _objPnCn = new SMHR_PNCN_INTRST(); _objPnCn.OPERATION = operation.Select; _objPnCn.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); DataTable dtPensionCbn = BLL.get_PensionContributionInterest(_objPnCn); Rg_IntrstOnNormalContributions.DataSource = dtPensionCbn; } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_IntrstOnNormlContribution", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }
protected void btn_Save_Click(object sender, EventArgs e) { try { if (rcmb_FinancialYear.SelectedIndex <= 0) { BLL.ShowMessage(this, "Please Select Financial Year"); return; } else if (string.IsNullOrEmpty(rtxt_YearlyInterest.Text)) { BLL.ShowMessage(this, "No details exists to save"); return; } SMHR_PNCN_INTRST _objPNCNIntrst = new SMHR_PNCN_INTRST(); _objPNCNIntrst.PNCN_PERIOD_ID = Convert.ToInt32(rcmb_FinancialYear.SelectedValue); _objPNCNIntrst.PNCN_QRTR1 = string.IsNullOrEmpty(rtxt_Qrtr1.Text) ? 0 : Convert.ToDecimal(rtxt_Qrtr1.Text); _objPNCNIntrst.PNCN_QRTR2 = string.IsNullOrEmpty(rtxt_Qrtr2.Text) ? 0 : Convert.ToDecimal(rtxt_Qrtr2.Text); _objPNCNIntrst.PNCN_QRTR3 = string.IsNullOrEmpty(rtxt_Qrtr3.Text) ? 0 : Convert.ToDecimal(rtxt_Qrtr3.Text); _objPNCNIntrst.PNCN_QRTR4 = string.IsNullOrEmpty(rtxt_Qrtr4.Text) ? 0 : Convert.ToDecimal(rtxt_Qrtr4.Text); _objPNCNIntrst.PNCN_YEARLY_INTEREST = string.IsNullOrEmpty(rtxt_YearlyInterest.Text) ? 0 : Convert.ToDecimal(rtxt_YearlyInterest.Text); _objPNCNIntrst.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); switch (((Button)sender).ID.ToUpper()) { case "BTN_SAVE": //To check if similar record exists _objPNCNIntrst.OPERATION = operation.Check; if (BLL.set_PensionContributionInterest(_objPNCNIntrst)) { BLL.ShowMessage(this, "Record already exists for the selected Financial Year"); return; } _objPNCNIntrst.CREATEDBY = Convert.ToInt32(Session["User_ID"]); _objPNCNIntrst.CREATEDDATE = DateTime.Now; _objPNCNIntrst.OPERATION = operation.Insert; if (BLL.set_PensionContributionInterest(_objPNCNIntrst)) { BLL.ShowMessage(this, "Information Saved Sucessfully"); } else { BLL.ShowMessage(this, "Information Not Saved"); } break; case "BTN_UPDATE": _objPNCNIntrst.PNCN_ID = Convert.ToInt32(lblPNCN_ID.Text); _objPNCNIntrst.PNCN_MODIFIEDBY = Convert.ToInt32(Session["User_ID"]); _objPNCNIntrst.PNCN_MODIFIEDDATE = DateTime.Now; _objPNCNIntrst.OPERATION = operation.Update; if (BLL.set_PensionContributionInterest(_objPNCNIntrst)) { BLL.ShowMessage(this, "Information Updated Sucessfully"); } else { BLL.ShowMessage(this, "Information Not Updated"); } break; default: break; } RMP_IntrstOnNormalContributions.SelectedIndex = 0; ClearControls(); LoadGrid(); Rg_IntrstOnNormalContributions.DataBind(); } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_IntrstOnNormlContribution", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }