//Get Scheme #region [Get Scheme] public void GetScheme() { try { ObjEWA = new EWA_Scheme(); ObjBL = new BL_Scheme(); ObjEWA.OrganizationId = Convert.ToInt32(Session["OrgId"].ToString()); ObjEWA.AcademicYearId = Convert.ToInt32(Session["AcademicYearId"]); ds = ObjBL.GetScheme_BL(ObjEWA); if (ds.Tables[0].Rows.Count > 0) { dvScheme = new DataView(ds.Tables[0]); ViewState["dvScheme"] = ds; ddlScheme.DataTextField = "SchemeName"; ddlScheme.DataValueField = "SchemeId"; ddlScheme.DataSource = ds.Tables[0]; ddlScheme.DataBind(); ddlScheme.Items.Insert(0, "Select"); //BindGrantedAmount(); //BindGridView(); } else { //No data } } catch (Exception exp) { GeneralErr(exp.Message); } }
//Update Scheme #region [Insert Scheme] public DataSet UpdateScheme_DL(EWA_Scheme objEWA) { DataSet ds = null; try { prmList = new string[12]; prmList[0] = "@Action"; prmList[1] = "Update"; prmList[2] = "@SchemeId"; prmList[3] = objEWA.SchemeId.ToString(); prmList[4] = "@SchemeDetailsId"; prmList[5] = objEWA.SchemeDetailsId.ToString(); prmList[6] = "@FundName"; prmList[7] = objEWA.FundName; prmList[8] = "@DistributedAmount"; prmList[9] = objEWA.DistributedAmount.ToString(); prmList[10] = "@UserId"; prmList[11] = objEWA.UserId.ToString(); ds = ObjHelper.FillControl(prmList, "SP_Scheme"); return(ds); } catch (Exception) { throw; } }
//Grid Fee row deleting #region [Grid Fee Row Deleting] protected void GrdScheme_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { string[] confirmValue = Request.Form["confirm_value"].Split(','); if (confirmValue[confirmValue.Length - 1] == "Yes") { EWA_Scheme ObjEWA = new EWA_Scheme(); BL_Scheme ObjBL = new BL_Scheme(); ObjEWA.Action = "Delete"; ObjEWA.SchemeId = Convert.ToInt32(ddlScheme.SelectedItem.Value); Label lblSchemeDetailsId = (Label)GrdScheme.Rows[e.RowIndex].FindControl("lblSchemeDetailsId"); ObjEWA.SchemeDetailsId = Convert.ToInt32(lblSchemeDetailsId.Text); ObjBL.DeleteScheme_BL(ObjEWA); BindGridView(); lblresult.ForeColor = Color.Green; lblresult.Text = ObjEWA.FundName + " Details Deleted successfully"; } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//Insert Scheme #region [Insert Scheme] public DataSet InsertScheme_DL(EWA_Scheme objEWA) { DataSet ds = null; try { prmList = new string[16]; prmList[0] = "@Action"; prmList[1] = "Save"; prmList[2] = "@SchemeId"; prmList[3] = objEWA.SchemeId.ToString(); prmList[4] = "@FundName"; prmList[5] = objEWA.FundName; prmList[6] = "@DistributedAmount"; prmList[7] = objEWA.DistributedAmount.ToString(); prmList[8] = "@AcademicYearId"; prmList[9] = objEWA.AcademicYearId.ToString(); prmList[10] = "@OrganizationId"; prmList[11] = objEWA.OrganizationId.ToString(); prmList[12] = "@UserId"; prmList[13] = objEWA.UserId.ToString(); prmList[14] = "@IsActive"; prmList[15] = objEWA.IsActive.ToString(); ds = ObjHelper.FillControl(prmList, "SP_Scheme"); return(ds); } catch (Exception) { throw; } }
//Update Scheme #region [Update Scheme] public DataSet UpdateScheme_BL(EWA_Scheme objEWA) { try { DL_Scheme objDL = new DL_Scheme(); DataSet ds = objDL.UpdateScheme_DL(objEWA); return(ds); } catch (Exception) { throw; } }
//Get Data #region [Get Data] public DataSet BindScheme_BL(EWA_Scheme ObjEWA) { try { DL_Scheme objDL = new DL_Scheme(); DataSet ds = objDL.BindScheme_DL(ObjEWA); return(ds); } catch (Exception) { throw; } }
public DataSet SchemeGridBind_BL(EWA_Scheme objEWA) { try { DL_Scheme objDL = new DL_Scheme(); DataSet ds = objDL.SchemeGridBind_DL(objEWA); return(ds); } catch (Exception) { throw; } }
public int SchemeAction_BL(EWA_Scheme objEWA) { try { DL_Scheme objDL = new DL_Scheme(); int flag = objDL.SchemeAction_DL(objEWA); return(flag); } catch (Exception) { throw; } }
//Subjects Grid Bind #region [Subject Grid Bind] private void GrdSchemeBind( ) { try { EWA_Scheme objEWA = new EWA_Scheme(); objEWA.OrganizationId = Convert.ToInt32(Session["OrgId"]); DataSet ds = objBL.SchemeGridBind_BL(objEWA); GrdScheme.DataSource = ds; GrdScheme.DataBind(); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//Grid Fee Row Command #region [Grid Fee Row Command] protected void GrdScheme_RowCommand(object sender, GridViewCommandEventArgs e) { try { EWA_Scheme ObjEWA = new EWA_Scheme(); BL_Scheme ObjBL = new BL_Scheme(); if (e.CommandName.Equals("AddNew")) { TextBox txtFundName = (TextBox)GrdScheme.FooterRow.FindControl("txtFooterFundName"); TextBox txtDistributedAmount = (TextBox)GrdScheme.FooterRow.FindControl("txtFooterDistributedAmount"); if ((Convert.ToDouble(ViewState["TotalAmount"].ToString()) + Convert.ToDouble(txtDistributedAmount.Text)) <= Convert.ToDouble(txtGrantedAmount.Text)) { ObjEWA.SchemeId = Convert.ToInt32(ddlScheme.SelectedItem.Value); ObjEWA.AcademicYearId = Convert.ToInt32(Session["AcademicYearId"]); ObjEWA.OrganizationId = Convert.ToInt32(Session["OrgId"].ToString()); ObjEWA.UserId = Session["UserCode"].ToString(); ObjEWA.FundName = txtFundName.Text; // string str = txtDistributedAmount.Text; ObjEWA.DistributedAmount = Convert.ToDouble(txtDistributedAmount.Text); ObjEWA.Action = "Save"; ObjBL.InsertScheme_BL(ObjEWA); BindGridView(); lblresult.ForeColor = Color.Green; lblresult.Text = ObjEWA.FundName + " Details inserted successfully"; } else { lblresult.ForeColor = Color.Red; lblresult.Text = "Distributed amount should be less than granted amount."; } ////msgBox.ShowMessage("Particular added successfully !!!", "Information", UserControls.MessageBox.MessageStyle.Critical); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//Delete Scheme #region [Bind Class] public DataSet DeleteScheme_DL(EWA_Scheme ObjEWA) { DataSet ds = new DataSet(); try { prmList = new string[4]; prmList[0] = "@Action"; prmList[1] = "Delete"; prmList[2] = "@SchemeDetailsId"; prmList[3] = ObjEWA.SchemeDetailsId.ToString(); ds = ObjHelper.FillControl(prmList, "SP_Scheme"); return(ds); } catch (Exception) { throw; } }
//Get Scheme #region [Get Scheme] public DataSet GetScheme_DL(EWA_Scheme ObjEWA) { DataSet ds = new DataSet(); try { prmList = new string[6]; prmList[0] = "@Action"; prmList[1] = "GetScheme"; prmList[2] = "@OrganizationId"; prmList[3] = ObjEWA.OrganizationId.ToString(); prmList[4] = "@AcademicYearId"; prmList[5] = ObjEWA.AcademicYearId.ToString(); ds = ObjHelper.FillControl(prmList, "SP_Scheme"); return(ds); } catch (Exception) { throw; } }
//Grid Fee Row Updating #region [Grid Fee Row Updating] protected void GrdScheme_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { EWA_Scheme ObjEWA = new EWA_Scheme(); BL_Scheme ObjBL = new BL_Scheme(); ObjEWA.Action = "Update"; ObjEWA.SchemeId = Convert.ToInt32(ddlScheme.SelectedItem.Value); TextBox txtFundName = (TextBox)GrdScheme.Rows[e.RowIndex].FindControl("txtFundName"); TextBox txtDistributedAmount = (TextBox)GrdScheme.Rows[e.RowIndex].FindControl("txtDistributedAmount"); Label lblSchemeDetailsId = (Label)GrdScheme.Rows[e.RowIndex].FindControl("lblSchemeDetailsId"); if ((Convert.ToDouble(ViewState["TotalAmount"].ToString()) + Convert.ToDouble(txtDistributedAmount.Text) - Convert.ToDouble(ViewState["OldDistributedAmount"].ToString())) <= Convert.ToDouble(txtGrantedAmount.Text)) { ObjEWA.SchemeDetailsId = Convert.ToInt32(lblSchemeDetailsId.Text); ObjEWA.FundName = txtFundName.Text; ObjEWA.DistributedAmount = Convert.ToDouble(txtDistributedAmount.Text); ObjEWA.UserId = Session["UserCode"].ToString(); ObjBL.UpdateScheme_BL(ObjEWA); GrdScheme.EditIndex = -1; BindGridView(); lblresult.ForeColor = Color.Green; lblresult.Text = ObjEWA.FundName + " Details Updated successfully"; } else { lblresult.ForeColor = Color.Red; lblresult.Text = "Distributed amount should be less than granted amount."; } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//Bind Grid View #region [Bind Grid View] private void BindGridView() { try { EWA_Scheme ObjEWA = new EWA_Scheme(); BL_Scheme ObjBL = new BL_Scheme(); DataSet ds = new DataSet(); SchemeId = ddlScheme.SelectedItem.Value; if (!SchemeId.Equals("Select")) { ObjEWA.SchemeId = Convert.ToInt32(ddlScheme.SelectedItem.Value); ObjEWA.AcademicYearId = Convert.ToInt32(Session["AcademicYearId"]); ObjEWA.OrganizationId = Convert.ToInt32(Session["OrgId"].ToString()); ds = ObjBL.BindScheme_BL(ObjEWA); if (ds.Tables[0].Rows.Count != 0) { GrdScheme.DataSource = ds.Tables[0]; GrdScheme.DataBind(); } else { BindEmptyDataTable(ds); } } else { BindEmptyDataTable(ds); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//To Perform Insert,Update,Delete and Search Actions On Subject Table #region [Perform Actions On Subject] public int SchemeAction_DL(EWA_Scheme objEWA) { try { cmd = new SqlCommand("SP_Scheme", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", objEWA.Action); cmd.Parameters.AddWithValue("@SchemeId", objEWA.SchemeId); cmd.Parameters.AddWithValue("@SchemeName", objEWA.SchemeName); cmd.Parameters.AddWithValue("@GrantedAmt", objEWA.SchemeAmount); cmd.Parameters.AddWithValue("@OrganizationId", objEWA.OrganizationId); cmd.Parameters.AddWithValue("@AcademicYearId", objEWA.AcademicYearId); cmd.Parameters.AddWithValue("@UserId", objEWA.UserId); cmd.Parameters.AddWithValue("@IsActive", objEWA.IsActive); con.Open(); int flag = cmd.ExecuteNonQuery(); con.Close(); return(flag); } catch (Exception ex) { int err = ((System.Data.SqlClient.SqlException)(ex)).Number; if (err == 547 && objEWA.Action == "Delete") { throw new SystemException("Record is in use !!!"); } else { throw ex; } } finally { con.Close(); cmd.Dispose(); } }