Exemple #1
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            LoadFeesHead();
            txtTotalAmt.Text = "0.00";

            BusinessLayer.Accounts.StudentOpeningBal objOpeningBal = new BusinessLayer.Accounts.StudentOpeningBal();
            Entity.Accounts.StudentOpeningBal        OpBal         = new Entity.Accounts.StudentOpeningBal();

            OpBal.StudentId = int.Parse(ddlMember.SelectedValue);

            DataSet ds = new DataSet();

            ds = objOpeningBal.StudentOpeningBalance_GetById(OpBal);

            if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
                decimal dramt = Convert.ToDecimal(ds.Tables[0].Rows[0]["AmountDr"].ToString());
                decimal cramt = Convert.ToDecimal(ds.Tables[0].Rows[0]["AmountCr"].ToString());
                txtTotalAmt.Text = (dramt > cramt) ? Convert.ToString(dramt) : Convert.ToString((cramt * -1));
            }

            if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
            {
                foreach (GridViewRow gvr in dgvFeesHead.Rows)
                {
                    TextBox      txtAmount  = (TextBox)gvr.FindControl("txtAmount");
                    DropDownList ddlDrCr    = (DropDownList)gvr.FindControl("ddlDrCr");
                    int          FeesHeadId = int.Parse(dgvFeesHead.DataKeys[gvr.RowIndex].Values[0].ToString());
                    foreach (DataRow dr in ds.Tables[1].Rows)
                    {
                        if (FeesHeadId == int.Parse(dr["FeesHeadId"].ToString()))
                        {
                            decimal AmtDr = Convert.ToDecimal(dr["AmountDr"].ToString());
                            decimal AmtCr = Convert.ToDecimal(dr["AmountCr"].ToString());
                            txtAmount.Text        = (AmtDr > AmtCr) ? Convert.ToString(AmtDr) : Convert.ToString(AmtCr);
                            ddlDrCr.SelectedValue = (AmtDr > AmtCr) ? "DR" : "CR";
                        }
                    }
                }
                ViewState["BillId"] = ds.Tables[0].Rows[0]["BillId"].ToString();
                btnSave.Text        = "Update";
            }
        }
Exemple #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int count = 0;

            if (ddlMember.SelectedValue == "0" || ddlMember.Text == string.Empty)
            {
                Message.IsSuccess = false;
                Message.Text      = "Please Select a Member";
                Message.Show      = true;
            }
            else
            {
                string strValues = DateTime.Now.ToString("dd MMM yyyy");
                strValues += chr.ToString() + "";
                DataSet ds_fn = gf.ExecuteSelectSP("spSelect_GetFnYear", strValues);

                //if (ds_fn.Tables[0].Rows[0]["FinYearID"].ToString() == Session["FinYrID"].ToString().Trim())
                //{
                BusinessLayer.Accounts.StudentOpeningBal objOpeningBal = new BusinessLayer.Accounts.StudentOpeningBal();
                Entity.Accounts.StudentOpeningBal        OpBal         = new Entity.Accounts.StudentOpeningBal();

                OpBal.CompanyID_FK = Convert.ToInt32(Session["CompanyId"].ToString().Trim());
                OpBal.BranchID_FK  = Convert.ToInt32(Session["BranchId"].ToString().Trim());
                OpBal.FinYearID_FK = Convert.ToInt32(Session["FinYrID"].ToString().Trim());
                OpBal.StudentId    = Convert.ToInt32(ddlMember.SelectedValue.Trim());
                OpBal.BillAmount   = Convert.ToDecimal(txtTotalAmt.Text.Trim());
                OpBal.CreatedBy    = Convert.ToInt32(Session["UserId"].ToString().Trim());

                DataTable DT = new DataTable();
                DT.Columns.Add("FeesHeadId", typeof(int));
                DT.Columns.Add("AmountDr", typeof(decimal));
                DT.Columns.Add("AmountCr", typeof(decimal));
                DataRow DR;

                foreach (GridViewRow GVR in dgvFeesHead.Rows)
                {
                    if (GVR.RowType == DataControlRowType.DataRow)
                    {
                        TextBox      txtAmount = (TextBox)GVR.FindControl("txtAmount");
                        DropDownList ddlDrCr   = (DropDownList)GVR.FindControl("ddlDrCr");
                        decimal      Amount    = (txtAmount.Text.Trim().Length > 0) ? Convert.ToDecimal(txtAmount.Text.Trim()) : 0;

                        if (Amount > 0)
                        {
                            count++;
                            DR = DT.NewRow();
                            DR["FeesHeadId"] = Convert.ToInt32(dgvFeesHead.DataKeys[GVR.RowIndex].Value.ToString());
                            DR["AmountDr"]   = (ddlDrCr.SelectedValue == "DR") ? Amount : 0;
                            DR["AmountCr"]   = (ddlDrCr.SelectedValue == "CR") ? Amount : 0;
                            DT.Rows.Add(DR);
                            DT.AcceptChanges();
                        }
                    }
                }

                using (DataSet ds = new DataSet())
                {
                    ds.Tables.Add(DT);
                    OpBal.OpeningBalXML = ds.GetXml().Replace("Table1>", "Table>");
                }

                if (ViewState["BillId"] != null && ViewState["BillId"].ToString().Length > 0)
                {
                    OpBal.BillId = int.Parse(ViewState["BillId"].ToString());
                    ViewState.Remove("BillId");
                }
                else
                {
                    OpBal.BillId = 0;
                }

                if (count > 0)
                {
                    int RecCount = objOpeningBal.SaveOpBal(OpBal);
                    if (RecCount > 0)
                    {
                        Message.IsSuccess = true;
                        Message.Text      = "Opening Balance Created Successfully";
                    }
                    else
                    {
                        Message.IsSuccess = false;
                        Message.Text      = "Opening Balance Allready Created";
                    }
                }
                else
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Please Enter Amount for Atleast One Head";
                }
                //}
                //else
                //{
                //    Message.IsSuccess = false;
                //    Message.Text = "Please select a Date Between " + Session["SesFromDate"].ToString() + " & " + Session["SesToDate"].ToString();
                //}

                Message.Show = true;
            }
        }