public static string HachToanCheo(string branchcode, string branch, string txnbranch, string txnacc, string txnccy, string txnamount, string offsetbrn,
                             string offsetacc, string offsetccy, string offsetamount, string narrative, string product)
 {
     HachToanCheo.ATMPort fc = new HachToanCheo.ATMPort();
     return fc.HachToanCheo(branchcode, branch, txnbranch, txnacc, txnccy, txnamount, offsetbrn, offsetacc, offsetccy, offsetamount, narrative, product);
     //return "";
 }
        private void HachToan()
        {
            try
            {
                string sql = "", err = "";
                sql += "select to_char(nap.business_date, 'dd/mm/yyyy') as business_date, ";
                sql += "       nap.cr_account_nbr, ";
                sql += "       TRIM(nap.amount_will_process) AS amount_will_process, ";
                sql += "       nap.account_flex_number, ";
                sql += "       trim(nap.account_flex_number) as auto_payment_account, ";
                sql += "       'Auto Payment ' || nap.cr_account_nbr || ' ngay ' || ";
                sql += "       to_char(nap.business_date, 'dd/mm/yyyy') as Narrative, ";
                sql += "       nap.record_seq, ";
                sql += "       nap.branch_4273 ";
                sql += "  from NAB_AUTO_PAYMENT nap ";
                sql += " where trunc(nap.business_date) = trunc(sysdate) ";
                sql += "   and nvl(nap.amount_will_process, 0) > 0 ";
                sql += "   and nvl(nap.processed, '0') in ('0','2') ";
                sql += "   and nap.record_seq >= " + tb_frm_sq.Text.Trim ( ) + "";
                sql += "   and nap.record_seq <= " + tb_to_sq.Text.Trim ( ) + "";
                sql += "   order by nap.record_seq";
                sql += " ";

                DataTable dtDetails =  Businessbp.executedb.getTable ( sql, ref err );
                if (err != "")
                {
                    MessageBox.Show(err);
                    return;
                }
                else
                {
                    //source_acc,string branch_desc_acc,string desc_acc,string amount, string narrative
                    //Load Details
                    if (dtDetails.Rows.Count > 0)
                    {
                        int success = 0;
                        int un_success = 0;
                        string source_acc = "";
                        string branch_desc_acc = "";
                        string desc_acc = "";
                        string amount = "";
                        string narrative = "";
                        string cr_account_nbr = "";
                        string AMOUNT_PROCESSED = "";
                        string result = "";
                        string MESSAGE_FLEXCUBE = "";
                        string business_date = "";
                        string TRAN_REF_NO = "";
                        string seq = "";
                        for (int i = 0; i < dtDetails.Rows.Count; i++)
                        {

                            cr_account_nbr = dtDetails.Rows[i]["cr_account_nbr"].ToString ( ).Trim ( );
                            business_date = dtDetails.Rows[i]["business_date"].ToString ( ).Trim ( );
                            source_acc = dtDetails.Rows[i]["auto_payment_account"].ToString ( ).Trim ( );
                            branch_desc_acc = dtDetails.Rows[i]["branch_4273"].ToString ( ).Trim ( );
                            seq = dtDetails.Rows[i]["record_seq"].ToString ( ).Trim ( );
                            //desc_acc = dtDetails.Rows[i]["account_flex_number"].ToString();
                            desc_acc = "";
                            if (cr_account_nbr.Trim ( ).Substring ( 0, 1 ) == "6")
                                desc_acc = Businessbp.executedb.InternalCredit;
                            else if (cr_account_nbr.Trim ( ).Substring ( 0, 1 ) == "3")
                                desc_acc = Businessbp.executedb.DomesticCredit;
                            else
                            {
                                MessageBox.Show ( "Số thẻ không hợp lệ. Không phải đầu 6 hoặc đầu 3. \n cr_account_nbr:" + cr_account_nbr );
                                return;
                            }
                            amount = dtDetails.Rows[i]["amount_will_process"].ToString ( );
                            narrative = dtDetails.Rows[i]["Narrative"].ToString ( );
                            HachToanCheo.ATMPort ht = new HachToanCheo.ATMPort ( );
                            MESSAGE_FLEXCUBE = ht.CreateTransactionForMaster ( source_acc, branch_desc_acc, desc_acc, amount, narrative );
                            //Cắt dữ liệu từ Response Flexcube
                            //string b = "<response><result>success</result><amount>10000000</amount><fccref>000ATF1120860303</fccref><error_desc></error_desc></response>";
                            //b = "<response><result>failure</result><amount>-39749</amount><fccref></fccref><error_desc>Transaction amount Cannot be Negative</error_desc></response>";
                            //MESSAGE_FLEXCUBE = "<response><result>success</result><amount>10000000</amount><fccref>000ATF1120860303</fccref><error_desc></error_desc></response>";
                            result = MESSAGE_FLEXCUBE.Substring ( MESSAGE_FLEXCUBE.IndexOf ( "<result>" ) + "<result>".Length, MESSAGE_FLEXCUBE.IndexOf ( "</result>" ) - ( MESSAGE_FLEXCUBE.IndexOf ( "<result>" ) + "<result>".Length ) );
                            AMOUNT_PROCESSED = MESSAGE_FLEXCUBE.Substring ( MESSAGE_FLEXCUBE.IndexOf ( "<amount>" ) + "<amount>".Length, MESSAGE_FLEXCUBE.IndexOf ( "</amount>" ) - ( MESSAGE_FLEXCUBE.IndexOf ( "<amount>" ) + "<amount>".Length ) );
                            TRAN_REF_NO = MESSAGE_FLEXCUBE.Substring ( MESSAGE_FLEXCUBE.IndexOf ( "<fccref>" ) + "<fccref>".Length, MESSAGE_FLEXCUBE.IndexOf ( "</fccref>" ) - ( MESSAGE_FLEXCUBE.IndexOf ( "<fccref>" ) + "<fccref>".Length ) );
                            sql = "";
                            err = "";
                            if (result.Trim ( ).ToUpper ( ) == "success".ToUpper ( ))//Hach toan thanh cong
                            {
                                if (AMOUNT_PROCESSED.Trim ( ) != "")
                                {
                                    sql = "";
                                    sql += " Begin";
                                    sql += " update nab_auto_payment set";
                                    sql += " PROCESSED='1'";
                                    sql += " ,MESSAGE_FLEXCUBE='" + MESSAGE_FLEXCUBE + "'";
                                    sql += " ,AMOUNT_PROCESSED=" + AMOUNT_PROCESSED;
                                    sql += " ,TRAN_REF_NO='" + TRAN_REF_NO + "'";
                                    sql += " where  trunc(business_date)=trunc(to_date('" + business_date + "','dd/mm/yyyy'))";
                                    sql += "        and record_seq = " + seq + "";
                                    sql += ";";
                                    sql += " commit;";
                                    sql += " exception";
                                    sql += " when others then";
                                    sql += " rollback;";
                                    sql += " end;";

                                    Businessbp.executedb.ExecuteDML ( sql, ref err );
                                    if (err != "")
                                    {
                                        MessageBox.Show ( err );
                                        return;
                                    }
                                    else
                                    {
                                        success += 1;
                                    }
                                }
                                else
                                {
                                    sql = "";
                                    sql += " Begin";
                                    sql += " update nab_auto_payment set";
                                    sql += " PROCESSED='1'";
                                    sql += " ,MESSAGE_FLEXCUBE='" + MESSAGE_FLEXCUBE + "'";
                                    sql += " ,AMOUNT_PROCESSED=" + "0";
                                    sql += " ,TRAN_REF_NO='" + TRAN_REF_NO + "'";
                                    sql += " where  trunc(business_date)=trunc(to_date('" + business_date + "','dd/mm/yyyy'))";
                                    sql += "        and record_seq = " + seq + "";
                                    sql += ";";
                                    sql += " commit;";
                                    sql += " exception";
                                    sql += " when others then";
                                    sql += " rollback;";
                                    sql += " end;";

                                    Businessbp.executedb.ExecuteDML ( sql, ref err );
                                    if (err != "")
                                    {
                                        MessageBox.Show ( err );
                                        return;
                                    }
                                    else
                                    {
                                        success += 1;
                                    }
                                }
                            }
                            else //Hach toan loi
                            {
                                sql = "";
                                sql += " Begin";
                                //Update record cũ -> phi giao dich
                                sql += " update nab_auto_payment set";
                                sql += " PROCESSED='2'";
                                sql += " ,MESSAGE_FLEXCUBE='" + MESSAGE_FLEXCUBE + "'";
                                // sql += " ,AMOUNT_PROCESSED=" + AMOUNT_PROCESSED;
                                // sql += " ,TRAN_REF_NO='" + TRAN_REF_NO + "'";
                                sql += " where  trunc(business_date)=trunc(to_date('" + business_date + "','dd/mm/yyyy'))";
                                sql += "        and record_seq = " + seq + "";
                                sql += ";";
                                sql += " commit;";
                                sql += " exception";
                                sql += " when others then";
                                sql += " rollback;";
                                sql += " end;";

                                Businessbp.executedb.ExecuteDML ( sql, ref err );
                                if (err != "")
                                {
                                    MessageBox.Show ( err );
                                    return;
                                }
                                {
                                    un_success += 1;
                                }
                            }
                        }//end for
                        tbStatus.Text = "Process successfull!!! --> sucess: " + success + " ; un_success: " + un_success;
                    }
                    else
                    {
                        MessageBox.Show ( "No data found!!!" );
                        tbStatus.Text = "No data to Authorize....";
                        return;
                    }
                }
            }
            catch
            { }
        }
 public static string SendSMS_Banking(string phone_nbr, string content, ref bool result)
 {
     try
     {
         HachToanCheo.ATMPort a = new HachToanCheo.ATMPort();
         result = a.sendSMS(phone_nbr, content);
         return " ";
     }
     catch (Exception ex)
     {
         return ex.Message;
     }
 }
 public static float GetAvlBal(string ACC)
 {
     HachToanCheo.ATMPort fc = new HachToanCheo.ATMPort();
     return fc.getAVLBalance(ACC);
    // return 0;
 }
 public static string ThuPhi(string source_acc, string branch_desc_acc, string desc_acc, string amount, string narrative)
 {
     HachToanCheo.ATMPort a = new HachToanCheo.ATMPort();
     return a.CreateTransactionForMaster(source_acc, branch_desc_acc, desc_acc, amount, narrative);
 }