Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BusinessLayer.Common.MemberDiscountConfig objDiscountConfig = new BusinessLayer.Common.MemberDiscountConfig();
            Entity.Common.MemberDiscountConfig        DiscountConfig    = new Entity.Common.MemberDiscountConfig();
            DiscountConfig.MemberId = Convert.ToInt32(ddlMember.SelectedValue);

            int    Error             = 0;
            string strDiscountXml    = "<NewDataSet>";
            string strDiscountAmount = string.Empty;

            foreach (GridViewRow gvr in dgvFeesHead.Rows)
            {
                if (gvr.RowType == DataControlRowType.DataRow)
                {
                    DropDownList ddlDiscountType   = (DropDownList)gvr.FindControl("ddlDiscountType");
                    TextBox      txtDiscountAmount = (TextBox)gvr.FindControl("txtDiscountAmount");
                    CheckBox     ChkIsActive       = (CheckBox)gvr.FindControl("ChkIsActive");
                    strDiscountAmount = (string.IsNullOrEmpty(txtDiscountAmount.Text.Trim()) ? "0" : txtDiscountAmount.Text.Trim());
                    TextBox txtNarration = (TextBox)gvr.FindControl("txtNarration");

                    strDiscountXml += "<Row";
                    strDiscountXml += " FeesHeadId = \"" + dgvFeesHead.DataKeys[gvr.RowIndex].Values["FeesHeadId"].ToString() + "\"";
                    strDiscountXml += " DiscountType = \"" + ddlDiscountType.SelectedValue + "\"";
                    strDiscountXml += " DiscountAmount = \"" + strDiscountAmount + "\"";
                    strDiscountXml += " IsActive = \"" + ChkIsActive.Checked.ToString() + "\"";
                    strDiscountXml += " Narration = \"" + txtNarration.Text.Trim().Replace("'", "''") + "\"";
                    strDiscountXml += " />";

                    if (ddlDiscountType.SelectedValue.Equals("P") && Convert.ToDecimal(strDiscountAmount) > 100)
                    {
                        Error = 1;
                    }
                }
            }

            strDiscountXml += "</NewDataSet>";

            DiscountConfig.DiscountConfigXml = strDiscountXml;

            if (Error == 0)
            {
                objDiscountConfig.Save(DiscountConfig);

                LoadFeesDetails();
                Message.IsSuccess = true;
                Message.Text      = "Discount Saved Successfully";
            }
            else
            {
                Message.IsSuccess = false;
                Message.Text      = "Invalid Discount Amount";
            }
            Message.Show = true;
        }
Beispiel #2
0
        protected void LoadFeesDetails()
        {
            BusinessLayer.Common.MemberDiscountConfig objDiscountConfig = new BusinessLayer.Common.MemberDiscountConfig();
            DataTable dt = objDiscountConfig.GetAll(Convert.ToInt32(ddlMember.SelectedValue));

            dgvFeesHead.DataSource = dt;
            dgvFeesHead.DataBind();

            if (dt.Rows.Count > 0)
            {
                btnSave.Visible = true;
            }
            else
            {
                btnSave.Visible = false;
            }
        }