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;

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

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            //HttpContext.Current.Session["mode"] = "l";
            //Session["uid"] = "1";
            //ExceptionUtility.LogException(0, "", "55", "Page_Load", "");
            getGroups();
            getUsers();
        }
    }

    private void getGroups()
    {
        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 = "SEC_GROUP_MAINTAIN.Get_Sec_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.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;


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

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

            oracon.Close();

            //GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
            RadioButtonList1.DataSource = ds;
            RadioButtonList1.DataBind();

            RadioButtonList1.SelectedIndex = 0;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex);
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

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

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "sec_user_maintain.get_sec_user";

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


        oracom.Parameters["p_user_id"].Value = OracleString.Null;
        oracom.Parameters["p_user_name"].Value = OracleString.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();
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("a"))
        {
            Lbl_CommandName.Text = "a";
            Lbl_CommandArgument.Text = e.CommandArgument.ToString();
            Lbl_URC_Message.Text = "Are you sure you want to Approve ?";

            Notifications.showModal("UR-confirmation-modal-xl", this);
        }
        else if (e.CommandName.Equals("u"))
        {
            Lbl_CommandName.Text = "u";
            Lbl_CommandArgument.Text = e.CommandArgument.ToString();
            Lbl_URC_Message.Text = "Are you sure you want to Update ?";

            Notifications.showModal("UR-confirmation-modal-xl", this);
        }
        else if (e.CommandName.Equals("d"))
        {
            Lbl_CommandName.Text = "d";
            Lbl_CommandArgument.Text = e.CommandArgument.ToString();
            Lbl_URC_Message.Text = "Are you sure you want to Delete ?";

            Notifications.showModal("UR-confirmation-modal-xl", this);
        }
        else if (e.CommandName.Equals("r"))
        {
            Lbl_CommandName.Text = "r";
            Lbl_CommandArgument.Text = e.CommandArgument.ToString();
            Lbl_URC_Message.Text = "Are you sure you want to Reset ?";

            Notifications.showModal("UR-confirmation-modal-xl", this);
        }
        else if (e.CommandName.Equals("decline"))
        {
            Lbl_CommandName.Text = "decline";
            Lbl_CommandArgument.Text = e.CommandArgument.ToString();
            Lbl_URC_Message.Text = "Are you sure you want to Decline ?";

            Notifications.showModal("UR-confirmation-modal-xl", this);
        }
    }

    protected void btn_URConfirm_OK_Click(object sender, EventArgs e)
    {
        if (Lbl_CommandName.Text == "a")
        {
            //int index = int.Parse(e.CommandArgument.ToString());
            int index = int.Parse(Lbl_CommandArgument.Text);
            string Uid = GridView1.DataKeys[index].Value.ToString();
            string error = "";
            bool temp = approveUser(Uid, ref error);
            if (temp)
            {
                //lblError.Text = "User status updated";
                Notifications.showMessage("User status updated", this, Notifications.successMessage, false);
                return;
            }
            else
            {
                //lblError.Text = error;
                Notifications.showMessage(error, this, Notifications.errorMessage, false);
                return;
            }
            getUsers();
        }
        else if (Lbl_CommandName.Text == "u")
        {
            //int index = int.Parse(e.CommandArgument.ToString());
            int index = int.Parse(Lbl_CommandArgument.Text);
            string Uid = GridView1.DataKeys[index].Value.ToString();
            ViewState["mode"] = "u";
            //pnlControls.Visible = true;
            //pnlGrid.Enabled = false;


            //this.lbl_addUpdateLegandText.Text = "Update User \"" + GridView1.Rows[index].Cells[2].Text + "\"";

            ViewState["uid"] = Uid;
            //put the data in the controls
            txtUserID.Text = GridView1.Rows[index].Cells[1].Text;
            txtUserName.Text = GridView1.Rows[index].Cells[2].Text;

            txtPass1.Attributes.Add("value", GridView1.Rows[index].Cells[3].Text);
            txtPass2.Attributes.Add("value", GridView1.Rows[index].Cells[3].Text);

            RadioButtonList1.SelectedValue = GridView1.Rows[index].Cells[6].Text;

            int status = int.Parse(GridView1.Rows[index].Cells[12].Text);
            if (status == 1)
                rdActive.Checked = true;
            else
                rdInActive.Checked = true;

            string DBSecurity = Helper.getParamByID("200");
            if (DBSecurity.Equals("DB"))
            {
                txtPass1.Enabled = true;
                txtPass2.Enabled = true;
            }
            else
            {
                txtPass1.Enabled = false;
                txtPass2.Enabled = false;
            }
            txtUserID.Enabled = false;

            string super = GridView1.Rows[index].Cells[11].Text;

            if (super == "1")
                chkSuper.Checked = true;
            else
                chkSuper.Checked = false;

            Notifications.showModal("modal-xl", this);
        }
        else if (Lbl_CommandName.Text == "d")
        {
            //int index = int.Parse(e.CommandArgument.ToString());
            int index = int.Parse(Lbl_CommandArgument.Text);
            string Uid = GridView1.DataKeys[index].Value.ToString();
            string error = "";
            bool temp = deleteUser(Uid, ref error);
            if (temp)
            {

                //lblError.Text = "User status updated";
                Notifications.showMessage("User status updated", this, Notifications.successMessage, false);
                return;
            }
            else
            {
                ExceptionUtility.LogException(9, "", "55.429", "GridView1_RowCommand.APPROVE", "");
                //lblError.Text = error;
                Notifications.showMessage(error, this, Notifications.errorMessage, false);
                return;
            }
            getUsers();
        }
        else if (Lbl_CommandName.Text == "r")
        {

        }
        else if (Lbl_CommandName.Text == "decline")
        {
            //int index = int.Parse(e.CommandArgument.ToString());
            int index = int.Parse(Lbl_CommandArgument.Text);
            string Uid = GridView1.DataKeys[index].Value.ToString();
            string error = "";
            //ExceptionUtility.LogException(0, "", "55.430", "GridView1_RowCommand.DECLINE", "");
            bool temp = declineUser(Uid, ref error);
            if (temp)
            {
                //lblError.Text = "User status updated";
                Notifications.showMessage("User status updated", this, Notifications.successMessage, false);
                return;
            }
            else
            {
                {
                    //lblError.Text = error;
                    Notifications.showMessage(error, this, Notifications.errorMessage, false);
                    return;
                }
            }
            getUsers();
        }
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            ViewState["mode"] = "a";

            //this.lbl_addUpdateLegandText.Text = "Add New Group";

            //pnlControls.Visible = true;
            //pnlGrid.Enabled = false;
            clearControls();
            //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>$('#modal-xl').modal('show');</script>", false);
            Notifications.showModal("modal-xl", this);

            //ExceptionUtility.LogException(0, "", "55.283", "btnAdd_Click", "");
        }
        catch (Exception ex)
        {
            //ExceptionUtility.LogException(ex, "", "55.283", "btnAdd_Click", "");
        }
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        try
        {
            ViewState["mode"] = null;
            ViewState["uid"] = null;
            //pnlControls.Visible = false;
            //pnlGrid.Enabled = true;
            clearControls();
            //ExceptionUtility.LogException(0, "", "", "btnCancel_Click", "");
        }
        catch (Exception ex)
        {
            //ExceptionUtility.LogException(ex, "", "", "btnCancel_Click", "");
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            

            string mode = ViewState["mode"].ToString();
            string error = "";
            if (mode.Equals("a"))
            {
                //ExceptionUtility.LogException(0, "", "55.431", "btnSave_Click", "");
                bool saved = addUser(ref error);
                if (saved)
                {
                    Notifications.showMessage("User Saved", this, Notifications.successMessage, true);
                }
                else
                {
                        //lblError.Text = error;
                        Notifications.showMessage(error, this, Notifications.errorMessage, true);
                }
            }
            else if (mode.Equals("u"))
            {
                string Uid = ViewState["uid"].ToString();
                string status = "";
                if (rdActive.Checked)
                    status = "1";
                else
                    status = "0";
                //ExceptionUtility.LogException(0, "", "55.431", "btnSave_Click", "");
                bool saved = updateUser(ref error);
                if (saved)
                {
                    Notifications.showMessage("User Saved", this, Notifications.successMessage, true);
                }
                else
                {
                        Notifications.showMessage("An Error Occured!", this, Notifications.errorMessage, true);
                        //ExceptionUtility.LogException(9, "", "55.432", "btnSave_Click", error);
                    
                }
            }
            getUsers();
            ViewState["mode"] = null;
            ViewState["uid"] = null;

            clearControls();
            //Notifications.hideModal("modal-xl", this);

        }
        catch (Exception ex)
        {
            if (ex.Message.Equals("ORA-00001: unique constraint (NCB.SEC_USER_UK) violated\n"))
            {
                //this user id already exists...
                //setMessage("This group name already exists");
                Notifications.showMessage("This User name already exists", this, Notifications.errorMessage, true);

            }
            else
            {
                //ExceptionUtility.LogException(ex, "", "", "btnSave_Click", "");
                Notifications.showMessage(ex.Message, this, Notifications.errorMessage, true);
            }
        }
        finally
        {
            
        }
    }

    #region Business Functions

    private void clearControls()
    {
        txtPass1.Text = "";
        txtPass2.Text = "";
        txtPass1.Attributes["value"] = "";
        txtPass2.Attributes["value"] = "";
        txtUserID.Text = "";
        txtUserName.Text = "";
        RadioButtonList1.SelectedIndex = 0;
        chkSuper.Checked = false;
    }

    #endregion

    private void setMessage(string message)
    {
        ClientScript.RegisterClientScriptBlock(typeof(Button), "hello", "alert('" + message + "');", true);
    }

    
    protected void GridView1_PreRender(object sender, EventArgs e)
    {
        if (GridView1.Rows.Count > 0)
        {
            GridView1.UseAccessibleHeader = true;
            GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
        }
    }
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        //if (e.Row.RowType == DataControlRowType.DataRow)
        //{
        //    //Button pop = e.Row.FindControl("pop") as Button;
        //    //pop.CommandArgument = e.Row.RowIndex.ToString();
        //}
        if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Visible = false;
            e.Row.Cells[3].Visible = false;
            e.Row.Cells[4].Visible = false;
            e.Row.Cells[5].Visible = false;
            e.Row.Cells[6].Visible = false;
            e.Row.Cells[11].Visible = false;
            e.Row.Cells[12].Visible = false;
        }
    }

    private bool deleteUser(string UserID, ref string error)
    {
        //if (Request["x"] == null || Request["y"] == null)
        // {
        //     Response.End();
        // }
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "sec_user_maintain.delete_sec_user";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_uid", 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_uid"].Value = UserID;
        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;
    }
    private bool addUser(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 = "sec_user_maintain.create_sec_user";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_user_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_user_name", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_password", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_super_user", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_USER_TEL_NO", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_TEL_EXTEN", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_gid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_status", 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_user_id"].Value = txtUserID.Text;
        oracom.Parameters["p_user_name"].Value = txtUserName.Text;
        oracom.Parameters["p_USER_TEL_NO"].Value = USER_TEL_NO.Text;
        oracom.Parameters["p_TEL_EXTEN"].Value = TEL_EXTEN.Text;
        oracom.Parameters["p_password"].Value = Helper.DecPassword(txtPass1.Text);
        oracom.Parameters["p_gid"].Value = RadioButtonList1.SelectedValue;
        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        if (chkSuper.Checked)
            oracom.Parameters["p_super_user"].Value = "1";
        else
            oracom.Parameters["p_super_user"].Value = "0";

        if (rdActive.Checked)
            oracom.Parameters["p_status"].Value = "1";
        else
            oracom.Parameters["p_status"].Value = "0";

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

    private bool updateUser(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 = "SEC_USER_MAINTAIN.Update_Sec_User";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_user_name", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_super_user", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_USER_TEL_NO", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_TEL_EXTEN", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_gid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_status", 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;

        string Uid = ViewState["uid"].ToString();
        oracom.Parameters["p_uid"].Value = Uid;
        oracom.Parameters["p_user_name"].Value = txtUserName.Text;
        oracom.Parameters["p_USER_TEL_NO"].Value = USER_TEL_NO.Text;
        oracom.Parameters["p_TEL_EXTEN"].Value = TEL_EXTEN.Text;
        string status = "";
        if (rdActive.Checked)
            status = "1";
        else
            status = "0";

        if (chkSuper.Checked)
            oracom.Parameters["p_super_user"].Value = "1";
        else
            oracom.Parameters["p_super_user"].Value = "0";

        oracom.Parameters["p_status"].Value = status;
        oracom.Parameters["p_gid"].Value = RadioButtonList1.SelectedValue;
        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;
    }

    private bool approveUser(string UserID, ref string error)
    {
        //if (Request["x"] == null || Request["y"] == null)
        // {
        //     Response.End();
        // }
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "sec_user_maintain.approve_sec_user";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_uid", 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_uid"].Value = UserID;
        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;
    }
    private bool declineUser(string UserID, ref string error)
    {
        //if (Request["x"] == null || Request["y"] == null)
        // {
        //     Response.End();
        // }
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "sec_user_maintain.decline_sec_user";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_uid", 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_uid"].Value = UserID;
        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;
    }
}