Exemplo n.º 1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Session["RequestUserid"] as string))
        {
            ob_bel.WalletId      = Convert.ToInt32(Session["walletid"]);
            ob_bel.UserId        = Convert.ToInt32(Session["RequestUserid"]);
            ob_bel.Amount        = Convert.ToDecimal(Session["walletamount"]);
            ob_bel.AddedAmount   = Convert.ToDecimal(txtamount.Text);
            ob_bel.Customername  = txtFulltname.Text;
            ob_bel.EmailId       = txtEmailid.Text;
            ob_bel.UserIdetifyNo = lblUserID.Text;
            ob_bel.PaymentType   = "";
            if (ddPaymenttype.SelectedIndex > 0)
            {
                ob_bel.PaymentType = Convert.ToString(ddPaymenttype.SelectedValue);
            }
            ob_bel.TransactionNo = 0;

            if (txtTransactionNo.Text != "")
            {
                ob_bel.TransactionNo = Convert.ToInt64(txtTransactionNo.Text);
            }
            ob_bel.WalletStatus = "";
            if (txtRemarks.Text != "")
            {
                ob_bel.WalletStatus = txtRemarks.Text;
            }
            int user = Convert.ToInt32(Session["userid"]);
            ob_bel.ActionBy = user;
            decimal WalletAmtFromAdd = 0;
            string  loginid          = Convert.ToString(Session["loginid"]);
            WalletAmtFromAdd = GetMainBalance(loginid);

            ShoppingCart obj_bll = new ShoppingCart();
            int          result  = 0;
            try
            {
                if (WalletAmtFromAdd >= Convert.ToDecimal(txtamount.Text))
                {
                    result = obj_bll.AddMoney(ob_bel);

                    if (result != 0)
                    {
                        bool    status        = true;
                        string  requeststatus = "Amount Added";
                        long    transaccont   = Convert.ToInt64(txtTransactionNo.Text);
                        decimal tranferamount = Convert.ToDecimal(Session["RequestAmount"]);
                        string  requestid     = Convert.ToString(Session["RequestID"]);
                        if (Session["RequestID"] != null)
                        {
                            ob_wallet.UpdateCustomerPayWalletStatus(status, tranferamount, transaccont, requeststatus, requestid);
                        }

                        lblMessage.ForeColor = Color.Green;
                        lblMessage.Text      = txtamount.Text + " rupees added into " + txtFulltname.Text + " wallet.";

                        string useridentifyno = lblUserID.Text;
                        if (useridentifyno != null)
                        {
                            SendMsg(useridentifyno);
                        }
                        txtamount.Text              = "";
                        txtRemarks.Text             = "";
                        txtTransactionNo.Text       = "";
                        ddPaymenttype.SelectedIndex = 0;
                        Session["RequestUserid"]    = null;
                        Session["RequestAmount"]    = null;
                        Session["TransactionNo"]    = null;
                        Session["PaymentType"]      = null;
                        Session["walletid"]         = null;
                        Session["walletamount"]     = null;
                        Response.Redirect("MemberDepostRequest.aspx", false);
                    }
                }
                else
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = txtamount.Text + " rupees amount should be less than wallet amount.";
                }
            }
            catch (Exception ex)
            {
                lblMessage.ForeColor = Color.Red;
                lblMessage.Text      = ex.Message;
            }
        }

        if (!string.IsNullOrEmpty(Session["NewUserID"] as string))
        {
            ob_bel.WalletId      = Convert.ToInt32(Session["walletid"]);
            ob_bel.UserId        = Convert.ToInt32(Session["NewUserID"]);
            ob_bel.Amount        = Convert.ToDecimal(Session["walletamount"]);
            ob_bel.AddedAmount   = Convert.ToDecimal(txtamount.Text);
            ob_bel.Customername  = txtFulltname.Text;
            ob_bel.EmailId       = txtEmailid.Text;
            ob_bel.UserIdetifyNo = lblUserID.Text;

            ob_bel.PaymentType = "";
            if (ddPaymenttype.SelectedIndex > 0)
            {
                ob_bel.PaymentType = Convert.ToString(ddPaymenttype.SelectedValue);
            }
            ob_bel.TransactionNo = 0;
            if (txtTransactionNo.Text != "")
            {
                ob_bel.TransactionNo = Convert.ToInt64(txtTransactionNo.Text);
            }
            ob_bel.WalletStatus = "";
            if (txtRemarks.Text != "")
            {
                ob_bel.WalletStatus = txtRemarks.Text;
            }
            int user = Convert.ToInt32(Session["userid"]);
            ob_bel.ActionBy = user;
            //decimal WalletAmtFromAdd = 0;
            //string loginid = Convert.ToString(Session["loginid"]);
            //WalletAmtFromAdd = GetMainBalance(loginid);

            ShoppingCart obj_bll = new ShoppingCart();
            int          result  = 0;
            try
            {
                result = obj_bll.AddMoney(ob_bel);

                if (result != 0)
                {
                    lblMessage.ForeColor = Color.Green;
                    lblMessage.Text      = txtamount.Text + " rupees added into " + txtFulltname.Text + " wallet.";

                    string useridentifyno = lblUserID.Text;
                    if (useridentifyno != null)
                    {
                        SendMsg(useridentifyno);
                    }
                    txtamount.Text              = "";
                    txtRemarks.Text             = "";
                    txtTransactionNo.Text       = "";
                    ddPaymenttype.SelectedIndex = 0;
                    Session["NewUserID"]        = null;
                    Session["walletid"]         = null;
                    Session["walletamount"]     = null;
                    Response.Redirect("AddtoWallet.aspx", false);
                }
            }
            catch (Exception ex)
            {
                lblMessage.ForeColor = Color.Red;
                lblMessage.Text      = ex.Message;
            }
        }
    }