using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Xml.Serialization;
using Newtonsoft.Json;
//using System.Windows.Forms;
using System.Web.Script.Serialization;
using CheckBox = System.Web.UI.WebControls.CheckBox;
public partial class Admin_ManagePineGTVStatus : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       if (!IsPostBack)
        {
            lblMsg.Text = "";
            lblResponse.Text = "";
            BOGTVDetail.GTVResponseCard objdata = new BOGTVDetail.GTVResponseCard() ;
            //objdata = null;
            ViewState["GTVResponse"] = objdata;
        }
       
    }
    
    
    public void GetPendingBillPostDetail(string BillRefID)
    {
        SqlParameter[] warlock = new SqlParameter[]
        {
         new SqlParameter("@RefId", BillRefID)
        };
        DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "usp_GetCompleteDetailsOfTxnID", warlock);
        if (ds.Tables[0].Rows.Count > 0)
        {
            gvPndTxn.DataSource = ds.Tables[0];
            gvPndTxn.DataBind();
           
        }
        else
        {
            gvPndTxn.DataSource = null;
            gvPndTxn.DataBind();
        }
        
    }
    
   

   
    public void InsertServiceRequestResponseLog(string MethodName, string RequestLog, string ResponseLog)
    {
        try
        {
            SqlParameter[] warlock = new SqlParameter[]
            {
                new SqlParameter("@MethodName", MethodName),
                new SqlParameter("@RequestLog", RequestLog),
                new SqlParameter("@ResponseLog", ResponseLog)
            };
            SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "usp_Insert_ServiceRequestResponseLog", warlock);
        }
        catch (Exception ex)
        {
            throw ex;

        }
    }
    public void UpdateConsumerBillDetail(string TxnId, string ReceiptNo)
    {
        SqlParameter[] warlock = new SqlParameter[]
        {
                
                new SqlParameter("@TxnId",TxnId),
                new SqlParameter("@ReceiptNo",ReceiptNo)
        };
        SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, System.Data.CommandType.StoredProcedure, "usp_updateRepostPaymentStatus", warlock);
    }
    public int RefundTxnUnProcessedBill(string TxnId)
    {
        SqlParameter[] warlock = new SqlParameter[]
        {
                new SqlParameter("@TxnId",TxnId)
        };
       return SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, System.Data.CommandType.StoredProcedure, "usp_RejectTxn", warlock);
    }
    public bool CheckRefundValidation(string TxnId)
    {
        SqlParameter[] warlock = new SqlParameter[]
        {
                new SqlParameter("@TxnId",TxnId)
        };
        return  SqlHelper.checkExistance(SqlHelper.mainConnectionString, System.Data.CommandType.StoredProcedure, "usp_CheckTxnIsValid", warlock);
    }
    public string GetStatusElecticity(string TxnId, string amount, string LoginId, string ConsumerMobileNo, string PineRefId)
    {
        string Response = "";
        try
        {

            pineLab objpinelab = new pineLab();
            string result = objpinelab.PinelabPaymentStatus(PineRefId, amount);
            PineLabStatusResponse myDeserializedClass = JsonConvert.DeserializeObject<PineLabStatusResponse>(result);
            if (myDeserializedClass.ResponseMessage.ToUpper() == "SUCCESS")
            {
                if (myDeserializedClass.UPITxnData != null)
                {
                    if (myDeserializedClass.UPITxnData.TxnStatus.ToLower() == "pass")
                    {
                        UpdateCustomerPayment(TxnId,
                            myDeserializedClass.UPITxnData.RRN, myDeserializedClass.UPITxnData.HostTxnId,
                             "success", myDeserializedClass.UPITxnData.HostTID, myDeserializedClass.UPITxnData.HostMID, "", 
                            LoginId, myDeserializedClass.UPITxnData.TxnType, myDeserializedClass.UPITxnData.CustomerVPA);

                        Response = "Success";
                    }
                    
                    else if (myDeserializedClass.UPITxnData.TxnStatus.ToLower() == "fail")
                    {
                        UpdateCustomerPayment(TxnId,
                            myDeserializedClass.UPITxnData.RRN, myDeserializedClass.UPITxnData.HostTxnId,
                            "failed",  myDeserializedClass.UPITxnData.HostTID, myDeserializedClass.UPITxnData.HostMID, "", 
                            LoginId, myDeserializedClass.UPITxnData.TxnType, myDeserializedClass.UPITxnData.CustomerVPA);
                        Response = myDeserializedClass.UPITxnData.UPITxnStatusDesciption;
                    }
                }
                else if (myDeserializedClass.UPITxnData == null && myDeserializedClass.CardTxnData != null)
                {
                    if (myDeserializedClass.CardTxnData.TxnStatus.ToLower() == "pass")
                    {

                        UpdateCustomerPayment(TxnId,
                            myDeserializedClass.CardTxnData.RRN, myDeserializedClass.CardTxnData.TransactionLogId,
                            "success", myDeserializedClass.CardTxnData.BankTid, myDeserializedClass.CardTxnData.BankMid, myDeserializedClass.CardTxnData.CardHolderName, 
                            LoginId, myDeserializedClass.CardTxnData.CardType, myDeserializedClass.CardTxnData.MaskedPanNum);
                            //Response = myDeserializedClass.CardTxnData.ResponseMessage;
                            Response = "Success";
                        
                    }
                    else if (myDeserializedClass.CardTxnData.TxnStatus.ToLower() == "fail")
                    {
                        UpdateCustomerPayment(TxnId,
                                                    myDeserializedClass.CardTxnData.RRN, myDeserializedClass.CardTxnData.TransactionLogId,
                                                    "failed", myDeserializedClass.CardTxnData.BankTid, myDeserializedClass.CardTxnData.BankMid, myDeserializedClass.CardTxnData.CardHolderName,
                                                    LoginId, myDeserializedClass.CardTxnData.CardType, myDeserializedClass.CardTxnData.MaskedPanNum);
                        Response = myDeserializedClass.CardTxnData.ResponseMessage;
                    }
                    else if (myDeserializedClass.CardTxnData.TxnStatus.ToLower() == "pending")
                    {
                        if(myDeserializedClass.CardTxnData.ResponseMessage.ToLower() == "success")
                        {
                            UpdateCustomerPayment(TxnId,
                            myDeserializedClass.CardTxnData.RRN, myDeserializedClass.CardTxnData.TransactionLogId,
                            "success", myDeserializedClass.CardTxnData.BankTid, myDeserializedClass.CardTxnData.BankMid, myDeserializedClass.CardTxnData.CardHolderName,
                            LoginId, myDeserializedClass.CardTxnData.CardType, myDeserializedClass.CardTxnData.MaskedPanNum);
                            //Response = myDeserializedClass.CardTxnData.ResponseMessage;
                            Response = "Success";
                        }
                        
                    }

                }


            }
            else
            {
                Response = myDeserializedClass.ResponseMessage;
            }
        }
        catch (Exception ex)
        {
            Response = ex.Message;
        }

        return Response;
    }

    public void UpdateCustomerPayment(string TxnId, string BankReferenceCode, string BankID,
            string PaymentStatus, string TerminalID, string MId, string cardonName
           , string LoginId, string Feild1, string Feild2)
    {
        SqlParameter[] warlock = new SqlParameter[]
        {
                new SqlParameter("@BankReferenceCode",BankReferenceCode),
                new SqlParameter("@BankID",BankID),
                new SqlParameter("@PaymentStatus",PaymentStatus),
                new SqlParameter("@cardTxnTypeDesc",""),
                new SqlParameter("@TerminalID",TerminalID),
                new SqlParameter("@MId",MId),
                new SqlParameter("@nameOnCard",cardonName),
                new SqlParameter("@LoginId",LoginId),
                new SqlParameter("@Feild1",Feild1),
                new SqlParameter("@Feild2",Feild2),
                new SqlParameter("@TxnID",TxnId)
        };
        SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, System.Data.CommandType.StoredProcedure, "usp_UpdatePaymentPipe", warlock);
    }

    public string GetStatus(string TxnId,string amount,string LoginId,string ConsumerMobileNo,string PineRefId)
    {
        string Response = "";
        try
        {
         
            pineLab objpinelab = new pineLab();
            string result = objpinelab.PinelabPaymentStatus(PineRefId, amount);
            PineLabStatusResponse myDeserializedClass = JsonConvert.DeserializeObject<PineLabStatusResponse>(result);
            if (myDeserializedClass.ResponseMessage.ToUpper()=="SUCCESS")
            {
                if (myDeserializedClass.UPITxnData != null)
                {
                    if(myDeserializedClass.UPITxnData.TxnStatus.ToLower()=="pass")
                    {
                        int status1 = InsertTransactionWithtopupStatus("", TxnId, LoginId, "Topup", "NBDCL",
                                    "102", "All", ConsumerMobileNo, Convert.ToString(amount), " ", "NBDCL", "Orangepay", "Topup");
                        if(status1!=1)
                        {
                            iNSERTtOTPUPBillDetail(TxnId, amount,
                            myDeserializedClass.UPITxnData.RRN, myDeserializedClass.UPITxnData.HostTxnId,
                            "UPI", "success", "success", "PINELABS", "", myDeserializedClass.UPITxnData.HostTID, myDeserializedClass.UPITxnData.HostMID, "", "AdminGetStatusProcess",
                            LoginId, myDeserializedClass.UPITxnData.TxnType, myDeserializedClass.UPITxnData.CustomerVPA, myDeserializedClass.UPITxnData.TxnDateTime, "", "", ConsumerMobileNo);

                            Response = "Success";
                        }
                        else if(myDeserializedClass.UPITxnData.TxnStatus.ToLower() == "pass")
                        {
                            iNSERTtOTPUPBillDetail(TxnId, amount,
                            myDeserializedClass.UPITxnData.RRN, myDeserializedClass.UPITxnData.HostTxnId,
                            "UPI", "success", "success", "PINELABS", "", myDeserializedClass.UPITxnData.HostTID, myDeserializedClass.UPITxnData.HostMID, "", "AdminGetStatusProcess",
                            LoginId, myDeserializedClass.UPITxnData.TxnType, myDeserializedClass.UPITxnData.CustomerVPA, myDeserializedClass.UPITxnData.TxnDateTime, "", "", ConsumerMobileNo);

                            Response = "Success";
                        }

                    }
                    else if(myDeserializedClass.UPITxnData.TxnStatus.ToLower() == "fail") 
                    {
                        iNSERTtOTPUPBillDetail(TxnId, amount,
                            myDeserializedClass.UPITxnData.RRN, myDeserializedClass.UPITxnData.HostTxnId,
                            "UPI", "failed", "failed", "PINELABS", "", myDeserializedClass.UPITxnData.HostTID, myDeserializedClass.UPITxnData.HostMID, "", "AdminGetStatusProcess",
                            LoginId, myDeserializedClass.UPITxnData.TxnType, myDeserializedClass.UPITxnData.CustomerVPA, myDeserializedClass.UPITxnData.TxnDateTime, "", "", ConsumerMobileNo);
                        Response = myDeserializedClass.UPITxnData.UPITxnStatusDesciption;
                    }
                }
                else if (myDeserializedClass.UPITxnData == null && myDeserializedClass.CardTxnData != null)
                {
                    if (myDeserializedClass.CardTxnData.TxnStatus.ToLower() == "pass")
                    {
                        int status1 = InsertTransactionWithtopupStatus("", TxnId, LoginId, "Topup", "NBDCL",
                                                            "102", "All", ConsumerMobileNo, Convert.ToString(amount), " ", "NBDCL", "Orangepay", "Topup");
                        if (status1 != 1)
                        {
                            iNSERTtOTPUPBillDetail(TxnId, amount,
                            myDeserializedClass.CardTxnData.RRN, myDeserializedClass.CardTxnData.TransactionLogId,
                            "CARD", "success", "success", "PINELABS", "", myDeserializedClass.CardTxnData.BankTid, myDeserializedClass.CardTxnData.BankMid, myDeserializedClass.CardTxnData.CardHolderName, "AdminGetStatusProcess",
                            LoginId, myDeserializedClass.CardTxnData.CardType, myDeserializedClass.CardTxnData.MaskedPanNum, myDeserializedClass.CardTxnData.TxnDateTime, "", "", ConsumerMobileNo);
                            Response = myDeserializedClass.CardTxnData.ResponseMessage;
                        }
                        else if (myDeserializedClass.CardTxnData.TxnStatus.ToLower() == "pass")
                        {
                            iNSERTtOTPUPBillDetail(TxnId, amount,
                            myDeserializedClass.CardTxnData.RRN, myDeserializedClass.CardTxnData.TransactionLogId,
                            "CARD", "success", "success", "PINELABS", "", myDeserializedClass.CardTxnData.BankTid, myDeserializedClass.CardTxnData.BankMid, myDeserializedClass.CardTxnData.CardHolderName, "AdminGetStatusProcess",
                            LoginId, myDeserializedClass.CardTxnData.CardType, myDeserializedClass.CardTxnData.MaskedPanNum, myDeserializedClass.CardTxnData.TxnDateTime, "", "", ConsumerMobileNo);
                            //Response = myDeserializedClass.CardTxnData.ResponseMessage;
                            Response = "Success";
                        }
                    }
                    else if(myDeserializedClass.CardTxnData.TxnStatus.ToLower() == "fail")
                    {
                        iNSERTtOTPUPBillDetail(TxnId, amount,
                                                    myDeserializedClass.CardTxnData.RRN, myDeserializedClass.CardTxnData.TransactionLogId,
                                                    "CARD", "failed", "failed", "PINELABS", "", myDeserializedClass.CardTxnData.BankTid, myDeserializedClass.CardTxnData.BankMid, myDeserializedClass.CardTxnData.CardHolderName, "AdminGetStatusProcess",
                                                    LoginId, myDeserializedClass.CardTxnData.CardType, myDeserializedClass.CardTxnData.MaskedPanNum, myDeserializedClass.CardTxnData.TxnDateTime, "", "", ConsumerMobileNo);
                        Response = myDeserializedClass.CardTxnData.ResponseMessage;
                    }
                    else if(myDeserializedClass.CardTxnData.TxnStatus.ToLower() == "pending")
                    {
                        if (myDeserializedClass.CardTxnData.ResponseMessage.ToLower() == "success")
                        {
                            int status1 = InsertTransactionWithtopupStatus("", TxnId, LoginId, "Topup", "NBDCL",
                                                                "102", "All", ConsumerMobileNo, Convert.ToString(amount), " ", "NBDCL", "Orangepay", "Topup");
                            if (status1 != 1)
                            {
                                iNSERTtOTPUPBillDetail(TxnId, amount,
                                myDeserializedClass.CardTxnData.RRN, myDeserializedClass.CardTxnData.TransactionLogId,
                                "CARD", "success", "success", "PINELABS", "", myDeserializedClass.CardTxnData.BankTid, myDeserializedClass.CardTxnData.BankMid, myDeserializedClass.CardTxnData.CardHolderName, "AdminGetStatusProcess",
                                LoginId, myDeserializedClass.CardTxnData.CardType, myDeserializedClass.CardTxnData.MaskedPanNum, myDeserializedClass.CardTxnData.TxnDateTime, "", "", ConsumerMobileNo);
                                Response = myDeserializedClass.CardTxnData.ResponseMessage;
                            }
                            
                        }
                    }
                        
                }
                
                
            }
            else
            {
                Response = myDeserializedClass.ResponseMessage;
            }
        }
        catch(Exception ex)
        {
            Response = ex.Message;
        }

        return Response;
    }
    public void iNSERTtOTPUPBillDetail(string TxnId, string PaidAmount, string BankReferenceCode, string BankID,
            string PaymentMode, string PaymentStatus, string PostingStatus, string Gateway, string cardTxnTypeDesc, string TerminalID, string MId, string cardonName, string Remarks
            , string LoginId, string Feild1, string Feild2, string paymentDate = "", string latitude = "", string longitude = "", string ConsumerMobileNo = "")
    {
        SqlParameter[] warlock = new SqlParameter[]
        {
                new SqlParameter("@TxnId",TxnId),
                new SqlParameter("@PaidAmount",Convert.ToDecimal(PaidAmount)),
                new SqlParameter("@BankReferenceCode",BankReferenceCode),
                new SqlParameter("@BankID",BankID),
                new SqlParameter("@PaymentMode",PaymentMode),
                new SqlParameter("@PaymentStatus",PaymentStatus),
                new SqlParameter("@Gateway",Gateway),
                new SqlParameter("@TerminalID",TerminalID),
                new SqlParameter("@MId",MId),
                new SqlParameter("@nameOnCard",cardonName),
                new SqlParameter("@Remarks",Remarks),
                new SqlParameter("@LoginId",LoginId),
                new SqlParameter("@Feild1",Feild1),
                new SqlParameter("@Feild2",Feild2),
                new SqlParameter("@PaymentDate",paymentDate),
                new SqlParameter("@ConsumerMobileNo",ConsumerMobileNo),
                new SqlParameter("@ConsumerName",cardonName),
                new SqlParameter("@RequestFor","Topup")
        };
        SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, System.Data.CommandType.StoredProcedure, "usp_UpdatePGPaymentDetail", warlock);
    }
    public int InsertTransactionWithtopupStatus(string Ipaddress, string RefNo, string AgentId, string Type, string Operator, string OperatotId, string Circle, string MobileNo, string Amount, string VendorTxnId, string ServiceVendor, string PortalName, string ServiceName)
    {
        SqlParameter[] InsertWithPendingStatusParam = new SqlParameter[]
        {
            new SqlParameter("@IPAddress",Ipaddress),
            new SqlParameter("@ReferenceNumber",RefNo),
            new SqlParameter("@AgentID",Convert.ToInt64(AgentId)),
            new SqlParameter("@Type",Type.ToString()),
            new SqlParameter("@Operater",Operator),
            new SqlParameter("@operatorID",Convert.ToInt32(OperatotId)),
            new SqlParameter("@Circle",Circle),
            new SqlParameter("@Mobileno",Convert.ToString(MobileNo)),
            new SqlParameter("@Amount",Convert.ToDecimal(Amount)),
            new SqlParameter("@cptransactionid",VendorTxnId),
            new SqlParameter("@ServiceVendor",ServiceVendor),
            new SqlParameter("@PortalName",PortalName),
            new SqlParameter("@SERVICE_NAME",ServiceName),
            new SqlParameter("@ErrorMessage",SqlDbType.Int)
        };
        InsertWithPendingStatusParam[13].Direction = ParameterDirection.Output;
        SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "InsertWalletTransactionForTopup", InsertWithPendingStatusParam);
        int result = Convert.ToInt32(InsertWithPendingStatusParam[13].Value);
        return result;
    }

    
    protected void btnFetchChargeSlipDetails_Click(object sender, EventArgs e)
    {
        if (txtChargeSlipNo.Text.Trim()=="")
        {
            Page.RegisterStartupScript("XXX", "<script> alert('Please the charge slip No')</script>");
            return;
        }
        else
        {
            GetGTVDetails(txtChargeSlipNo.Text,ddlPaymentMode.SelectedValue);
        }
    }
    public void GetGTVDetails(string ChargeSlipNo, string PaymentMode)
    {
        GTVProcess objGTVProcess = new GTVProcess();
        BOGTVDetail.GTVResponseCard objdata = objGTVProcess.GetGTVDetailsForChargeSlipNo(ChargeSlipNo, PaymentMode);
        ViewState["GTVResponse"]=objdata;
        lblResponse.Text = new JavaScriptSerializer().Serialize(objdata);
        if (objdata != null) {
            string billRefId = Convert.ToString(objdata.billRefNumber==null?"": objdata.billRefNumber);
            if(billRefId!="")
            {
                GetPendingBillPostDetail(billRefId);
            }
            else
            {
                lblMsg.Text = objdata.responseMessage=="null"?"Bill Reference Not Found": objdata.responseMessage;
            }
        }
        else
        {
            lblMsg.Text = objdata.responseMessage;
        }
    }
    protected void btnCustomerTopup_Click(object sender, EventArgs e)
    {
        try
        {
            //CommonFunction obj_ComFun = new CommonFunction();
            //ReProcess objRePro = new ReProcess();
            Boolean flag = true;
            foreach (GridViewRow rowItem in gvPndTxn.Rows)
            {
                //CheckBox chk1 = (CheckBox)(rowItem.Cells[0].FindControl("chkbox"));
                CheckBox chknew = (CheckBox)(rowItem.Cells[0].FindControl("chkboxNew"));
                if (chknew.Checked)
                {
                    string Response = "";
                    string MerTxn = Convert.ToString(gvPndTxn.DataKeys[rowItem.RowIndex].Values[0]);
                    string TxnAmt = Convert.ToString(gvPndTxn.DataKeys[rowItem.RowIndex].Values[1]);
                    string LoginId = Convert.ToString(gvPndTxn.DataKeys[rowItem.RowIndex].Values[2]);
                    string pineRefId = Convert.ToString(gvPndTxn.DataKeys[rowItem.RowIndex].Values[3]);
                    string PaymentStatus = Convert.ToString(gvPndTxn.DataKeys[rowItem.RowIndex].Values[4]);
                    string PaymentFor = Convert.ToString(gvPndTxn.DataKeys[rowItem.RowIndex].Values[5]);
                    BOGTVDetail.GTVResponseCard objdata = (BOGTVDetail.GTVResponseCard)ViewState["GTVResponse"];
                    if (PaymentFor.ToLower() == "topup")
                    {
                        if(PaymentStatus.ToLower()== "pending")
                        {
                            //Process for topup
                            
                            if (objdata != null)
                            {
                                if(objdata.transactionStatus.ToLower()=="success")
                                {
                                    int status1 = InsertTransactionWithtopupStatus("", MerTxn, LoginId, "Topup", "NBDCL",
                                    "102", "All", pineRefId, Convert.ToString(TxnAmt), " ", "NBDCL", "Orangepay", "Topup");
                                    if (status1 != 1)
                                    {
                                        iNSERTtOTPUPBillDetail(MerTxn, TxnAmt,
                                        objdata.rrn, objdata.transactionId,
                                        ddlPaymentMode.SelectedValue, "success", "success", "PINELABS", "", objdata.merchantDetails.tid, objdata.merchantDetails.mid, "", "AdminGTVStatusProcess",
                                        LoginId, objdata.transactionType, objdata.paymentDetails.customerVpa=="null"? objdata.paymentDetails.customerPaymentModeId: objdata.paymentDetails.customerVpa, objdata.transactionDate, "", "", pineRefId);

                                        //Response = "Success";
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = "GTV Transaction Status not in success";
                                }
                            }

                        }
                        else
                        {
                            lblMsg.Text = "Unable to process for topup.";
                        }
                    }
                    else if(PaymentFor.ToLower() == "billpayment")
                    {
                        if (PaymentStatus.ToLower() == "pending")
                        {
                            //Process for consumer paymentstatus success
                            if (objdata.transactionStatus.ToLower() == "success")
                            {
                                UpdateCustomerPayment(MerTxn, objdata.rrn
                            , objdata.transactionId,
                             "success", objdata.merchantDetails.tid, objdata.merchantDetails.mid, objdata.paymentDetails.customerName,
                            LoginId, objdata.transactionType, objdata.paymentDetails.customerVpa == "null" ? objdata.paymentDetails.customerPaymentModeId : objdata.paymentDetails.customerVpa);

                                GetPendingBillPostDetail(objdata.billRefNumber);
                            }
                            else
                            {
                                lblMsg.Text = "GTV Transaction Status not in success";
                            }
                        }
                        else
                        {
                            lblMsg.Text = "Unable to process for topup.";
                        }
                        //Response = GetStatusElecticity(MerTxn, TxnAmt, LoginId, MobileNo, pineRefId);
                    }


                    
                    lblMsg.ForeColor = System.Drawing.Color.Red;
                    flag = false;
                }
            }
            if (flag)
            {
                lblMsg.Text = "Please Select Any Transaction";
                lblMsg.ForeColor = System.Drawing.Color.Red;
            }
            
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }
}