using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data;
using System.Diagnostics;

public partial class AddBank : System.Web.UI.Page
{

    public int page_id = 0;
    public string table_name = "";
    string url = "";
    static int intCount = 0;

    protected void Page_Load(object sender, EventArgs e)
    {

        
    }

    

    

    

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if (txtBankBin.Text.Length > 0 && txtBankCode.Text.Length > 0)
        {
            string error = "";
            bool saved = addBR(ref error);
            if (saved)
            {
                //lblError.Text = "Bank saved";
                Notifications.showMessage("Bank saved", this, Notifications.successMessage, true);
            }
            else
            {
                //lblError.Text = error;
                Notifications.showMessage(error, this, Notifications.errorMessage, true);
            }
        }
        else
        {
            //lblError.Text = "please enter the Bank Code and the Bank name.";
            Notifications.showMessage("please enter the Bank Code and the Bank name.", this, Notifications.errorMessage, true);
        }
    }

    private bool addBR(ref string error)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "BANK_LKP_EDITOR.Add_Bank_BIN";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_bank_code", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_bin", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        oracom.Parameters["p_bank_code"].Value = txtBankCode.Text;
        oracom.Parameters["p_bin"].Value = txtBankBin.Text;

        oracom.ExecuteNonQuery();
        oracon.Close();
        string a = oracom.Parameters["p_res_code"].Value.ToString();
        error = oracom.Parameters["p_res_msg"].Value.ToString();
        if (a == "0")
            return true;
        else
            return false;
    }

    
}