protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    //if (Session["LoginID"] != null)
                    //{
                    //    if (Session["ClientType"].ToString() == "Distributor")
                    //    {
                    //        Response.Redirect("Login.aspx", false);
                    //        Session.Abandon();
                    //        return;
                    //    }

                    //}
                    string Condition = Request.QueryString["Condition"];
                    if (Condition != null && Condition != "")
                    {
                        Condition = Encryption.Decrypt(Request.QueryString["Condition"]);
                    }
                    else
                    {
                        Condition = "";
                    }
                    string Identity = Request.QueryString["Identity"];
                    if (Identity != null && Identity != "")
                    {
                        Identity = Encryption.Decrypt(Request.QueryString["Identity"]);
                    }
                    else
                    {
                        Identity = "";
                    }
                    if (Condition == "View")
                    {
                        divActive.Visible = true;
                        FillTariff(Identity);
                        ResetControl(2);
                        btnReset.Visible  = false;
                        btnSave.Visible   = false;
                        btnBack.Visible   = true;
                        btnUpdate.Visible = false;
                    }
                    if (Condition == "Edit")
                    {
                        divActive.Visible = true;
                        FillTariff(Identity);
                        hddnTariffID.Value = Identity.ToString();
                        //txtTariffCode.Attributes.Add("readonly", "true");
                        btnReset.Visible  = false;
                        btnSave.Visible   = false;
                        btnBack.Visible   = true;
                        btnUpdate.Visible = true;
                    }
                    if (Condition == "")
                    {
                        divActive.Visible = false;
                        btnBack.Visible   = true;
                        btnUpdate.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtGroup.Text.Trim() == "")
                {
                    ShowPopUpMsg("Please enter Tariff Group. ");
                    return;
                }
                if (btnSave.Text.Trim() == "Save")
                {
                    DataSet ds = svc.CheckTariffGroupExist(txtGroup.Text.Trim());
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        ShowPopUpMsg("Tariff Group alredy exist with this name. ");
                        return;
                    }
                }

                STariff sTM = new STariff();
                //sTM.Comission = Convert.ToDouble(txtComission.Text.Trim());
                // add by akash starts
                //sTM.H2OGeneralDiscount = Convert.ToDouble(txtH2OGeneralDiscount.Text.Trim());
                // add by akash ends
                sTM.GroupName     = Convert.ToString(txtGroup.Text.Trim());
                sTM.dtSpiffDetail = SpiffDetail();

                int loginID = Convert.ToInt32(Session["LoginID"]);
                // add by akash starts
                decimal H2ORechargeDiscount = 0;
                decimal.TryParse(Convert.ToString(txtH2ORechargeDiscount.Text), out H2ORechargeDiscount);
                //H2ORechargeDiscount = Convert.ToDecimal(txtH2ORechargeDiscount.Text);
                // add by akash ends
                decimal rechargecommision = 0;
                decimal.TryParse(Convert.ToString(txtRechageCom.Text), out rechargecommision);
                // decimal rechargecommision = Convert.ToDecimal(txtRechageCom.Text);
                decimal _Comission = 0;
                decimal.TryParse(Convert.ToString(txtComission.Text), out _Comission);

                decimal _H2OGeneralDiscount = 0;
                decimal.TryParse(Convert.ToString(txtH2OGeneralDiscount.Text), out _H2OGeneralDiscount);

                if (btnSave.Text.Trim() == "Save")
                {
                    int TariggGroupId = 0;
                    int a             = svc.SaveTariffGroupSpiffMapping(sTM, loginID, TariggGroupId, "INSERT", rechargecommision, H2ORechargeDiscount, Convert.ToDecimal(_Comission), Convert.ToDecimal(_H2OGeneralDiscount));
                    if (a > 0)
                    {
                        ShowPopUpMsg("Data Saved Successfully");
                        ResetControl();
                        Response.Redirect("TariffGroup.aspx");
                    }

                    else
                    {
                        ShowPopUpMsg("Detail not saved. \n Please Try Again");
                    }
                }
                else
                {
                    string identity = Convert.ToString(Request.QueryString["Identity"]);
                    identity = Encryption.Decrypt(identity);
                    int TariggGroupId = 0;
                    TariggGroupId = Convert.ToInt32(identity);


                    int a = svc.SaveTariffGroupSpiffMapping(sTM, loginID, TariggGroupId, "UPDATE", rechargecommision, H2ORechargeDiscount, Convert.ToDecimal(_Comission), Convert.ToDecimal(_H2OGeneralDiscount));
                    if (a > 0)
                    {
                        ShowPopUpMsg("Data Updated Successfully");
                        ResetControl();
                        //Response.Redirect("TariffGroup.aspx");
                    }
                    else
                    {
                        ShowPopUpMsg("Detail not Updated. \n Please Try Again");
                    }
                }
            }
            catch (Exception ex)
            {
                ShowPopUpMsg(ex.Message);
            }
        }