Ejemplo n.º 1
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);
            }
        }