public string SOA_Update_OVD ( string source_chanel, string in_cr_account_nbr, string nqh_code, string in_SS )
 {
     string result = "";
     TTTSOA.TrungTamThe tt = new TTTSOA.TrungTamThe();
     result = tt.SOA_Update_OVD ( source_chanel, in_cr_account_nbr, nqh_code, in_SS );
     return result;
 }
 public string SOA_Misc_Credit ( string source_chanel , string in_card_nbr,string in_amount, string in_desc, string in_SS )
 {
     string result = "";
     TTTSOA.TrungTamThe ttt = new TTTSOA.TrungTamThe ( );
     result = ttt.SOA_Misc_Credit ( source_chanel, in_card_nbr, in_amount, in_desc, in_SS );
     return result;
 }
 public string SOA_Update_Autopayment(string source_chanel, string in_cr_account_nbr, string in_autopayment_acc, string in_autopayment_flag, string in_SS)
 {
     string result = "";
     TTTSOA.TrungTamThe ttt = new TTTSOA.TrungTamThe();
     result = ttt.SOA_Update_Autopayment(source_chanel, in_cr_account_nbr, in_autopayment_acc, in_autopayment_flag, in_SS);
     return result;
 }
 public string SOA_Update_Vip_Flag(string source_chanel, string in_card_nbr, string type, string in_SS)
 {
     string result = "";
     TTTSOA.TrungTamThe ttt = new TTTSOA.TrungTamThe();
     result = ttt.SOA_Update_Vip_Flag(source_chanel, in_card_nbr, type, in_SS);
     return result;
 }
 public string SOA_Update_SMS_Flag(string source_chanel, string contract_nbr, string contract_type,string mobile_nbr, string type, string in_SS)
 {
     string result = "";
     TTTSOA.TrungTamThe ttt = new TTTSOA.TrungTamThe();
     result = ttt.SOA_Update_SMS_Flag(source_chanel, contract_nbr, contract_type, mobile_nbr, type, in_SS);
     return result;
 }
 public string SOA_Reset_Pin(string source_chanel, string in_card_nbr, string in_SS)
 {
     string result = "";
     TTTSOA.TrungTamThe ttt = new TTTSOA.TrungTamThe();
     result = ttt.SOA_Reset_Pin(source_chanel, in_card_nbr, in_SS);
     return result;
 }
    private void Authorize_FundTrans()
    {
        try
        {
            string sql = "", err = "";
            string //CARD_NUMBER = "",
            ACCOUNT_NUMBER = "";
            //card_nbr = (string)Session["Card_nbr"];
            string batch = ""; string ref_no_br = ""; string txn_amount = ""; string user_duyet = "";

            sql = "select * from nab_balance_prepaid_realtime a where a.ref_no='" + lb_ref_no_Fund_Tran.Text + "' and a.authorize='Y'";
            DataTable dtcheck = executedb.getTable(sql, ref err);

            if (err != "")
            {
                executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), sql + " --> " + err);
                Alert.Show("Error when executing from database!!!", this);
            }
            else
            {
                if (dtcheck.Rows.Count > 0)
                {
                    executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Da duyet Record nay: ref_no: " + lb_ref_no_Fund_Tran.Text);
                    Alert.Show("Da duyet record nay!!!", this);
                    return;
                }
            }
            //CARD_NUMBER = lbCardNbr.Text.Trim() == "" ? "null" : ("'" + lbCardNbr.Text.Trim() + "'");
            ACCOUNT_NUMBER = tbTAcc.Text.Trim ( ) == "" ? "null" : ( "" + tbTAcc.Text.Trim ( ) + "" );

            //1. goi ham hach toan
            //    if ok 
            //        (
            //          ghi logfile
            //          update electra
            //        )

            //#region HachToan
            string branchcode = "", branch = "", txnbranch = "", txnacc = "", txnccy = "", txnamount = "", offsetbrn = "", offsetacc = ""
                , offsetccy = "", offsetamount = "", narrative = "", product = "";
            //Nộp tiền mặt
            if (Session["UserBranch"].ToString().Trim() == "")
            {
                executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Section bị ngắt. Bạn vui lòng đăng nhập lại");
                //executedb.WriteLogPri(Environment.NewLine + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + " - " + Session["Username"].ToString() + ": " + sql + " --> " + err);
                //Response.Write("<script>alert('Error when executing from database!!!')</script>");
                Alert.Show("Section bị ngắt. Bạn vui lòng đăng nhập lại", this);
                return;
            }
            else
            {
                branchcode = Session["UserBranch"].ToString().Trim();
                branch = Session["UserBranch"].ToString().Trim();
                // offsetbrn = Session["UserBranch"].ToString().Trim().Substring(1, 3);//dung tai chi nhanh nao thi lay tai khoan tien mat tai chi nhanh do
            }
            txnbranch = tbFAcc.Text.Trim ( ).Substring ( 0, 3 );
            txnacc = tbFAcc.Text.Trim();
            txnccy = "VND";
            txnamount = tbBalanceInsert_Fund_Tran.Text.Trim().Replace(",", "").Replace(".", "");
            offsetbrn = tbTAcc_Branch.Text.Trim();//.Substring(1,3);
            if (tbTAcc.Text.Trim().Substring(0, 1) == "5")
                offsetacc = executedb.InternalPrepaid;//"427302002";//tbTAcc.Text.Trim();
            else
                offsetacc = executedb.DomesticPrepaid;// "427301002";//tbTAcc.Text.Trim();

            //datpt 24/05/2013: change 4273 to 4599
            offsetacc = executedb.TK_TamTreoNapTien;
            offsetbrn = executedb.Br_TamTreoNapTien;
            //end datpt 24/05/2013: change 4273 to 4599


            offsetccy = "VND";
            offsetamount = tbBalanceInsert_Fund_Tran.Text.Trim().Replace(",", "").Replace(".", "");
            narrative = tbDecription_Fund_Tran.Text;
            product = executedb.sp_chuyenkhoan;// "GL03";//TEST chuyen khoan
            //, , offsetamount, narrative, product
            //Gọi hàm hạch toán
            string receive = CoreAuthorize.HachToanCheo(branchcode, branch, txnbranch, txnacc, txnccy, txnamount, offsetbrn, offsetacc, offsetccy, offsetamount, narrative, product);
            //string receive = "success|Note lam sau";
            if (receive.Trim() != "")
            {
                if (receive.Substring(0, 7).ToUpper() == "success".ToUpper())
                {
                    batch = tbBatchID_fundsTran.Text.Trim ( );
                    ref_no_br = lb_ref_no.Text;
                    txn_amount = txnamount;
                    user_duyet = Session["Username"].ToString();
                    #region new
                    string result = "";
                    try
                    {
                        TTTSOA.TrungTamThe fundstrans = new TTTSOA.TrungTamThe ( ); ;
                        result = fundstrans.SOA_Misc_Credit ( "WEB", ACCOUNT_NUMBER.Trim(), txnamount, "CHUYEN KHOAN VAO TAI KHOAN", "82" );
                        DataTable check = Splitxml.getxmlvalue ( result );
                        if (check.Rows[0]["result"].ToString().Trim() == "0")
                        {
                            sql  = " update nab_balance_prepaid_realtime b ";
                            sql += "   set b.authorize = 'Y' ";
                            sql += "       ,b.extract_flag='Y' ";
                            sql += "       ,b.user_extract= '" + user_duyet + "'";
                            sql += "       ,b.date_extract= sysdate";
                            sql += "       ,b.message_receive= '" + receive + "'";
                            sql += "       , b.user_modify= '" + user_duyet + "'";
                            sql += "       ,b.DATE_MODIFY= sysdate";
                            sql += "       ,b.microfilm_ref_number = '" + check.Rows[0]["SRN"].ToString().Trim() + "'";
                            sql += "   where b.batch_id = '" + batch + "'";
                            sql += "   and b.ref_no = '" + ref_no_br + "' ";
                            executedb.ExecuteDML ( sql, ref err );
                            if (err != "")
                            {
                                ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                          "err_msg",
                                          "alert('Authorize Fail !!');",
                                          true );
                                executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), " Update not success:" + sql + " Error:" + err );
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                              "err_msg",
                                              "alert('Authorize Success !!');",
                                              true );
                                executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), " Update success:" + sql + " Error:" + err );
                            }
                            
                        }

                        else
                        {
                            executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), "Authorize not success: " + check.Rows[2]["msg"].ToString().Trim() );
                            ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                             "err_msg",
                                             "alert('Mics not success!!');",
                                             true );
                        }
                    }
                    catch (Exception ex)
                    {
                        executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), "Problem in calling SOA --> SOA_Mics_Credit : " + ex.ToString ( ) );
                        ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                              "err_msg",
                                              "alert('Error in calling SOA --> SOA_Mics_Credit ');",
                                              true );
                    }

                    #endregion new
                    
                }//Hach toan khong thanh cong
                else
                {
                    executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Authorize not success: " + receive);
                    ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                            "err_msg",
                                            "alert('Failed to call from core!!');",
                                            true );
                }
            }
            else
            {
                executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Khong nhan duoc receive tu CORE");
                ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                       "err_msg",
                                       "alert('Khong nhan duoc receive tu CORE');",
                                       true );
            }
        }

        catch (Exception ex)
        {
            #region logException
            executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), ex.Message);
            //executedb.WriteLogPri(Environment.NewLine + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + " - " + Session["Username"].ToString() + ": " + ex.Message);
            //Response.Write("<script>alert('Error when executing coding')</script>");
            ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                      "err_msg",
                                      "alert('Error when executing coding');",
                                      true );
            #endregion logException
        }
    }
    private void Authorize_NopTienMat()
    {
        try
        {
            string sql = "", err = "";
            string ACCOUNT_NUMBER = "",
            account_nbr = (string)Session["Account_nbr"];
            //card_nbr = (string)Session["Card_nbr"];
            
            string batch = ""; string ref_no_br = ""; string txn_amount = ""; string user_duyet = "";

            sql = "select * from nab_balance_prepaid_realtime a where a.ref_no='" + lb_ref_no.Text + "' and a.authorize='Y'";
            DataTable dtcheck = executedb.getTable(sql, ref err);

            if (err != "")
            {
                executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), sql + " --> " + err);
                Alert.Show("Error when executing from database!!!", this);
            }
            else
            {
                if (dtcheck.Rows.Count > 0)
                {
                    executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Da duyet Record nay: ref_no: " + lb_ref_no.Text);
                    Alert.Show("Da duyet record nay!!!", this);
                    return;
                }
            }

            // batch = ""; ref_no_br = lb_ref_no.Text; txn_amount = ""; user_duyet = "";
            ACCOUNT_NUMBER = tbAccountnbr.Text.Trim ( ) == "" ? "null" : ( "" + tbAccountnbr.Text.Trim() + "" );


            //1. goi ham hach toan
            //    if ok 
            //        (
            //          ghi logfile
            //          update electra
            //        )

            string branchcode = "", branch = "", txnbranch = "", txnacc = "", txnccy = "", txnamount = "", offsetbrn = "", offsetacc = ""
                , offsetccy = "", offsetamount = "", narrative = "", product = "";
            //Nộp tiền mặt
            if (Session["UserBranch"].ToString().Trim() == "")
            {
                executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Section bị ngắt. Bạn vui lòng đăng nhập lại");
                //executedb.WriteLogPri(Environment.NewLine + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + " - " + Session["Username"].ToString() + ": " + sql + " --> " + err);
                //Response.Write("<script>alert('Error when executing from database!!!')</script>");
                Alert.Show("Section bị ngắt. Bạn vui lòng đăng nhập lại", this);

                return;
            }
            else
            {
                branchcode = Session["UserBranch"].ToString().Trim();
                branch = Session["UserBranch"].ToString().Trim();
                offsetbrn = Session["UserBranch"].ToString().Trim();//dung tai chi nhanh nao thi lay tai khoan tien mat tai chi nhanh do
            }
            //Lấy branch tài khoản thẻ:
            sql = ""; err = "";
            sql = "select ctr.contract_number card_number, b.code branch_code";
            sql += "  from " + executedb.owner + "acnt_contract ctr, " + executedb.owner + "branch b";
            sql += " where ctr.amnd_state = 'A'";
            sql += "   and ctr.con_cat = 'A' ";
            sql += "   and b.amnd_state = 'A' ";
            sql += "   and ctr.branch = b.code ";
            sql += "   and ctr.contract_number = '" + account_nbr.Trim ( ) + "'";

            DataTable dtcheckbranchcard = executedb.getTable(sql, ref err);

            if (err != "")
            {
                executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), sql + " --> " + err);
                Alert.Show("Error when executing from database!!!", this);
            }
            else
            {
                if (dtcheckbranchcard.Rows.Count <= 0)
                {
                    executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Khong the tim thay so the nay:" + lbCardNbr.Text.Trim());
                    Alert.Show("Khong the tim thay so the nay:" + lbCardNbr.Text.Trim(), this);
                    return;
                }
                else
                    if (dtcheckbranchcard.Rows.Count >= 2)
                    {
                        executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Nhieu hon 1 branch duoc tim thay:" + lbCardNbr.Text.Trim());
                        Alert.Show("Nhieu hon 1 branch duoc tim thay:" + lbCardNbr.Text.Trim(), this);
                        return;
                    }
                    else
                    {
                        txnbranch = dtcheckbranchcard.Rows[0]["branch_code"].ToString().Trim();
                    }
            }
            if (tbAccountnbr.Text.Trim ( ).Substring ( 0, 1 ) == "5")
                txnacc = executedb.InternalPrepaid;//"427302002";//fix for prepaid card
            else
                txnacc = executedb.DomesticPrepaid;// "427301002";

            //datpt 24/05/2013: change 4273 to 4599
            txnacc = executedb.TK_TamTreoNapTien;
            txnbranch = executedb.Br_TamTreoNapTien;
            //end datpt 24/05/2013: change 4273 to 4599


            txnccy = "VND";
            txnamount = tbBalanceInsert.Text.Trim().Replace(",", "").Replace(".", "");
            offsetacc = executedb.TKTienmat;// "101101001";
            offsetccy = "VND";
            offsetamount = tbBalanceInsert.Text.Trim().Replace(",", "").Replace(".", "");
            narrative = "BALANCE PREPAID CARD";
            product = executedb.sp_noptienmat;// "NT04";//TEST nap tien mat
            //, , offsetamount, narrative, product
            //Gọi hàm hạch toán
            string receive = CoreAuthorize.HachToanCheo(branchcode, branch, txnbranch, txnacc, txnccy, txnamount, offsetbrn, offsetacc, offsetccy, offsetamount, narrative, product);
            //string receive= "success|Note lam sau";
            
            if (receive.Trim() != "")
            //if(true)
            {
                if (receive.Substring(0, 7).ToUpper() == "success".ToUpper())
                {
                    batch = tbBatchID1.Text.Trim ( );
                    ref_no_br = lb_ref_no.Text;
                    txn_amount = txnamount;
                    user_duyet = Session["Username"].ToString();

                    //Write log success
                    executedb.WriteLogINFO ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), "Authorize result: " + receive);
                    //Goi procedure a Phuong viet de xu ly cap nhat balance electra

                    //const int para = 2;
                    try
                    {
                        string usermodify = "";//cardnbr = "", 
                        usermodify = (string)Session["Username"];
                        if (ref_no_br != "")
                        {
                            #region new
                            string result = "";
                            try
                            {
                                TTTSOA.TrungTamThe noptienmat = new TTTSOA.TrungTamThe ( ); ;
                                result = noptienmat.SOA_Misc_Credit ( "WEB", ACCOUNT_NUMBER.Trim(), txn_amount, "NOP TIEN VAO TAI KHOAN", "82" );
                                DataTable check = Splitxml.getxmlvalue ( result );
                                if (check.Rows[0]["result"].ToString ( ).Trim ( ) == "0")
                                {
                                    sql = " update nab_balance_prepaid_realtime b ";
                                    sql += "   set b.authorize = 'Y' ";
                                    sql += "       ,b.extract_flag='Y' ";
                                    sql += "       ,b.user_extract= '" + user_duyet + "'";
                                    sql += "       ,b.date_extract= sysdate";
                                    sql += "       ,b.message_receive= '" + receive + "'";
                                    sql += "       , b.user_modify= '" + user_duyet + "'";
                                    sql += "       ,b.DATE_MODIFY= sysdate";
                                    sql += "       ,b.microfilm_ref_number = '" + check.Rows[0]["SRN"].ToString ( ).Trim ( ) + "'";
                                    sql += "   where b.batch_id = '" + batch + "'";
                                    sql += "   and b.ref_no = '" + ref_no_br + "' ";

                                    executedb.ExecuteDML ( sql, ref err );
                                    
                                    if (err !="")
                                    {               
                                        ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                            "err_msg",
                                            "alert('Authorize Fail !!');",
                                            true );
                                        
                                    }
                                    else                       
                                    {
                                        ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                              "err_msg",
                                              "alert('Authorize Success !!');",
                                              true );
                                        
                                    }
                                    executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), "Authorize success: " + check.Rows[0]["msg"].ToString ( ) + " Update success:" +sql+ " Error:" + err );
                                }
                                else
                                {
                                    executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), "Authorize not success: " + check.Rows[0]["msg"].ToString ( ) + " " + ACCOUNT_NUMBER.ToString().Trim() );
                                    ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                              "err_msg",
                                              "alert('Mics not success --> SOA_Mics_Credit');",
                                              true );
                                }
                            #endregion new
                            }
                            catch     (Exception ex)
                            {
                                executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), "Problem in calling SOA --> SOA_Misc_Credit --> " + ex.ToString ( ) );
                                ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                             "err_msg",
                                             "alert('Error in calling SOA --> SOA_Mics_Credit');",
                                             true );
                            }
                        }

                        tbBalanceInsert.ReadOnly = true;
                        LoadGrid();
                    }
                    catch (Exception ex)
                    {
                        #region logException
                        executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), ex.Message);
                        ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                             "err_msg",
                                             "alert('Error when executing coding!!!');window.location='../Default.aspx';",
                                             true );
                        #endregion logException
                    }
                }//Hach toan khong thanh cong
                else
                {
                    executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), "Authorize not success: " + receive);
                    ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                            "err_msg",
                                            "alert('Check FCC port, authorize not success!!');",
                                            true );
                }
            }
            else
            {
                executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), "Khong nhan duoc receive tu CORE");
                ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                       "err_msg",
                                       "alert('Khong nhan duoc receive tu CORE');",
                                       true );
            }

        }
        catch (Exception ex)
        {
            #region logException
            executedb.WriteLogERROR(Session["Username"].ToString(), "IP: " + Request.UserHostAddress, this.Page.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), ex.Message);
            ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                            "err_msg",
                                            "alert('Error when executing coding!!!');window.location='../Default.aspx';",
                                            true );
            #endregion logException
        }
    }
    private void execute_proc(string Card_Nbr, string client_code, string branch_code)
    {
        const int para = 3;
        try
        {
            string cardnbr = "";
            cardnbr = Card_Nbr.Trim ( );
            if (cardnbr != "")
            {

                int i = 0;
                string name = "PCK_MIGR_CARD_FILE.mirg_fast_card";
                string[] InParaName = new string[3] { "card_nbr", "client_code", "branch_code" };
                string[] OutParaName = new string[para] { "xml_str", "xml_str_related", "Emsg" };
                OracleType[] InParaType = new OracleType[3] { OracleType.VarChar, OracleType.VarChar, OracleType.VarChar };
                OracleType[] OutParaType = new OracleType[para] { 
                    OracleType.LongVarChar ,
                    OracleType.LongVarChar ,
                    OracleType.VarChar
                    };
                string[] InParaValues = new string[3] { cardnbr, client_code, branch_code };
                string[] OutParaValues = new string[para];
                for (i = 0; i < para; i++)
                    OutParaValues[i] = "";
                int[] OutParaSize = new int[para] {
                     9999999,     
                     9999999,
                     200
                };
                OracleType reParaType = OracleType.Number;
                int reParaSize = 1;
                string returnValue = "";
                string err = "";
                executedb.ExecuteFunc ( name, InParaName, InParaType, InParaValues, OutParaName, OutParaType, OutParaSize, reParaType, reParaSize, ref OutParaValues, ref returnValue, ref err );
                if (err != "")
                {
                    executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), "" + executedb.owner + "Proc_nab_Update_Card_Info_CN" + " --> " + err );
                    Alert.Show ( "Error when executing from database!!!", this );
                }
                else
                {
                    if (returnValue != "1")
                    {
                        executedb.WriteLogINFO ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), " Proc_nab_Update_Card_Info_CN " + lbCardNbr.Text );
                        ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                         "err_msg",
                         "alert('Call Proc Error ==> " + OutParaValues[2].ToString ( ) + " ');",
                          true );

                    }
                    else
                    {
                        string xml = OutParaValues[0].ToString ( );
                        string xml_related = OutParaValues[1].ToString ( );
                        TTTSOA.TrungTamThe soa = new TTTSOA.TrungTamThe ( );
                        string result = soa.Fast_Card_Issue ( xml );
                        DataTable check = Splitxml.getxmlvalue ( result );
                        if (check.Rows[0]["result"].ToString ( ).Trim ( ) != "0")
                        {
                            ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                         "err_msg",
                         "alert('Call SOA Error ==> " + check.Rows[0]["msg"].ToString ( ).Trim ( ) + " ');",
                          true );
                        }
                        else
                        {
                            result = soa.Fast_Card_Issue ( xml_related ); // add related account
                            check.Clear ( );
                            check = Splitxml.getxmlvalue ( result );
                            if (check.Rows[0]["result"].ToString ( ).Trim ( ) != "0")
                            {
                                ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                             "err_msg",
                             "alert('Call SOA Error ==> " + check.Rows[0]["msg"].ToString ( ).Trim ( ) + " ');",
                              true );
                            }
                            else
                            {
                                string sql = "";
                                sql += " begin ";
                                sql += " insert into nab_cp_card_prepaid_temp_df ";
                                sql += " select * from nab_cp_card_prepaid_temp;";
                                sql += " delete from nab_cp_card_prepaid_temp where source_application_no = '" + lbSource_no.Text + "';";
                                sql += "  commit; ";
                                sql += " exception ";
                                sql += "  when others then ";
                                sql += "    rollback; ";
                                sql += " end; ";
                                if (!executedb.ExecuteDML ( sql, ref err ))
                                {
                                    ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                       "err_msg",
                                       "alert('Update Error !!');",
                                        true );
                                }
                                else
                                {
                                    ScriptManager.RegisterStartupScript ( this.Page, this.Page.GetType ( ),
                                        "err_msg",
                                        "alert('Success !!');",
                                         true );
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Alert.Show ( "Không có số thẻ: " + lbCardNbr.Text, this );
                executedb.WriteLogINFO ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), " null card nbr: " + lbCardNbr.Text );
            }
        }
        catch (Exception ex)
        {
            #region logException
            executedb.WriteLogERROR ( Session["Username"].ToString ( ), "IP: " + Request.UserHostAddress, this.Page.ToString ( ), System.Reflection.MethodBase.GetCurrentMethod ( ).ToString ( ), ex.Message );
            //executedb.WriteLogPri(Environment.NewLine + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + " - " + Session["Username"].ToString() + ": " + ex.Message);
            //Response.Write("<script>alert('Error when executing coding')</script>");
            Alert.Show ( "Error when executing coding!!!", this );
            #endregion logException
        }
    }