Exemplo n.º 1
0
        protected void RPbtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    LRRRlblRoleResult.Visible = true;
                    RlblRoleResult.Text       = string.Empty;
                    string CampusID = string.Empty;
                    CampusID = Convert.ToString(Rddlcampus.SelectedValue);
                    if (RPbtnSave.Text == "Save")
                    {
                        if (DataAccessManager.CheckRole(RtxtRoleCode.Text, CampusID, "", "Role_Id") == false)
                        {
                            RlblRoleResult.Text = "Role code  exist!";
                            return;
                        }

                        Boolean status = DataAccessManager.SaveAddRoleDB(RtxtRoleCode.Text, txtRoleName.Text, CampusID);
                        if (status == true)
                        {
                            txtRoleName.Text     = string.Empty;
                            RtxtRoleCode.Text    = string.Empty;
                            RlblRoleResult.Text  = "Role save successfully!";
                            RtxtRoleCode.Enabled = true;
                        }
                        else
                        {
                            RlblRoleResult.Text  = "Execute Failed Please Try Again!";
                            RtxtRoleCode.Enabled = true;
                        }
                    }

                    if (RPbtnSave.Text == "Update")
                    {
                        string updateCampuID = string.Empty;
                        updateCampuID = Convert.ToString(ViewState["updateCampuID"]);
                        Boolean status = DataAccessManager.UpdateAddRoleDB(RtxtRoleCode.Text, txtRoleName.Text, CampusID, updateCampuID);
                        if (status == true)
                        {
                            txtRoleName.Text     = string.Empty;
                            RtxtRoleCode.Text    = string.Empty;
                            RPbtnSave.Text       = "Save";
                            RtxtRoleCode.Enabled = true;
                            RlblRoleResult.Text  = "Role update successfully!";
                        }
                        else
                        {
                            RlblRoleResult.Text  = "Execute Failed Please Try Again!";
                            RtxtRoleCode.Enabled = false;
                        }
                    }
                    if (Convert.ToString(Session["user_level"]) != "99")
                    {
                        BindRole(Convert.ToString(Session["CampusID"]));
                    }
                    else
                    {
                        BindRole("");
                        Rddlcampus.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }