Exemplo n.º 1
0
    protected void rpFixamount_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "FixAmount")
        {
            if ((e.Item.ItemType == ListItemType.Item) || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Label   lblfixamount = (Label)e.Item.FindControl("lblFixamount");
                TextBox txtamount    = (TextBox)e.Item.FindControl("txtAmounts");
                if (txtamount.Text == "")
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = "Enter the new value of add amout.";
                    return;
                }
                Label   lblwalletamount = (Label)e.Item.FindControl("lblWalletamt");
                decimal walletblce      = 0;
                if (lblwalletamount.Text != "0")
                {
                    walletblce = Convert.ToDecimal(lblwalletamount.Text);
                }
                decimal fixamount = 0;
                if (lblfixamount.Text != "")
                {
                    fixamount = Convert.ToDecimal(lblfixamount.Text);
                }
                decimal addedamount   = Convert.ToDecimal(txtamount.Text);
                decimal fixamounts    = fixamount + addedamount;
                string  useridetifyno = GetUserIdentifyNo(Convert.ToString(Session["userid"]));
                Int32   userid        = Convert.ToInt32(Session["userid"]);
                decimal percent       = getPercetage();
                int     result        = 0;

                if (walletblce != 0)
                {
                    try
                    {
                        if (local_wallet.IsFixExists(userid) == "T")
                        {
                            result = local_wallet.AddNewFixAmount(fixamounts, addedamount, useridetifyno, userid, percent);
                            local_wallet.UpdateCustomerWalletFundtransfer(addedamount, userid);
                            if (result != 0)
                            {
                                string user = Convert.ToString(Session["userid"]);
                                BindFixAmountDetail(user);
                                BindToFixAmount(user);
                                mpe.Show();
                                lblpopup.Text = "Your amount added to fixed amount.";
                                //lblMessage.ForeColor = Color.Green;
                                //lblMessage.Text = "Your amount added to fixed amount.";
                            }
                        }
                        else
                        {
                            string monthcount = "Month Begin";
                            result = local_wallet.AddNewFixAmountFirst(fixamounts, addedamount, useridetifyno, monthcount, userid, percent);
                            local_wallet.UpdateCustomerWalletFundtransfer(addedamount, userid);
                            if (result != 0)
                            {
                                string user = Convert.ToString(Session["userid"]);
                                BindFixAmountDetail(user);
                                BindToFixAmount(user);
                                mpe.Show();
                                lblpopup.Text = "Your amount added to fixed amount.";
                                //lblMessage.ForeColor = Color.Green;
                                //lblMessage.Text = "Your amount added to fixed amount.";
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        lblMessage.ForeColor = Color.Red;
                        lblMessage.Text      = ex.Message;
                    }
                }
                else
                {
                    mpe.Show();
                    lblpopup.Text = "You haven't enough wallet balance to fix amount.";
                    //lblMessage.ForeColor = Color.Red;
                    //lblMessage.Text = "You haven't enough wallet balance to fix amount.";
                }
            }
        }

        if (e.CommandName == "DetachAmount")
        {
            if ((e.Item.ItemType == ListItemType.Item) || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Label   lblfixamount    = (Label)e.Item.FindControl("lblFixamount");
                TextBox txtamount       = (TextBox)e.Item.FindControl("txtAmounts");
                Label   lblwalletamount = (Label)e.Item.FindControl("lblWalletamt");
                if (txtamount.Text == "")
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = "Enter the new value of deduct amount.";
                    return;
                }
                decimal walletblce = 0;
                if (lblwalletamount.Text != "0.00")
                {
                    walletblce = Convert.ToDecimal(lblwalletamount.Text);
                }
                decimal fixamount = 0;
                if (lblfixamount.Text != "")
                {
                    fixamount = Convert.ToDecimal(lblfixamount.Text);
                }
                decimal deductamount = Convert.ToDecimal(txtamount.Text);

                string  useridetifyno = GetUserIdentifyNo(Convert.ToString(Session["userid"]));
                Int32   userid        = Convert.ToInt32(Session["userid"]);
                decimal percent       = getPercetage();

                int result = 0;
                try
                {
                    if (local_wallet.IsFixExists(userid) == "T")
                    {
                        if (fixamount >= deductamount)
                        {
                            fixamount = fixamount - deductamount;

                            result = local_wallet.DeductNewFixAmount(fixamount, deductamount, useridetifyno, userid, percent);
                            local_wallet.UpdateCustomerWalletDeductAdd(deductamount, userid);
                            if (result != 0)
                            {
                                string user = Convert.ToString(Session["userid"]);
                                BindFixAmountDetail(user);
                                BindToFixAmount(user);
                                mpe.Show();
                                lblpopup.Text = "Amount detached from fixed amount.";
                                //lblMessage.ForeColor = Color.Green;
                                //lblMessage.Text = "Amount detached from fixed amount.";
                            }
                        }
                        else
                        {
                            mpe.Show();
                            lblpopup.Text = "You have not enough fixed amount to deduct.";
                            //lblMessage.ForeColor = Color.Red;
                            //lblMessage.Text = "You have not enough fixed amount to deduct.";
                        }
                    }
                    else
                    {
                        mpe.Show();
                        lblpopup.Text = "You haven't fixed amount to detach.";
                        //lblMessage.ForeColor = Color.Red;
                        //lblMessage.Text = "You haven't fixed amount to detach.";
                    }
                }
                catch (Exception ex)
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = ex.Message;
                }
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["TranferOTP"].ToString() == Session["txtCodeTranferOTP"].ToString())
            {
                string uid           = Configuration.SuvidhaUser;
                string pin           = Configuration.SuvidhaPin;
                string mobileno      = Session["MobileNo"].ToString();
                string benecode      = Session["BenfCode"].ToString();
                string ifsccode      = Session["IfscCode"].ToString();
                string amount        = Session["TransferAmount"].ToString();
                string paytype       = Session["BeneficiaryType"].ToString();
                string accountno     = Session["BeneAccount"].ToString();
                string beneName      = Session["BeneName"].ToString();
                string transactionId = TransactionID();

                string URL = "http://recharge.suvidhaarecharge.com/api/MoneyTransfer/MoneyTransfer?Username="******"&Password="******"&Mobile=" + mobileno + "&BeneCode=" + benecode + "&IFSC=" + ifsccode + "&Amount=" + amount + "&PayType=" + paytype + "&AccountNumber=" + accountno + "&Name=" + beneName + "&YourTransactionID=" + transactionId + "";

                var httpWebRequest = (HttpWebRequest)WebRequest.Create(URL);

                string postData = "http://recharge.suvidhaarecharge.com/api/MoneyTransfer/MoneyTransfer?Username="******"&Password="******"&Mobile=" + mobileno + "&BeneCode=" + benecode + "&IFSC=" + ifsccode + "&Amount=" + amount + "&PayType=" + paytype + "&AccountNumber=" + accountno + "&Name=" + benecode + "&YourTransactionID=" + transactionId + "";
                httpWebRequest.Method        = WebRequestMethods.Http.Post;
                httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
                httpWebRequest.ContentLength = postData.Length;

                using (StreamWriter writer = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    writer.Write(postData);
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    CustRegistraion      cr = js.Deserialize <CustRegistraion>(result);
                    Int32  user_id          = cr.UserId;
                    string bankAcno         = cr.BankAccNo;
                    string benename         = cr.BeneficiaryName;
                    string sendermobile     = cr.SenderMobile;
                    string requestno        = cr.requestNo;
                    string errormsg         = cr.ErrorMsg;
                    string message          = cr.Message;

                    if (message == "SUCCESS")
                    {
                        string trasactionno = TransactionID();
                        string sysIPaddress = GetIPAddress();
                        Int32  userID       = Convert.ToInt32(Session["Customerid"]);

                        obj_wallet.UpdateCustomerWalletFundtransfer(Convert.ToDecimal(txtAmount.Text), userID);

                        obj_wallet.AddFundTransferDetail(trasactionno, userID, Session["UserIdenfifyNo"].ToString(), Session["BeneName"].ToString(), Session["BeneAccount"].ToString(), Session["BeneficiaryType"].ToString(), Session["IfscCode"].ToString(), Session["MobileNo"].ToString(), Convert.ToDecimal(Session["TransferAmount"]), sysIPaddress);

                        string mobile = Session["MobileNo"].ToString();
                        SendMsg(mobile);
                        string requeststatus = "Amount Transfered";

                        BindUserWalletDetails(Convert.ToString(userID));
                        Session["transactiontype"] = "Withdrawal Amount";
                        int logid = Convert.ToInt32(Session["userid"]);
                        obj_wallet.DeductCustomerWalletAmt(Convert.ToInt32(Session["walletid"]), userID, Convert.ToDecimal(Session["walletamount"]), Convert.ToDecimal(Session["TransferAmount"]), trasactionno, Session["transactiontype"].ToString(), requeststatus, Session["Customername"].ToString(), Session["CustEmailid"].ToString(), logid, Session["UserIdenfifyNo"].ToString());
                        obj_wallet.UpdateCustomerWalletFundtransfer(Convert.ToDecimal(Session["TransferAmount"]), logid);

                        bool    status        = true;
                        long    transaccont   = Convert.ToInt64(Session["BeneAccount"]);
                        decimal tranferamount = Convert.ToDecimal(Session["TransferAmount"]);
                        string  requestid     = Convert.ToString(Session["RequestID"]);
                        if (Session["RequestID"] != null)
                        {
                            obj_wallet.UpdateCustomerFundTransferStatus(status, tranferamount, transaccont, requeststatus, requestid);
                        }

                        lblMessage.ForeColor       = Color.Green;
                        lblMessage.Text            = "Amount Transfer Successfully!";
                        Session["MobileNo"]        = null;
                        Session["BeneAccount"]     = null;
                        Session["BeneName"]        = null;
                        Session["IfscCode"]        = null;
                        Session["BeneficiaryType"] = null;
                        Session["TransferAmount"]  = null;
                        Session["Customerid"]      = null;
                        Session["TranferOTP"]      = null;
                        txtAmount.Text             = "";
                        Session["RequestUserid"]   = null;
                        Session["RequestID"]       = null;
                        Session["RequestAmount"]   = null;

                        Session["TranferOTP"]        = null;
                        Session["txtCodeTranferOTP"] = null;
                    }
                    if (errormsg != null)
                    {
                        lblMessage.ForeColor = Color.Red;
                        lblMessage.Text      = errormsg;
                    }
                }
            }
            else
            {
                lblMessage.ForeColor = Color.Red;
                lblMessage.Text      = "OTP entered is incorrect";
            }
        }
        catch
        { }
    }