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;
using System.Diagnostics;

public partial class Business_ATM : 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)
    {
        table_name = "atm_group_tbl";
        url = HttpContext.Current.Request.Url.AbsolutePath;
        string[] urlArr = url.Split('/');
        url = urlArr[2] + "/" + urlArr[3];
        page_id = loadPageIDs(url);
        if (!IsPostBack)
        {
            ExceptionUtility.LogException(0, "", "75", "Page_Load", "");
            loadCurrency();
            loadGroups();

            this.pnl_confirmation.Visible = false;
           
        }
    }
    private int loadPageIDs(string URL)
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "lookup_getter.get_pages";

            oracom.Parameters.Add("p_url", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_pages", OracleType.Cursor).Direction = ParameterDirection.Output;


            oracom.Parameters["p_url"].Value = URL;

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);

            oracon.Close();
            return int.Parse(ds.Tables[0].Rows[0]["pid"].ToString());
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "lookup_getter.get_pages","", "loadPageIDs", "URL: " + URL);
            ////Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return 0;
        }

    }
    private int loadChgID()
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "maker_checker_editor.get_chg_id";


            oracom.Parameters.Add("p_chg_id", OracleType.Number).Direction = ParameterDirection.Output;

            oracom.ExecuteNonQuery();
            oracon.Close();

            int nop = int.Parse(oracom.Parameters["p_chg_id"].Value.ToString());
            oracon.Close();
            return nop;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "maker_checker_editor.get_chg_id","", "loadChgID", "");
            ////Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return 0;
        }
    }

    private int loadMaxChgID(string atm_number)
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "maker_checker_editor.get_max_chg_id";

            oracom.Parameters.Add("p_changed_rec_id", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_chg_id", OracleType.Number).Direction = ParameterDirection.Output;

            oracom.Parameters["p_changed_rec_id"].Value = atm_number;

            oracom.ExecuteNonQuery();
            oracon.Close();

            int nop = int.Parse(oracom.Parameters["p_chg_id"].Value.ToString());
            oracon.Close();
            return nop;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "maker_checker_editor.get_max_chg_id","", "loadMaxChgID", "atm_number: " + atm_number);
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return 0;
        }
    }

    private void loadCurrency()
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "LOOKUP_GETTER.get_curr";

            oracom.Parameters.Add("p_repl_curr", OracleType.Cursor).Direction = ParameterDirection.Output;

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);

            ddlCass1.DataSource = ds;
            ddlCass1.DataBind();
            ddlCass2.DataSource = ds;
            ddlCass2.DataBind();
            ddlCass3.DataSource = ds;
            ddlCass3.DataBind();
            ddlCass4.DataSource = ds;
            ddlCass4.DataBind();
            ddlCass5.DataSource = ds;
            ddlCass5.DataBind();
            ddlCass6.DataSource = ds;
            ddlCass6.DataBind();

            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.get_curr","", "loadCurrency", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadGroups()
    {
        try
        {
            string currentMethod = "";
            StackTrace stackTrace = new StackTrace();
            currentMethod = stackTrace.GetFrame(1).GetMethod().Name;
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "ATM_GROUP_EDITOR.get_atm_groups";


            oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_gid", OracleType.Number).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.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;

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

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);

            oracon.Close();

            GridView1.DataSource = ds;
            GridView1.DataBind();
            if(currentMethod .Contains ("Page_Load"))
                ExceptionUtility.LogException(0, "ATM_GROUP_EDITOR.get_atm_groups", "", "loadGroups", "p_lang-EN");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "ATM_GROUP_EDITOR.get_atm_groups", "", "loadGroups", "p_lang-EN");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }
    private DataSet loadGroupsDetails(int gid)
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "ATM_GROUP_EDITOR.get_atm_groups";


            oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_gid", OracleType.Number).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.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;

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

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);

            oracon.Close();
            return ds;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "ATM_GROUP_EDITOR.get_atm_groups", "", "loadGroupsDetails", "gid- " + gid + ":p_lang-EN");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return null;
        }
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        intCount = 0;
        pnlControls.Visible = true;
        pnlResult.Enabled = false;
        ViewState["mode"] = "a";
        ExceptionUtility.LogException(0, "", "75.411", "btnAdd_Click", "");
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("e"))
        {
            intCount = 0;
            ExceptionUtility.LogException(0, "", "75.473", "GridView1_RowCommand.Edit", "");
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();
            txtName.Text = GridView1.Rows[index].Cells[0].Text.ToString().Replace("&nbsp;","");

            txtCass1Value.Text = GridView1.Rows[index].Cells[2].Text.ToString().Replace("&nbsp;", "");
            txtCass2Value.Text = GridView1.Rows[index].Cells[4].Text.ToString().Replace("&nbsp;", "");
            txtCass3Value.Text = GridView1.Rows[index].Cells[6].Text.ToString().Replace("&nbsp;", "");
            txtCass4Value.Text = GridView1.Rows[index].Cells[8].Text.ToString().Replace("&nbsp;", "");
            txtCass5Value.Text = GridView1.Rows[index].Cells[10].Text.ToString().Replace("&nbsp;", "");
            txtCass6Value.Text = GridView1.Rows[index].Cells[12].Text.ToString().Replace("&nbsp;", "");

            if (GridView1.Rows[index].Cells[18].Text.ToString().Replace("&nbsp;", "").Length > 0
                && !GridView1.Rows[index].Cells[18].Text.ToString().Replace("&nbsp;", "").Equals("0"))
                ddlCass1.SelectedValue = GridView1.Rows[index].Cells[18].Text.ToString();

            if (GridView1.Rows[index].Cells[19].Text.ToString().Replace("&nbsp;", "").Length > 0
                && !GridView1.Rows[index].Cells[19].Text.ToString().Replace("&nbsp;", "").Equals("0"))
                ddlCass2.SelectedValue = GridView1.Rows[index].Cells[19].Text.ToString();

            if (GridView1.Rows[index].Cells[20].Text.ToString().Replace("&nbsp;", "").Length > 0
                && !GridView1.Rows[index].Cells[20].Text.ToString().Replace("&nbsp;", "").Equals("0"))
                ddlCass3.SelectedValue = GridView1.Rows[index].Cells[20].Text.ToString();

            if (GridView1.Rows[index].Cells[21].Text.ToString().Replace("&nbsp;", "").Length > 0
                && !GridView1.Rows[index].Cells[21].Text.ToString().Replace("&nbsp;", "").Equals("0"))
                ddlCass4.SelectedValue = GridView1.Rows[index].Cells[21].Text.ToString();

            if (GridView1.Rows[index].Cells[22].Text.ToString().Replace("&nbsp;", "").Length > 0
                && !GridView1.Rows[index].Cells[22].Text.ToString().Replace("&nbsp;", "").Equals("0"))
                ddlCass5.SelectedValue = GridView1.Rows[index].Cells[22].Text.ToString();

            if (GridView1.Rows[index].Cells[23].Text.ToString().Replace("&nbsp;", "").Length > 0
                && !GridView1.Rows[index].Cells[23].Text.ToString().Replace("&nbsp;", "").Equals("0"))
                ddlCass6.SelectedValue = GridView1.Rows[index].Cells[23].Text.ToString();


            pnlControls.Visible = true;
            pnlResult.Enabled = false;

            ViewState["mode"] = "u";
            ViewState["rowid"] = rowID;
        }
        else if (e.CommandName.Equals("vm"))
        {
            ExceptionUtility.LogException(0, "", "75.473", "GridView1_RowCommand.ViewModification", "");
            pnlControls.Visible = false;
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();
            int chgId = loadMaxChgID(rowID);
            Response.Redirect("Checker.aspx?chgId=" + chgId);
        }
        else if (e.CommandName.Equals("d"))
        {
            ExceptionUtility.LogException(0, "", "75.410", "GridView1_RowCommand.Delete", "");
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();

            ViewState["selectedGroupID"] = rowID;

            this.pnlResult.Visible = false;
            this.pnl_confirmation.Visible = true;
        }
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        ExceptionUtility.LogException(0, "", "75.410", "btnCancel_Click", "");
        pnlControls.Visible = false;
        pnlResult.Enabled = true;
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (intCount < 1)
            intCount++;
        else
        {
            pnlControls.Visible = false;
            lblError.Text = "Your request has been sent to Checker user for Approval";
            return;
        }
        try
        {
            string mode = ViewState["mode"].ToString();
            string GROUP_NAME_NEW,CASS1_CURR_NEW, CASS1_CURR_DESC_NEW, CASS1_VALUE_NEW, CASS2_CURR_NEW, CASS2_CURR_DESC_NEW, CASS2_VALUE_NEW, CASS3_CURR_NEW, CASS3_CURR_DESC_NEW, CASS3_VALUE_NEW, CASS4_CURR_NEW, CASS4_CURR_DESC_NEW, CASS4_VALUE_NEW, CASS5_CURR_NEW, CASS5_CURR_DESC_NEW, CASS5_VALUE_NEW, CASS6_CURR_NEW, CASS6_CURR_DESC_NEW, CASS6_VALUE_NEW;
            string GROUP_NAME_OLD,CASS1_CURR_OLD, CASS1_CURR_DESC_OLD, CASS1_VALUE_OLD, CASS2_CURR_OLD, CASS2_CURR_DESC_OLD, CASS2_VALUE_OLD, CASS3_CURR_OLD, CASS3_CURR_DESC_OLD, CASS3_VALUE_OLD, CASS4_CURR_OLD, CASS4_CURR_DESC_OLD, CASS4_VALUE_OLD, CASS5_CURR_OLD, CASS5_CURR_DESC_OLD, CASS5_VALUE_OLD, CASS6_CURR_OLD, CASS6_CURR_DESC_OLD, CASS6_VALUE_OLD;
            GROUP_NAME_NEW = txtName.Text;
            if (txtCass1Value.Text.Length != 0)
            {
                 CASS1_CURR_NEW = ddlCass1.SelectedValue;
                 CASS1_CURR_DESC_NEW=ddlCass1.SelectedItem .Text ;
                 CASS1_VALUE_NEW = txtCass1Value.Text.Trim();
            }
            else
            {
                 CASS1_CURR_NEW ="";
                 CASS1_CURR_DESC_NEW="";
                 CASS1_VALUE_NEW = "";
            }

            if (txtCass2Value.Text.Length != 0)
            {
                CASS2_CURR_NEW = ddlCass2.SelectedValue;
                CASS2_CURR_DESC_NEW=ddlCass2.SelectedItem.Text ;
                CASS2_VALUE_NEW = txtCass2Value.Text.Trim();
            }
            else
            {
                CASS2_CURR_NEW = "";
                CASS2_CURR_DESC_NEW="";
                CASS2_VALUE_NEW ="";
            }

            if (txtCass3Value.Text.Length != 0)
            {
                CASS3_CURR_NEW = ddlCass3.SelectedValue;
                CASS3_CURR_DESC_NEW=ddlCass3.SelectedItem .Text  ;
                CASS3_VALUE_NEW = txtCass3Value.Text.Trim();
            }
            else
            {
                CASS3_CURR_NEW = "";
                CASS3_CURR_DESC_NEW ="";
                CASS3_VALUE_NEW = "";
            }

            if (txtCass4Value.Text.Length != 0)
            {
                CASS4_CURR_NEW = ddlCass4.SelectedValue;
                CASS4_CURR_DESC_NEW=ddlCass4 .SelectedItem .Text ;
                CASS4_VALUE_NEW = txtCass4Value.Text.Trim();
            }
            else
            {
                CASS4_CURR_NEW = "";
                CASS4_CURR_DESC_NEW ="";
                CASS4_VALUE_NEW = "";
            }

            if (txtCass5Value.Text.Length != 0)
            {
                CASS5_CURR_NEW = ddlCass5.SelectedValue;
                CASS5_CURR_DESC_NEW=ddlCass5 .SelectedItem .Text  ;
                CASS5_VALUE_NEW = txtCass5Value.Text.Trim();
            }
            else
            {
                CASS5_CURR_NEW = "";
                CASS5_CURR_DESC_NEW="";
                CASS5_VALUE_NEW = "";
            }


            if (txtCass6Value.Text.Length != 0)
            {
                CASS6_CURR_NEW = ddlCass6.SelectedValue;
                CASS6_CURR_DESC_NEW=ddlCass6.SelectedItem .Text;
                CASS6_VALUE_NEW = txtCass6Value.Text.Trim();
            }
            else
            {
                CASS6_CURR_NEW = "";
                CASS6_CURR_DESC_NEW="";
                CASS6_VALUE_NEW = "";
            }
            ExceptionUtility.LogException(0, "", "75.412", "btnSave_Click", "");
            string error = "";
            if (mode.Equals("a"))
            {
                int chgId = loadChgID();                
                bool saved = false;
                saved = UpdateMakerChecker(chgId, "", "GROUP_NAME", "", GROUP_NAME_NEW, "", "", 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "STATUS", "", "1", "", "", 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS1_CURR", "", CASS1_CURR_DESC_NEW, "", CASS1_CURR_NEW, 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS1_VALUE", "", CASS1_VALUE_NEW, "", "", 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS2_CURR", "", CASS2_CURR_DESC_NEW, "", CASS2_CURR_NEW, 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS2_VALUE", "", CASS2_VALUE_NEW, "", "", 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS3_CURR", "", CASS3_CURR_DESC_NEW, "", CASS3_CURR_NEW, 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS3_VALUE", "", CASS3_VALUE_NEW, "", "", 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS4_CURR", "", CASS4_CURR_DESC_NEW, "", CASS4_CURR_NEW, 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS4_VALUE", "", CASS4_VALUE_NEW, "", "", 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS5_CURR", "", CASS5_CURR_DESC_NEW, "", CASS5_CURR_NEW, 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS5_VALUE", "", CASS5_VALUE_NEW, "", "", 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS6_CURR", "", CASS6_CURR_DESC_NEW, "", CASS6_CURR_NEW, 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }
                saved = UpdateMakerChecker(chgId, "", "CASS6_VALUE", "", CASS6_VALUE_NEW, "", "", 0, ref error);
                if (saved == false)
                {
                    if (Helper.OracleError(error))
                    {
                        lblError.Text = "An error occured!";
                        ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                    }
                    else
                        lblError.Text = error;
                    return;
                }

                lblError.Text = "Your request has been sent to Checker user for Approval";
               
            }
            else if (mode.Equals("u"))
            {
                string Uid = ViewState["rowid"].ToString();
                int chgId = loadChgID();
                bool compare = false;
                DataSet ds = loadGroupsDetails(int.Parse(Uid));
                if (ds.Tables[0].Rows.Count > 0)
                {
                    GROUP_NAME_OLD = ds.Tables[0].Rows[0]["GROUP_NAME"].ToString();
                    CASS1_CURR_OLD = ds.Tables[0].Rows[0]["CASS1_CURR_VALUE"].ToString();
                    CASS1_CURR_DESC_OLD = ds.Tables[0].Rows[0]["CASS1_CURR"].ToString();
                    CASS1_VALUE_OLD = ds.Tables[0].Rows[0]["CASS1_VALUE"].ToString();
                    CASS2_CURR_OLD = ds.Tables[0].Rows[0]["CASS2_CURR_VALUE"].ToString();
                    CASS2_CURR_DESC_OLD = ds.Tables[0].Rows[0]["CASS2_CURR"].ToString();
                    CASS2_VALUE_OLD = ds.Tables[0].Rows[0]["CASS2_VALUE"].ToString();
                    CASS3_CURR_OLD = ds.Tables[0].Rows[0]["CASS3_CURR_VALUE"].ToString();
                    CASS3_CURR_DESC_OLD = ds.Tables[0].Rows[0]["CASS3_CURR"].ToString();
                    CASS3_VALUE_OLD = ds.Tables[0].Rows[0]["CASS3_VALUE"].ToString();
                    CASS4_CURR_OLD = ds.Tables[0].Rows[0]["CASS4_CURR_VALUE"].ToString();
                    CASS4_CURR_DESC_OLD = ds.Tables[0].Rows[0]["CASS4_CURR"].ToString();
                    CASS4_VALUE_OLD = ds.Tables[0].Rows[0]["CASS4_VALUE"].ToString();
                    CASS5_CURR_OLD = ds.Tables[0].Rows[0]["CASS5_CURR_VALUE"].ToString();
                    CASS5_CURR_DESC_OLD = ds.Tables[0].Rows[0]["CASS5_CURR"].ToString();
                    CASS5_VALUE_OLD = ds.Tables[0].Rows[0]["CASS5_VALUE"].ToString();
                    CASS6_CURR_OLD = ds.Tables[0].Rows[0]["CASS6_CURR_VALUE"].ToString();
                    CASS6_CURR_DESC_OLD = ds.Tables[0].Rows[0]["CASS6_CURR"].ToString();
                    CASS6_VALUE_OLD = ds.Tables[0].Rows[0]["CASS6_VALUE"].ToString();

                    if (CASS1_CURR_NEW == CASS1_CURR_OLD && CASS1_VALUE_NEW == CASS1_VALUE_OLD &&
                       CASS2_CURR_NEW == CASS2_CURR_OLD && CASS2_VALUE_NEW == CASS2_VALUE_OLD &&
                       CASS3_CURR_NEW == CASS3_CURR_OLD && CASS3_VALUE_NEW == CASS3_VALUE_OLD &&
                       CASS4_CURR_NEW == CASS4_CURR_OLD && CASS4_VALUE_NEW == CASS4_VALUE_OLD &&
                       CASS5_CURR_NEW == CASS5_CURR_OLD && CASS5_VALUE_NEW == CASS5_VALUE_OLD &&
                       CASS6_CURR_NEW == CASS6_CURR_OLD && CASS6_VALUE_NEW == CASS6_VALUE_OLD)
                        compare = true;
                    if (compare == false)
                    {
                        bool update = false;
                        if (GROUP_NAME_NEW != GROUP_NAME_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "GROUP_NAME", GROUP_NAME_OLD, GROUP_NAME_NEW, "", "", 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS1_CURR_NEW != CASS1_CURR_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS1_CURR", CASS1_CURR_DESC_OLD, CASS1_CURR_DESC_NEW, CASS1_CURR_OLD, CASS1_CURR_NEW, 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS1_VALUE_NEW != CASS1_VALUE_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS1_VALUE", CASS1_VALUE_OLD, CASS1_VALUE_NEW, "", "", 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS2_CURR_NEW != CASS2_CURR_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS2_CURR", CASS2_CURR_DESC_OLD, CASS2_CURR_DESC_NEW, CASS2_CURR_OLD, CASS2_CURR_NEW, 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS2_VALUE_NEW != CASS2_VALUE_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS2_VALUE", CASS2_VALUE_OLD, CASS2_VALUE_NEW, "", "", 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS3_CURR_NEW != CASS3_CURR_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS3_CURR", CASS3_CURR_DESC_OLD, CASS3_CURR_DESC_NEW, CASS3_CURR_OLD, CASS3_CURR_NEW, 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS3_VALUE_NEW != CASS3_VALUE_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS3_VALUE", CASS3_VALUE_OLD, CASS3_VALUE_NEW, "", "", 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS4_CURR_NEW != CASS4_CURR_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS4_CURR", CASS4_CURR_DESC_OLD, CASS4_CURR_DESC_NEW, CASS4_CURR_OLD, CASS4_CURR_NEW, 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS4_VALUE_NEW != CASS4_VALUE_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS4_VALUE", CASS4_VALUE_OLD, CASS4_VALUE_NEW, "", "", 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS5_CURR_NEW != CASS5_CURR_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS5_CURR", CASS5_CURR_DESC_OLD, CASS5_CURR_DESC_NEW, CASS5_CURR_OLD, CASS5_CURR_NEW, 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS5_VALUE_NEW != CASS5_VALUE_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS5_VALUE", CASS5_VALUE_OLD, CASS5_VALUE_NEW, "", "", 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }

                        if (CASS6_CURR_NEW != CASS6_CURR_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS6_CURR", CASS6_CURR_DESC_OLD, CASS6_CURR_DESC_NEW, CASS6_CURR_OLD, CASS6_CURR_NEW, 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }
                        if (CASS6_VALUE_NEW != CASS6_VALUE_OLD)
                        {
                            update = UpdateMakerChecker(chgId, Uid, "CASS6_VALUE", CASS6_VALUE_OLD, CASS6_VALUE_NEW, "", "", 1, ref error);
                            if (update == false)
                            {
                                if (Helper.OracleError(error))
                                {
                                    lblError.Text = "An error occured!";
                                    ExceptionUtility.LogException(9, "", "75.412", "btnSave_Click", error);
                                }
                                else
                                    lblError.Text = error;
                                return;
                            }
                        }

                        lblError.Text = "Your request has been sent to Checker user for Approval";
                      
                    }
                }
            }
            loadGroups();
            ViewState["mode"] = null;
            ViewState["rowid"] = null;
            pnlControls.Visible = false;
            pnlResult.Enabled = true;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "", "75.412", "btnSave_Click()", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private bool addGroup(ref string error)
    {
        string parameters = "";
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "ATM_GROUP_EDITOR.add_atm_group";

            oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_GROUP_NAME", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS1_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS1_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS2_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS2_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS3_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS3_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS4_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS4_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS5_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS5_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS6_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS6_VALUE", OracleType.Number).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_GROUP_NAME"].Value = txtName.Text;
            parameters = "p_GROUP_NAME-" + txtName.Text;
            if (txtCass1Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS1_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS1_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS1_CURR"].Value = ddlCass1.SelectedValue;
                oracom.Parameters["p_CASS1_VALUE"].Value = txtCass1Value.Text;
            }

            if (txtCass2Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS2_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS2_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS2_CURR"].Value = ddlCass2.SelectedValue;
                oracom.Parameters["p_CASS2_VALUE"].Value = txtCass2Value.Text;
            }

            if (txtCass3Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS3_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS3_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS3_CURR"].Value = ddlCass3.SelectedValue;
                oracom.Parameters["p_CASS3_VALUE"].Value = txtCass3Value.Text;
            }

            if (txtCass4Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS4_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS4_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS4_CURR"].Value = ddlCass4.SelectedValue;
                oracom.Parameters["p_CASS4_VALUE"].Value = txtCass4Value.Text;
            }

            if (txtCass5Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS5_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS5_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS5_CURR"].Value = ddlCass5.SelectedValue;
                oracom.Parameters["p_CASS5_VALUE"].Value = txtCass5Value.Text;
            }

            if (txtCass6Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS6_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS6_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS6_CURR"].Value = ddlCass6.SelectedValue;
                oracom.Parameters["p_CASS6_VALUE"].Value = txtCass6Value.Text;
            }

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

            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;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "ATM_GROUP_EDITOR.add_atm_group","", "addGroup", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return false;
        }
    }

    private bool updateGroup(string rowID, ref string error)
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "ATM_GROUP_EDITOR.update_atm_group";

            oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_gid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_GROUP_NAME", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS1_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS1_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS2_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS2_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS3_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS3_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS4_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS4_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS5_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS5_VALUE", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS6_CURR", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_CASS6_VALUE", OracleType.Number).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_gid"].Value = rowID;
            oracom.Parameters["p_GROUP_NAME"].Value = txtName.Text;

            if (txtCass1Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS1_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS1_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS1_CURR"].Value = ddlCass1.SelectedValue;
                oracom.Parameters["p_CASS1_VALUE"].Value = txtCass1Value.Text;
            }

            if (txtCass2Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS2_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS2_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS2_CURR"].Value = ddlCass2.SelectedValue;
                oracom.Parameters["p_CASS2_VALUE"].Value = txtCass2Value.Text;
            }

            if (txtCass3Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS3_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS3_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS3_CURR"].Value = ddlCass3.SelectedValue;
                oracom.Parameters["p_CASS3_VALUE"].Value = txtCass3Value.Text;
            }

            if (txtCass4Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS4_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS4_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS4_CURR"].Value = ddlCass4.SelectedValue;
                oracom.Parameters["p_CASS4_VALUE"].Value = txtCass4Value.Text;
            }

            if (txtCass5Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS5_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS5_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS5_CURR"].Value = ddlCass5.SelectedValue;
                oracom.Parameters["p_CASS5_VALUE"].Value = txtCass5Value.Text;
            }

            if (txtCass6Value.Text.Length == 0)
            {
                oracom.Parameters["p_CASS6_CURR"].Value = OracleNumber.Null;
                oracom.Parameters["p_CASS6_VALUE"].Value = OracleNumber.Null;
            }
            else
            {
                oracom.Parameters["p_CASS6_CURR"].Value = ddlCass6.SelectedValue;
                oracom.Parameters["p_CASS6_VALUE"].Value = txtCass6Value.Text;
            }

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

            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;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "ATM_GROUP_EDITOR.update_atm_group","", "updateGroup", "rowID: " + rowID);
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return false;
        }
    }

    private bool deleteGroup(string GID, ref string error)
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "ATM_GROUP_EDITOR.delete_atm_group";

            oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_gid", OracleType.Number).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_gid"].Value = GID;

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

            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;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "ATM_GROUP_EDITOR.delete_atm_group","", "deleteGroup", "GID: " + GID);
            return false;
        }
    }

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[9].Visible = false;
            e.Row.Cells[10].Visible = false;
            e.Row.Cells[11].Visible = false;
            e.Row.Cells[12].Visible = false;
            e.Row.Cells[13].Visible = false;
            e.Row.Cells[18].Visible = false;
            e.Row.Cells[19].Visible = false;
            e.Row.Cells[20].Visible = false;
            e.Row.Cells[21].Visible = false;
            e.Row.Cells[22].Visible = false;
            e.Row.Cells[23].Visible = false;
        }
    }
    
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        ExceptionUtility.LogException(0, "", "", "GridView1_PageIndexChanging", "");
        loadGroups();
    }

    protected void btn_conf_ok_Click(object sender, EventArgs e)
    {
        string rowID = ViewState["selectedGroupID"].ToString();
        ViewState["mode"] = "d";
        string error = "";
        int chgId = loadChgID();       
        bool delete = false;
        ExceptionUtility.LogException(0, "", "", "btn_conf_ok_Click", "");
        delete = UpdateMakerChecker(chgId, rowID, "GID", rowID, "", "", "", 2, ref error);
        if(delete==true )        
        {
            ExceptionUtility.LogException(9, "", "", "btn_conf_ok_Click", "");
            lblError.Text = "Your request has been sent to Checker user for Approval";
        }
        else
        {
            if (Helper.OracleError(error))
            {
                lblError.Text = "An error occured!";
                ExceptionUtility.LogException(9, "", "", "btn_conf_ok_Click", error);
            }
            else
                lblError.Text = error;
            return;
        }

        this.pnlResult.Visible = true;
        this.pnl_confirmation.Visible = false;

        loadGroups();
    }
    protected void btn_conf_cancel_Click(object sender, EventArgs e)
    {
        this.pnlResult.Visible = true;
        this.pnl_confirmation.Visible = false;
        ExceptionUtility.LogException(0, "", "412.1", "btn_conf_cancel_Click", "");
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
        {

            int app_status = Convert.ToInt16(DataBinder.Eval(e.Row.DataItem, "app_status"));

            if (app_status == 0)
            {
                e.Row.Cells[15].Visible = true;
                e.Row.Cells[16].Visible = false;
                e.Row.Cells[17].Visible = false;
            }
            else
            {
                e.Row.Cells[15].Visible = false;
                e.Row.Cells[16].Visible = true;
                e.Row.Cells[17].Visible = true;
            }
        }

    }
    private bool UpdateMakerChecker(int chgId, string pkey, string columnName, string oldValue, string newValue, string oldValueNo, string NewValueNo, int chgType, ref string error)
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "MAKER_CHECKER_EDITOR.Add_Maker_Checker";

            oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_chg_id", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_chg_type", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_page_id", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_table_name", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_column_name", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_old_value", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_new_value", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_maker_id", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_made_on_date", OracleType.DateTime).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_checker_id", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_checked_on_date", OracleType.DateTime).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_changed_rec_id", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_chg_status", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_checker_notes", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_old_number", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_new_number", OracleType.Number).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_current_uid"].Value = Session["uid"].ToString();
            oracom.Parameters["p_page_id"].Value = page_id;
            oracom.Parameters["p_table_name"].Value = table_name;
            oracom.Parameters["p_chg_id"].Value = chgId;
            oracom.Parameters["p_chg_type"].Value = chgType;
            oracom.Parameters["p_column_name"].Value = columnName;
            oracom.Parameters["p_new_value"].Value = newValue;
            oracom.Parameters["p_old_value"].Value = oldValue;
            oracom.Parameters["p_maker_id"].Value = Session["uid"].ToString();
            oracom.Parameters["p_made_on_date"].Value = OracleDateTime.Null;
            oracom.Parameters["p_checker_id"].Value = OracleNumber.Null;
            oracom.Parameters["p_checked_on_date"].Value = OracleDateTime.Null;
            oracom.Parameters["p_changed_rec_id"].Value = pkey;
            oracom.Parameters["p_chg_status"].Value = 0;
            oracom.Parameters["p_checker_notes"].Value = OracleString.Null;

            if (oldValueNo.Trim() == "")
                oracom.Parameters["p_old_number"].Value = OracleNumber.Null;
            else
                oracom.Parameters["p_old_number"].Value = oldValueNo;
            if (NewValueNo.Trim() == "")
                oracom.Parameters["p_new_number"].Value = OracleNumber.Null;
            else
                oracom.Parameters["p_new_number"].Value = NewValueNo;

            oracom.Parameters["p_lang"].Value = "EN";

            oracom.ExecuteNonQuery();
            oracon.Close();
            string a = oracom.Parameters["p_res_code"].Value.ToString();
            error = oracom.Parameters["p_res_msg"].Value.ToString();
            if (a == "0")
            {
                ExceptionUtility.LogException(0, "MAKER_CHECKER_EDITOR.Add_Maker_Checker", "412.1", "UpdateMakerChecker", "chgId: " + chgId + ", pkey: " + pkey + ", columnName: " + columnName + ", oldValue: " + oldValue + " , newValue: " + newValue + " , oldValueNo: " + oldValueNo + ", NewValueNo: " + NewValueNo + " ,chgType: " + chgType);
                return true;
            }
            else
            {
                ExceptionUtility.LogException(9, "MAKER_CHECKER_EDITOR.Add_Maker_Checker", "412.1", "UpdateMakerChecker", "chgId: " + chgId + ", pkey: " + pkey + ", columnName: " + columnName + ", oldValue: " + oldValue + " , newValue: " + newValue + " , oldValueNo: " + oldValueNo + ", NewValueNo: " + NewValueNo + " ,chgType: " + chgType);
                return false;
            }
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "MAKER_CHECKER_EDITOR.Add_Maker_Checker","412.1", "UpdateMakerChecker", "chgId: " + chgId + ", pkey: " + pkey + ", columnName: " + columnName + ", oldValue: " + oldValue + " , newValue: " + newValue + " , oldValueNo: " + oldValueNo + ", NewValueNo: " + NewValueNo + " ,chgType: " + chgType);
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return false;
        }
    }
}
