using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OracleClient;

public partial class Business_GLS1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtBankBin.Text.Length > 0 && txtBankCode.Text.Length > 0) 
        {
            string error = "";
            bool saved = addBR(ref error);
            if (saved)
            {
                lblError.ForeColor = System.Drawing.Color.DarkGreen;
                lblError.Text = "Bank saved";
            }
            else
            {
                lblError.Text = error;
            }
        }
        else
        {
            lblError.Text = "please enter the Bank Code and the Bank name.";
        }
    }

    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;
    }
}
