protected void btnSubmit_Click(object sender, EventArgs e)
    {
        #region initialiseVariables
        int    intProcessSerialId = 0;
        string strProcessId       = Guid.NewGuid().ToString().ToUpper();
        string strPageName        = "Withdrawal.BankTransfer";

        string strResultCode    = string.Empty;
        string strResultDetail  = string.Empty;
        string strErrorCode     = string.Empty;
        string strErrorDetail   = string.Empty;
        string strProcessRemark = string.Empty;
        bool   isProcessAbort   = false;
        bool   isSystemError    = false;

        long   lngOperatorId     = long.MinValue;
        string strWithdrawAmount = string.Empty;
        string strBankCode       = string.Empty;
        string strBankName       = string.Empty;
        string strBankNameInput  = string.Empty;
        string strBankBranch     = string.Empty;
        string strBankAddress    = string.Empty;
        string strAccountName    = string.Empty;
        string strAccountNumber  = string.Empty;
        string strMyKad          = string.Empty;
        string strMobileNumber   = string.Empty;
        bool   MobileNotify      = false;

        decimal decMinLimit     = decimal.Zero;
        decimal decMaxLimit     = decimal.Zero;
        decimal decTotalAllowed = decimal.Zero;
        decimal decDailyLimit   = decimal.Zero;

        System.Xml.Linq.XElement xeResponse = null;

        bool   isWithdrawSuccessful = false;
        string strTransferId        = string.Empty;

        bool sessionExpired = false;
        #endregion

        #region populateVariables
        lngOperatorId   = long.Parse(commonVariables.OperatorId);
        strMemberCode   = commonVariables.GetSessionVariable("MemberCode");
        strCurrencyCode = commonVariables.GetSessionVariable("CurrencyCode");

        strWithdrawAmount = txtAmount.Value;
        strBankCode       = drpBank.Value;
        strBankName       = drpBank.Items.FindByValue(strBankCode).Text;
        strBankNameInput  = txtBankName.Value;
        strBankAddress    = txtAddress.Value;
        strBankBranch     = txtBankBranch.Value;
        strAccountName    = txtAccountName.Value;
        strAccountNumber  = txtAccountNumber.Value;
        strMyKad          = txtMyKad.Value;

        System.Text.RegularExpressions.Regex regxATM = new System.Text.RegularExpressions.Regex("([0-9]{16})$");

        #endregion

        #region parametersValidation
        if (string.IsNullOrEmpty(strWithdrawAmount))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/MissingWithdrawalAmount", xeErrors); return;
        }
        else if (string.IsNullOrEmpty(strAccountName))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/MissingAccountName", xeErrors); return;
        }
        else if (string.IsNullOrEmpty(strAccountNumber))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/MissingAccountNumber", xeErrors); return;
        }
        else if (string.Compare(drpBank.Value, "OTHER", true) == 0 && string.IsNullOrEmpty(strBankNameInput))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/MissingBankName", xeErrors); return;
        }
        //else if (string.Compare(drpBank.SelectedValue, "VIETIN", true) == 0 && (!commonValidation.isNumeric(strAccountNumber) || !regxATM.IsMatch(strAccountNumber))) { strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidAccountNumber", xeErrors); return; }
        else if (string.IsNullOrEmpty(strBankBranch) && string.Compare(strCurrencyCode, "krw", true) != 0)
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/MissingBankBranch", xeErrors); return;
        }
        else if (string.IsNullOrEmpty(strBankAddress) && string.Compare(strCurrencyCode, "krw", true) != 0)
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/MissingBankAddress", xeErrors); return;
        }
        else if (string.Compare(strCurrencyCode, "myr", true) == 0)
        {
            if (string.IsNullOrEmpty(strMyKad))
            {
                strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/MissingAccountNumber", xeErrors); return;
            }
        }
        else if (Convert.ToString(drpBank.Value) == "-1")
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/SelectBank", xeErrors); return;
        }
        else if (!commonValidation.isDecimal(strWithdrawAmount))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidWithdrawAmount", xeErrors); return;
        }
        else if (Convert.ToDecimal(strWithdrawAmount) <= 0)
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidWithdrawAmount", xeErrors); return;
        }
        else if (commonValidation.isInjection(strWithdrawAmount))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidWithdrawAmount", xeErrors); return;
        }
        else if (commonValidation.isInjection(strBankNameInput))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidBankName", xeErrors); return;
        }
        else if (commonValidation.isInjection(strAccountName))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidAccountName", xeErrors); return;
        }
        else if (commonValidation.isInjection(strAccountNumber))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidAccountNumber", xeErrors); return;
        }
        else if (commonValidation.isInjection(strBankBranch))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidBankBranch", xeErrors); return;
        }
        else if (commonValidation.isInjection(strBankAddress))
        {
            strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/InvalidBankAddress", xeErrors); return;
        }
        else if (string.Compare(strCurrencyCode, "myr", true) == 0)
        {
            if (commonValidation.isInjection(strMyKad))
            {
                strAlertCode = "-1"; strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/MissingMyKad", xeErrors); return;
            }
        }
        else if (string.IsNullOrEmpty(strMemberCode))
        {
            strAlertCode    = "-1";
            strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/SessionExpired", xeErrors);
            isProcessAbort  = true;
            sessionExpired  = true;
        }
        else if (string.IsNullOrEmpty(strCurrencyCode))
        {
            strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/FundTransfer/SessionExpired", xeErrors);
            isProcessAbort  = true;
            sessionExpired  = true;
        }
        #endregion

        #region initialiseWithdrawal
        if (!isProcessAbort)
        {
            try
            {
                string strProcessCode = string.Empty;
                string strProcessText = string.Empty;

                System.Data.DataTable dtPaymentMethodLimits = null;

                using (svcPayMember.MemberClient svcInstance = new svcPayMember.MemberClient())
                {
                    dtPaymentMethodLimits = svcInstance.getMethodLimits(strOperatorId, strMemberCode, Convert.ToString(Convert.ToInt32(commonVariables.WithdrawalMethod.BankTransfer)), Convert.ToString(Convert.ToInt32(commonVariables.PaymentTransactionType.Withdrawal)), false, out strProcessCode, out strProcessText);

                    if (dtPaymentMethodLimits.Rows.Count > 0)
                    {
                        decMinLimit     = Convert.ToDecimal(dtPaymentMethodLimits.Rows[0]["minWithdrawal"]);
                        decMaxLimit     = Convert.ToDecimal(dtPaymentMethodLimits.Rows[0]["maxWithdrawal"]);
                        decTotalAllowed = Convert.ToDecimal(dtPaymentMethodLimits.Rows[0]["totalAllowed"]);
                        decDailyLimit   = Convert.ToDecimal(dtPaymentMethodLimits.Rows[0]["limitDaily"]);

                        if (Convert.ToDecimal(strWithdrawAmount) < decMinLimit)
                        {
                            strAlertCode    = "-1";
                            strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/AmountMinLimit", xeErrors);
                            isProcessAbort  = true;
                        }
                        else if (Convert.ToDecimal(strWithdrawAmount) > decMaxLimit)
                        {
                            strAlertCode    = "-1";
                            strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/AmountMaxLimit", xeErrors);
                            isProcessAbort  = true;
                        }
                        else if (Convert.ToDecimal(strWithdrawAmount) > decTotalAllowed)
                        {
                            strAlertCode    = "-1";
                            strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/TotalAllowedExceeded", xeErrors);
                            isProcessAbort  = true;
                        }
                    }
                }

                if (!isProcessAbort)
                {
                    using (svcPayWithdrawal.WithdrawalClient svcInstance = new svcPayWithdrawal.WithdrawalClient())
                    {
                        xeResponse = svcInstance.createBankTransferTransactionV1(lngOperatorId, strMemberCode, Convert.ToInt64(commonVariables.WithdrawalMethod.BankTransfer),
                                                                                 strCurrencyCode, Convert.ToDecimal(strWithdrawAmount), strAccountName, strAccountNumber, strBankAddress, strBankBranch, strBankCode, strBankName, strBankNameInput,
                                                                                 strMyKad, strMobileNumber, MobileNotify, Convert.ToString(commonVariables.TransactionSource.Wap));

                        if (xeResponse == null)
                        {
                            strAlertCode    = "-1";
                            strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/TransferFail", xeErrors);
                        }
                        else
                        {
                            isWithdrawSuccessful = Convert.ToBoolean(commonCulture.ElementValues.getResourceString("result", xeResponse));
                            strTransferId        = commonCulture.ElementValues.getResourceString("invId", xeResponse);

                            if (isWithdrawSuccessful)
                            {
                                strAlertCode      = "0";
                                strAlertMessage   = string.Format("{0}\\n{1}: {2}", commonCulture.ElementValues.getResourceXPathString("/Withdrawal/TransferSuccess", xeErrors), commonCulture.ElementValues.getResourceString("lblTransactionId", xeResources), strTransferId);
                                btnSubmit.Visible = false;
                                btnBack.Value     = commonCulture.ElementValues.getResourceString("home", commonVariables.LeftMenuXML);
                            }
                            else
                            {
                                strAlertCode    = "-1";
                                strAlertMessage = string.Format("{0}\\n{1}", commonCulture.ElementValues.getResourceXPathString("/Withdrawal/TransferFail", xeErrors), commonCulture.ElementValues.getResourceXPathString("/Withdrawal/error" + strTransferId, xeErrors));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                strAlertCode    = "-1";
                strAlertMessage = commonCulture.ElementValues.getResourceXPathString("/Withdrawal/Exception", xeErrors);

                strErrorDetail = ex.Message;
            }

            strProcessRemark = string.Format("OperatorId: {0} | MemberCode: {1} | CurrencyCode: {2} | WithdrawAmount: {3} | AccountName: {4} | AccountNumber: {5} | BankAddress: {6} | BankBranch: {7} | BankCode: {8} | BankName: {9} | BankNameInput: {10} | MyKad: {11} | Mobile: {12} | MinLimit: {13} | MaxLimit: {14} | TotalAllowed: {15} | DailyLimit: {16} | Response: {17}",
                                             lngOperatorId, strMemberCode, strCurrencyCode, strWithdrawAmount, strAccountName, strAccountNumber, strBankAddress, strBankBranch, strBankCode, strBankName, strBankNameInput, strMyKad, strMobileNumber, decMinLimit, decMaxLimit, decTotalAllowed, decDailyLimit, xeResponse == null ? string.Empty : xeResponse.ToString());

            intProcessSerialId += 1;
            commonAuditTrail.appendLog("system", strPageName, "InitiateWithdrawal", "DataBaseManager.DLL", strResultCode, strResultDetail, strErrorCode, strErrorDetail, strProcessRemark, Convert.ToString(intProcessSerialId), strProcessId, isSystemError);
        }
        #region Response
        txtMessage.InnerHtml = strAlertMessage.Replace("\\n", "<br />");
        #endregion

        #endregion

        if (sessionExpired)
        {
            Response.Redirect("/Expire");
        }
    }
示例#2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strWithdrawalAmount = txtAmount.Text.Trim();
        string strBankCode         = drpBank.SelectedValue;
        string strBankName         = drpBank.SelectedItem.Text;
        string strBankNameInput    = txtBankName.Text;
        string strBankAddress      = txtAddress.Text;
        string strBankBranch       = txtBankBranch.Text;
        string strAccountName      = txtAccountName.Text;
        string strAccountNumber    = txtAccountNumber.Text;
        string strMyKad            = string.Empty; //txtMyKad.Text;

        decimal decWithdrawalAmount = commonValidation.isDecimal(strWithdrawalAmount) ? Convert.ToDecimal(strWithdrawalAmount) : 0;
        decimal decMinLimit         = commonValidation.isDecimal(strMinLimit) ? Convert.ToDecimal(strMinLimit) : 0;
        decimal decMaxLimit         = commonValidation.isDecimal(strMaxLimit) ? Convert.ToDecimal(strMaxLimit) : 0;

        bool useV2          = false;
        long BankLocationId = 0;
        long BankBranchId   = 0;

        #region initialiseWithdrawal

        CommonStatus status = new CommonStatus();

        try
        {
            //if (string.Compare(strCurrencyCode, "myr", true) == 0)
            //{
            //    if (string.IsNullOrEmpty(strMyKad))
            //    {
            //        status = base.GetErrors("/MissingMyKad");
            //    }
            //    else if (commonValidation.isInjection(strMyKad))
            //    {
            //        status = base.GetErrors("/InvalidMyKad");
            //    }
            //} else
            if (decWithdrawalAmount == 0)
            {
                status = base.GetErrors("/MissingWithdrawAmount");
            }
            else if (commonValidation.isInjection(strWithdrawalAmount))
            {
                status = base.GetErrors("/InvalidWithdrawAmount");
            }
            else if (string.IsNullOrEmpty(strAccountName))
            {
                status = base.GetErrors("/MissingAccountName");
            }
            else if (commonValidation.isInjection(strAccountName))
            {
                status = base.GetErrors("/InvalidAccountName");
            }
            else if (string.IsNullOrEmpty(strAccountNumber))
            {
                status = base.GetErrors("/MissingAccountNumber");
            }
            else if (commonValidation.isInjection(strAccountNumber))
            {
                status = base.GetErrors("/InvalidAccountNumber");
            }
            else if (Convert.ToString(drpBank.SelectedValue) == "-1")
            {
                status = base.GetErrors("/SelectBank");
            }
            else if (decWithdrawalAmount < decMinLimit)
            {
                status = base.GetErrors("/AmountMinLimit");
            }
            else if (decWithdrawalAmount > decMaxLimit)
            {
                status = base.GetErrors("/AmountMaxLimit");
            }
            else if ((strTotalAllowed != commonCulture.ElementValues.getResourceString("unlimited", xeResources)) && (decWithdrawalAmount > Convert.ToDecimal(strTotalAllowed)) && Convert.ToDecimal(strTotalAllowed) > 0)
            {
                status = base.GetErrors("/TotalAllowedExceeded");
            }

            var otherBankCode = drpSecondaryBank.SelectedItem != null ? drpSecondaryBank.SelectedItem.Value : "";
            if (strBankCode == "OTHER")
            {
                if (commonCookie.CookieCurrency.ToLower() == "vnd")
                {
                    if (otherBankCode == "-1")
                    {
                        status = base.GetErrors("/MissingSelectBankName");
                    }
                    else if (!commonValidation.isNumeric(hfBLId.Value) || commonValidation.isInjection(hfBLId.Value))
                    {
                    }
                    else if (hfBLId.Value == "-1")
                    {
                        status = base.GetErrors("/MissingSelectBankLocation");
                    }
                    else if (hfBBId.Value == "-1")
                    {
                        status = base.GetErrors("/MissingSelectBankBranch");
                    }
                    else if (!commonValidation.isNumeric(hfBBId.Value) || commonValidation.isInjection(hfBBId.Value))
                    {
                        status = base.GetErrors("/InvalidBankBranch");
                    }
                }
            }
            else
            {
                if (string.IsNullOrEmpty(strBankBranch) && string.Compare(strCurrencyCode, "krw", true) != 0)
                {
                    status = base.GetErrors("/MissingBankBranch");
                }
                else if (commonValidation.isInjection(strBankBranch))
                {
                    status = base.GetErrors("/InvalidBankBranch");
                }
                else if (string.IsNullOrEmpty(strBankAddress) && string.Compare(strCurrencyCode, "krw", true) != 0)
                {
                    status = base.GetErrors("/MissingBankAddress");
                }
                else if (commonValidation.isInjection(strBankAddress))
                {
                    status = base.GetErrors("/InvalidBankAddress");
                }
                else if (string.Compare(drpBank.SelectedValue, "OTHER", true) == 0 && string.IsNullOrEmpty(strBankNameInput))
                {
                    status = base.GetErrors("/MissingBankName");
                }
                else if (commonValidation.isInjection(strBankNameInput))
                {
                    status = base.GetErrors("/InvalidBankName");
                }
            }

            if (!status.IsProcessAbort)
            {
                if (commonCookie.CookieCurrency.ToLower() == "vnd" && !drpSecondaryBank.SelectedItem.Value.Equals("-1") && !drpSecondaryBank.SelectedItem.Value.Equals("OTHER"))
                {
                    strBankCode      = SecondaryBankCode[drpSecondaryBank.SelectedItem.Value];
                    strBankName      = drpSecondaryBank.SelectedItem.Text;
                    strBankNameInput = drpSecondaryBank.SelectedItem.Text;
                    BankLocationId   = Convert.ToInt64(hfBLId.Value);
                    BankBranchId     = Convert.ToInt64(hfBBId.Value);
                    useV2            = true;
                }

                using (var svcInstance = new svcPayWithdrawal.WithdrawalClient())
                {
                    if (useV2)
                    {
                        xeResponse = svcInstance.createBankTransferTransactionV2(Convert.ToInt64(strOperatorId),
                                                                                 strMemberCode, Convert.ToInt64(commonVariables.WithdrawalMethod.BankTransfer),
                                                                                 strCurrencyCode, decWithdrawalAmount, strAccountName, strAccountNumber, BankLocationId,
                                                                                 BankBranchId, strBankCode, strBankName, strBankNameInput, string.Empty, string.Empty, false,
                                                                                 Convert.ToString(commonVariables.TransactionSource.Mobile));
                    }
                    else
                    {
                        xeResponse = svcInstance.createBankTransferTransactionV1(Convert.ToInt64(strOperatorId),
                                                                                 strMemberCode, Convert.ToInt64(commonVariables.WithdrawalMethod.BankTransfer),
                                                                                 strCurrencyCode, decWithdrawalAmount, strAccountName, strAccountNumber, strBankAddress,
                                                                                 strBankBranch, strBankCode, strBankName, strBankNameInput,
                                                                                 strMyKad, string.Empty, false, Convert.ToString(commonVariables.TransactionSource.Mobile));
                    }

                    if (xeResponse == null)
                    {
                        status = base.GetErrors("/TransferFail");
                    }
                    else
                    {
                        bool   isTransactionSuccessful = Convert.ToBoolean(commonCulture.ElementValues.getResourceString("result", xeResponse));
                        string strTransferId           = commonCulture.ElementValues.getResourceString("invId", xeResponse);

                        if (isTransactionSuccessful)
                        {
                            status.AlertCode    = "0";
                            status.AlertMessage = string.Format("{0}\\n{1}: {2}", commonCulture.ElementValues.getResourceXPathString(base.PaymentType.ToString() + "/TransferSuccess", xeErrors), strlblTransactionId, strTransferId);
                        }
                        else
                        {
                            status = GetErrors("/TransferFail", strTransferId, "/error");
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            status = base.GetErrors("/Exception");

            strErrorDetail = ex.Message;
        }

        strAlertCode    = status.AlertCode;
        strAlertMessage = status.AlertMessage;

        string strProcessRemark = string.Format("OperatorId: {0} | MemberCode: {1} | CurrencyCode: {2} | WithdrawAmount: {3} | AccountName: {4} | AccountNumber: {5} | BankAddress: {6} | BankBranch: {7} | BankCode: {8} | BankName: {9} | BankNameInput: {10} | BankLocationId: {11} | BankBranchId: {12} | MyKad: {13} | Mobile: {14} | MinLimit: {15} | MaxLimit: {16} | TotalAllowed: {17} | DailyLimit: {18} | Response: {19}",
                                                Convert.ToInt64(strOperatorId), strMemberCode, strCurrencyCode, strWithdrawalAmount, strAccountName, strAccountNumber, strBankAddress, strBankBranch, strBankCode, strBankName, strBankNameInput, BankLocationId, BankBranchId, strMyKad, string.Empty, decMinLimit, decMaxLimit, strTotalAllowed, strDailyLimit, xeResponse == null ? string.Empty : xeResponse.ToString());

        intProcessSerialId += 1;
        commonAuditTrail.appendLog("system", PageName, "InitiateWithdrawal", "DataBaseManager.DLL", strResultCode, strResultDetail, strErrorCode, strErrorDetail, strProcessRemark, Convert.ToString(intProcessSerialId), strProcessId, isSystemError);

        #endregion
    }