/// <summary>
        /// چنانچه کلید تایید زده شود درخواست ارسال گردیده و در دیتابیس ثبت می شود
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btn_taeid_Click(object sender, EventArgs e)
        {
            if (!canRequest())
            {
                return;
            }
            if (string.IsNullOrEmpty(txt_JahateErae.Text.Trim()) && grd_AcceptEdit.Items.Count <= 0)
            {
                Session["RequestIdArray"] = null;
                Session["EraeBeArray"]    = null;

                rwm_Validations.RadAlert("امکان خالی بودن جهت ارائه به وجود ندارد", null, 100, "خطا", null);
                return;
            }
            if (!string.IsNullOrEmpty(txt_JahateErae.Text))
            {
                if (Session["EraeBeArray"] != null)
                {
                    Session["EraeBeArray"] = Session["EraeBeArray"].ToString() + "," + txt_JahateErae.Text;
                }
                else
                {
                    Session["EraeBeArray"] = txt_JahateErae.Text;
                }
            }

            CommonBusiness cmnb = new CommonBusiness();
            var            dtgo = GovahiBusiness.GetGovahiStatus(Session[sessionNames.userID_StudentOstad].ToString());

            MashmulNumber = "";
            if (dtgo.Rows.Count > 0)
            {
                for (int i = 0; i < dtgo.Rows.Count; i++)
                {
                    if (dtgo.Rows[i]["MashmulNumber"].ToString() != "")
                    {
                        MashmulNumber = dtgo.Rows[i]["MashmulNumber"].ToString();
                        break;
                    }
                }
            }

            var eraeBeArray = Session["EraeBeArray"].ToString().Split(new char[] { ',' });

            var  requestId      = 0;
            int  countRequest   = 0;
            long mablagh        = 120000 + (eraeBeArray.Length * 20000);
            var  studentBalance = _walletBusiness.GetStudentCurrentBalance(Session[sessionNames.userID_StudentOstad].ToString());

            if (studentBalance >= mablagh)
            {
                for (var i = 0; i < eraeBeArray.Length; i++)
                {
                    if (Session["RequestIdArray"] != null)
                    {
                        var isEreaBeExists = business.CheckEraeBeExist(Session[sessionNames.userID_StudentOstad].ToString(), 3, 6, eraeBeArray[i]);
                        if (!isEreaBeExists)
                        {
                            requestId = int.Parse(business.InsertInToStudentRequest(Session[sessionNames.userID_StudentOstad].ToString(), 3, 6, eraeBeArray[i], MashmulNumber, 1).ToString());
                            Session["RequestIdArray"] = Session["RequestIdArray"] + "," + requestId;
                        }
                        else
                        {
                            rwm_Validations.RadAlert("این درخواست قبلا برای شما ثبت شده است.", 300, 100, "پیام سیستم", "RedirectToGovahiVaziatUI");
                            return;//با این خط کد، اگه هر تعدادی درخواست رو ثبت کرده باشه و آخری تکراری باشه، کلا از پرداخت صرف نظر میشه!!
                        }
                    }

                    else
                    {
                        var isEreaBeExists = business.CheckEraeBeExist(Session[sessionNames.userID_StudentOstad].ToString(), 3, 6, eraeBeArray[i]);
                        if (!isEreaBeExists)
                        {
                            requestId = int.Parse(business.InsertInToStudentRequest(Session[sessionNames.userID_StudentOstad].ToString(), 3, 6, eraeBeArray[i], MashmulNumber, 1).ToString());
                            Session["RequestIdArray"] = requestId.ToString();
                        }
                        else
                        {
                            rwm_Validations.RadAlert("این درخواست قبلا برای شما ثبت شده است.", 300, 100, "پیام سیستم", "RedirectToGovahiVaziatUI");
                            return;//با این خط کد، اگه هر تعدادی درخواست رو ثبت کرده باشه و آخری تکراری باشه، کلا از پرداخت صرف نظر میشه!!
                        }
                    }
                    if (requestId != 0)
                    {
                        countRequest++;
                    }
                }
            }
            else
            {
                rwm_Validations.RadAlert("موجودی کیف پول شما برای ثبت این درخواست کافی نیست.", 300, 100, "پیام سیستم", "RedirectToGovahiVaziatUI");
                return;
            }
            mablagh = 0;
            if (countRequest > 0)
            {
                mablagh = 120000 + (countRequest * 20000);

                var paymentStatus = GovahiBusiness.PaymentStatus(Session["RequestIdArray"].ToString(),
                                                                 Session[sessionNames.userID_StudentOstad].ToString());//??? 3tasho bargardoond

                if (paymentStatus.Any(x => x.HasBeenPaid))
                {
                    if (paymentStatus.All(x => x.HasBeenPaid))
                    {
                        var paymentByPastPayments = GovahiBusiness.PaymentByPastPayments(Session["RequestIdArray"].ToString(),
                                                                                         Session[sessionNames.userID_StudentOstad].ToString());

                        Session["RequestIdArray"] = null;
                        Session["EraeBeArray"]    = null;

                        rwm_Validations.RadAlert("شما به دلیل پرداخت قبلی نیاز به پرداخت ندارید", 300, 100, "پیام سیستم", "RedirectToGovahiVaziatUI");
                        return;
                    }
                    else
                    {
                        paymentStatus.ForEach(x =>
                        {
                            if (x.HasBeenPaid)
                            {
                                mablagh = mablagh - x.AmountTrans;
                            }
                        });
                    }
                }


                var msg         = string.Empty;
                var transaction = new TransactionDTO
                {
                    Amount            = mablagh,
                    stcode            = Session[sessionNames.userID_StudentOstad].ToString(),
                    TransactionTypeId = Convert.ToDecimal(TransactionTypeEnum.StudyingCertificate),
                };
                if (_walletBusiness.PayByWallet(transaction, out msg))
                {
                    var requestIdArray    = Session["RequestIdArray"].ToString().Split(new char[] { ',' });
                    var payByPastPayments = GovahiBusiness.PaymentByPastPayments(Session["RequestIdArray"].ToString(),
                                                                                 Session[sessionNames.userID_StudentOstad].ToString());//???
                    Session["paymentStatus"] = payByPastPayments;



                    bmp_PaymentBusiness bmp = new bmp_PaymentBusiness();
                    for (var j = 0; j < requestIdArray.Length; j++)
                    {
                        if (!(payByPastPayments[j].HasBeenPaid))
                        {
                            bmp.CreateRequestStudentPayment(new DTO.CommonClasses.PaymentDTO
                            {
                                Amount      = payByPastPayments[j].AmountTrans,
                                AppStatus   = "COMMIT",
                                Description = eraeBeArray[payByPastPayments[j].RowNumber - 1],
                                MiladiDate  = DateTime.Now,
                                tterm       = ConfigurationManager.AppSettings["Term"],
                                stcode      = Session[sessionNames.userID_StudentOstad].ToString(),
                                RequestId   = payByPastPayments[j].Number,
                                Result      = 0,
                                OrderId     = _walletBusiness.GenerateOrderIdForRequests(),
                                bankId      = 700,
                                TraceNumber = 0,
                                PayType     = 1,
                                ReqKey      = "WALLETPAYMENT",
                            });
                        }
                    }
                    cmnb.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_StudentOstad].ToString()), 15, requestId.ToString());
                    Session["RequestIdArray"] = null;
                    Session["EraeBeArray"]    = null;
                    rwm_Validations.RadAlert("پرداخت شما با موفقیت انجام گردید", null, 100, "گواهی اشتغال به تحصیل", "walletPaymentCallback");
                }
                else
                {
                    rwm_Validations.RadAlert(msg, null, 100, "گواهی اشتغال به تحصیل", "");
                }
            }
            #region
            //پرداخت مستقیم - حذف به علت جایگزینی روش پرداخت از طریق کیف پول - 990401

            /*
             * try
             * {
             *  long orderid;//= new bmp_PaymentBusiness().GenerateOrderId();
             *
             *
             *  SetDefaultDateTime();
             *  PaymentDTO pay = new PaymentDTO();
             *  bmp_PaymentBusiness bmp = new bmp_PaymentBusiness();
             *  pay.Amount = mablagh;
             *  pay.PayDate = PayDate + "_" + PayTime;
             *  pay.stcode = Session[sessionNames.userID_StudentOstad].ToString();
             *  pay.bankId = 2;
             *  pay.tterm = ConfigurationManager.AppSettings["Term"];
             *
             *  var result = bmp.pay(pay.Amount, pay.stcode, out orderid, Convert.ToInt32(Session[sessionNames.appID_StudentOstad]), 0);
             *  pay.OrderId = orderid;
             *      //bpService.bpPayRequest(long.Parse(TerminalId),
             *      //UserName,
             *      //UserPassword,
             *      //pay.OrderId,
             *      //pay.Amount,
             *      //PayDate,
             *      //PayTime,
             *      //pay.stcode,
             *      //CallBackUrl, payerId);
             *
             *  String[] resultArray = result.Split(',');
             *
             *  //String[] resultArray = { "E5F656213D33E807", "E5F656213D33E805" };
             *
             *  pay.ReqKey = resultArray[1];
             *  pay.AppStatus = "none";
             *  pay.TraceNumber = 0;
             *  pay.Result = -1;
             *  pay.PayType = 1;
             *
             *  var requestIdArray = Session["RequestIdArray"].ToString().Split(new char[] { ',' });
             *
             *
             *  var paymentByPastPayments = GovahiBusiness.PaymentByPastPayments(Session["RequestIdArray"].ToString(),
             *      Session[sessionNames.userID_StudentOstad].ToString());
             *
             *  Session["paymentStatus"] = paymentByPastPayments;
             *
             *  for (var j = 0; j < requestIdArray.Length; j++)
             *  {
             *      if (!(paymentByPastPayments[j].HasBeenPaid))
             *      {
             *          pay.Amount = paymentByPastPayments[j].AmountTrans;
             *          pay.Description = eraeBeArray[paymentByPastPayments[j].RowNumber - 1];
             *          pay.RequestId = paymentByPastPayments[j].Number;
             *          bmp.CreateRequestStudentPayment(pay);
             *      }
             *  }
             *
             *
             *  cmnb.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_StudentOstad].ToString()), 15, requestId.ToString());
             *
             *
             *  if (resultArray[0] == "0")
             *      ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", "<script language='javascript' type='text/javascript'> postRefId('" + resultArray[1] + "');</script> ", false);
             *  Session["RequestIdArray"] = null;
             *  Session["EraeBeArray"] = null;
             *
             * }
             * catch (Exception exp)
             * {
             *  Response.Write("Error: " + exp.Message);
             * }
             */
            #endregion
        }
        protected void btn_pardakht_Click(object sender, EventArgs e)
        {
            CommonBusiness cmnb      = new CommonBusiness();
            int            requestID = int.Parse(CartBusiness.InsertInToStudentRequest(Session[sessionNames.userID_StudentOstad].ToString(), 1, 6, "Null", "", 1).ToString());

            var msg         = string.Empty;
            var transaction = new TransactionDTO
            {
                Amount            = 140000,
                stcode            = Session[sessionNames.userID_StudentOstad].ToString(),
                TransactionTypeId = Convert.ToDecimal(TransactionTypeEnum.StudentCardPurchase),
                Description       = "درخواست شماره " + requestID
            };

            if (_walletBusiness.PayByWallet(transaction, out msg))
            {
                cmnb.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_StudentOstad].ToString()), 14, requestID.ToString());
                bmp_PaymentBusiness bmp = new bmp_PaymentBusiness();
                bmp.CreateRequestStudentPayment(new DTO.CommonClasses.PaymentDTO {
                    Amount      = Convert.ToInt64(transaction.Amount),
                    AppStatus   = "COMMIT",
                    Description = "پرداخت هزینه ارسال کارت دانشجویی از طریق کیف پول",
                    MiladiDate  = DateTime.Now,
                    tterm       = ConfigurationManager.AppSettings["Term"],
                    stcode      = Session[sessionNames.userID_StudentOstad].ToString(),
                    RequestId   = requestID,
                    Result      = 0,
                    OrderId     = _walletBusiness.GenerateOrderIdForRequests(),
                    bankId      = 700,
                    TraceNumber = 0,
                    PayType     = 2,
                    ReqKey      = "WALLETPAYMENT",
                });
                rwm_Validations.RadAlert("درخواست شما با موفقیت ثبت گردید؛ کد رهگیری درخواست: " + requestID, null, 100, "درخواست کارت دانشجویی", "walletPaymentCallback");
            }
            else
            {
                rwm_Validations.RadAlert(msg, null, 100, "درخواست کارت دانشجویی", "");
            }

            //پرداخت مستقیم - حذف به علت جایگزینی روش پرداخت از طریق کیف پول - 990401

            /*
             * try
             * {
             *  string result;
             *
             *  long orderid;//= new bmp_PaymentBusiness().GenerateOrderId();
             *
             *
             *  SetDefaultDateTime();
             *  PaymentDTO pay = new PaymentDTO();
             *  bmp_PaymentBusiness bmp = new bmp_PaymentBusiness();
             *  pay.Amount = Convert.ToInt64("140000");
             *  pay.PayDate = PayDate + "_" + PayTime;
             *  pay.stcode = Session[sessionNames.userID_StudentOstad].ToString();
             *  pay.bankId = 2;
             *  pay.tterm = ConfigurationManager.AppSettings["Term"];
             *  pay.Description = "درخواست کارت";
             *
             *
             *  //PaymentGatewayImplService bpService = new PaymentGatewayImplService();
             *  //long PayerId = long.Parse(pay.stcode + (new bmp_PaymentBusiness().PayerIdGenerator(pay.stcode).ToString()));
             *  var terminalIDD = string.IsNullOrWhiteSpace(TerminalId) ? "-1" : TerminalId;
             *  //var a = 1;
             *  result = bmp.pay(pay.Amount, pay.stcode, out orderid, Convert.ToInt32(Session[sessionNames.appID_StudentOstad]), 0);
             *  pay.OrderId = orderid;
             *
             *  //bpService.bpPayRequest(Int64.Parse(terminalIDD),
             *  //UserName,
             *  //UserPassword,
             *  //pay.OrderId,
             *  //pay.Amount,
             *  //PayDate,
             *  //PayTime,
             *  //pay.stcode,
             *  //CallBackUrl, PayerId);
             *
             *  String[] resultArray = result.Split(',');
             *  try
             *  {
             *      pay.ReqKey = resultArray[1];
             *
             *  }
             *  catch (Exception xx)
             *  {
             *      var errr = string.Format("{0} ", xx.Message);
             *      rwm_Validations.RadAlert(errr, null, 100, "پیام", "");
             *      return;
             *      //throw;
             *  }
             *  pay.AppStatus = "none";
             *  pay.TraceNumber = 0;
             *  pay.Result = -1;
             *  pay.PayType = 2;
             *  pay.Description = "";
             *  pay.RequestId = requestID;
             *  bmp.CreateRequestStudentPayment(pay);
             *
             *
             *  cmnb.InsertIntoStudentLog(Session[sessionNames.userID_StudentOstad].ToString(), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_StudentOstad].ToString()), 14, requestID.ToString());
             *
             *  if (resultArray[0] == "0")
             *      ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", "<script language='javascript' type='text/javascript'> postRefId('" + resultArray[1] + "');</script> ", false);
             * }
             * catch (Exception exp)
             * {
             *  Response.Write("Error: " + exp.Message);
             * }
             */
        }