Esempio n. 1
0
        public static ObjectValidation Validate(ATTRoles roleObj)
        {
            ObjectValidation OV = new ObjectValidation();

            if (roleObj.ApplicationID == 0)
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Application cannot be blank. Select any one application. asdas dasdasdasd asdasd";
                return(OV);
            }

            if (roleObj.RoleName == "")
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Role name cannot be blank.";
                return(OV);
            }

            if (roleObj.RoleDescription == "")
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Role description cannot be blank.";
                return(OV);
            }

            return(OV);
        }
Esempio n. 2
0
        public static List <ATTRoles> GetApplicationRoles(int ApplID)
        {
            try
            {
                List <ATTRoles> LstAppl = new List <ATTRoles>();

                foreach (DataRow row in DLLRoles.GetApplicationRoleTable(ApplID, null).Rows)
                {
                    ATTRoles objRoles = new ATTRoles
                                        (
                        int.Parse(row["ROLE_ID"].ToString()),
                        int.Parse(row["Appl_ID"].ToString()),
                        (string)row["ROLE_Name"].ToString(),
                        (string)row["ROLE_Description"].ToString(),
                        "E"
                                        );

                    LstAppl.Add(objRoles);
                }



                return(LstAppl);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
 public bool SaveRoles(ATTRoles objRoles)
 {
     try
     {
         PCS.SECURITY.DLL.DLLRoles.AddRoles(objRoles);
         return(true);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 4
0
        private static List <ATTRoles> GetRolesList(int applID, int roleID)
        {
            List <ATTRoles> lstRoles = new List <ATTRoles>();

            foreach (DataRow row in DLLRoles.GetApplicationRoleTable(null, null).Rows)
            {
                ATTRoles RolesObj = new ATTRoles(int.Parse(row["ROLE_ID"].ToString()),
                                                 int.Parse(row["APPL_ID"].ToString()), (string)row["ROLE_NAME"],
                                                 (string)row["ROLE_DESCRIPTION"], "");
                lstRoles.Add(RolesObj);

                return(lstRoles);
            }

            return(lstRoles);
        }
Esempio n. 5
0
        public static List <ATTRoles> GetRolesAndMenus(int applID, int roleID)
        {
            List <ATTRoles>     lstRoles      = new List <ATTRoles>();
            List <ATTRoleMenus> lstRolesMenus = BLLRoleMenus.GetRoleMenus(-1, -1, -1, -1);

            foreach (DataRow row in DLLRoles.GetApplicationRoleTable(null, null).Rows)
            {
                ATTRoles obj = new ATTRoles(int.Parse(row["ROLE_ID"].ToString()),
                                            int.Parse(row["APPL_ID"].ToString()), (string)row["ROLE_NAME"],
                                            (string)row["ROLE_DESCRIPTION"], "");

                obj.LstRoleMenus = lstRolesMenus.FindAll(delegate(ATTRoleMenus rolemnu) { return(rolemnu.ApplicationID == obj.ApplicationID && rolemnu.RoleID == obj.RoleID); });

                lstRoles.Add(obj);
            }

            return(lstRoles);
        }
Esempio n. 6
0
        public static bool AddRoles(ATTRoles objATT)
        {
            PCS.COREDL.GetConnection Conn = new GetConnection();
            OracleConnection         DBConn;

            try
            {
                DBConn = Conn.GetDbConn();

                string InsertUpdateSQL = "";

                if (objATT.RoleID <= 0)
                {
                    InsertUpdateSQL = "SP_ADD_ROLES";
                }
                else
                {
                    InsertUpdateSQL = "SP_EDIT_ROLES";
                }

                OracleParameter[] ParamArray = new OracleParameter[4];

                ParamArray[0] = Utilities.GetOraParam(":p_APPL_ID", objATT.ApplicationID, OracleDbType.Int64, ParameterDirection.Input);
                ParamArray[1] = Utilities.GetOraParam(":p_ROLE_ID", objATT.RoleID, OracleDbType.Int64, ParameterDirection.InputOutput);
                ParamArray[2] = Utilities.GetOraParam(":p_ROLE_NAME", objATT.RoleName, OracleDbType.Varchar2, ParameterDirection.Input);
                ParamArray[3] = Utilities.GetOraParam(":p_ROLE_DESCRIPTION", objATT.RoleDescription, OracleDbType.Varchar2, ParameterDirection.Input);

                SqlHelper.ExecuteNonQuery(DBConn, CommandType.StoredProcedure, InsertUpdateSQL, ParamArray);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Conn.CloseDbConn();
            }
        }
Esempio n. 7
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            lblStatusMessage.Text = "";

            List <ATTApplication> lstApplicationsDetails = (List <ATTApplication>)Session["ApplicationsRolesMenusList"];

            int?roleID = 0;
            if (this.lstRoles.SelectedIndex > -1)
            {
                roleID = lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles[this.lstRoles.SelectedIndex].RoleID;
            }

            List <ATTRoles>     lstRoles     = new List <ATTRoles>();
            List <ATTRoleMenus> lstRoleMenus = new List <ATTRoleMenus>();

            ATTRoles RolesAtt = new ATTRoles(roleID, int.Parse(this.ddlApplication_Rqd.SelectedValue.ToString()),
                                             this.txtRoleName_Rqd.Text, this.txtRoleDesc_Rqd.Text, "");
            ATTRoleMenus RoleMenus = new ATTRoleMenus();

            if (!BLLRoles.Validate(RolesAtt).IsValid)
            {
                this.lblStatusMessage.Text = BLLRoles.Validate(RolesAtt).ErrorMessage.ToString();
                this.programmaticModalPopup.Show();
                return;
            }
            lstRoles.Add(RolesAtt);

            #region "DATABASE PART"
            foreach (GridViewRow row in this.grdApplMenus.Rows)
            {
                string strAction    = "";
                string strUpdate    = "";
                string strOldUpdate = "";

                CheckBox cbSelMnu     = (CheckBox)(row.Cells[5].FindControl("chkSelectMenu"));
                CheckBox cbOldSelMnu  = (CheckBox)(row.Cells[6].FindControl("chkOldSelectMenu"));
                CheckBox cbAddMnu     = (CheckBox)(row.Cells[7].FindControl("chkAddMenu"));
                CheckBox cbOldAddMnu  = (CheckBox)(row.Cells[8].FindControl("chkOldAddMenu"));
                CheckBox cbEditMnu    = (CheckBox)(row.Cells[9].FindControl("chkEditMenu"));
                CheckBox cbOldEditMnu = (CheckBox)(row.Cells[10].FindControl("chkOldEditMenu"));
                CheckBox cbDelMnu     = (CheckBox)(row.Cells[11].FindControl("chkDelMenu"));
                CheckBox cbOldDelMnu  = (CheckBox)(row.Cells[12].FindControl("chkOldDelMenu"));

                if (((cbSelMnu.Checked) || (cbAddMnu.Checked) || (cbEditMnu.Checked) || (cbDelMnu.Checked)) &&
                    ((!cbOldSelMnu.Checked) && (!cbOldAddMnu.Checked) && (!cbOldEditMnu.Checked) && (!cbOldDelMnu.Checked)))
                {
                    strAction = "A";
                }

                else if (((!cbSelMnu.Checked) && (!cbAddMnu.Checked) && (!cbEditMnu.Checked) && (!cbDelMnu.Checked)) &&
                         ((cbOldSelMnu.Checked) || (cbOldAddMnu.Checked) || (cbOldEditMnu.Checked) || (cbOldDelMnu.Checked)))
                {
                    strAction = "D";
                }
                else
                {
                    if (cbSelMnu.Checked)
                    {
                        strUpdate += "S";
                    }
                    if (cbAddMnu.Checked)
                    {
                        strUpdate += "A";
                    }
                    if (cbEditMnu.Checked)
                    {
                        strUpdate += "E";
                    }
                    if (cbDelMnu.Checked)
                    {
                        strUpdate += "D";
                    }

                    if (cbOldSelMnu.Checked)
                    {
                        strOldUpdate += "S";
                    }
                    if (cbOldAddMnu.Checked)
                    {
                        strOldUpdate += "A";
                    }
                    if (cbOldEditMnu.Checked)
                    {
                        strOldUpdate += "E";
                    }
                    if (cbOldDelMnu.Checked)
                    {
                        strOldUpdate += "D";
                    }

                    if (strUpdate != strOldUpdate)
                    {
                        strAction = "E";
                    }
                }

                if (strAction != "")
                {
                    RoleMenus = new ATTRoleMenus(roleID, int.Parse(row.Cells[2].Text.ToString()),
                                                 int.Parse(row.Cells[0].Text.ToString()), int.Parse(row.Cells[1].Text.ToString()),
                                                 (cbSelMnu.Checked == true ? "Y" : "N"), (cbAddMnu.Checked == true ? "Y" : "N"),
                                                 (cbEditMnu.Checked == true ? "Y" : "N"), (cbDelMnu.Checked == true ? "Y" : "N"));
                    RoleMenus.Action = strAction;
                    RolesAtt.LstRoleMenus.Add(RoleMenus);
                }
            }
            int newroleID = 0;
            newroleID = BLLRoles.AddRolesAndRoleMenus(lstRoles);
            #endregion

            #region "UPDATE SESSION LIST"
            if (this.lstRoles.SelectedIndex > -1)
            {
                lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles[this.lstRoles.SelectedIndex].RoleID          = newroleID;
                lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles[this.lstRoles.SelectedIndex].ApplicationID   = int.Parse(this.ddlApplication_Rqd.SelectedValue.ToString());
                lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles[this.lstRoles.SelectedIndex].RoleName        = this.txtRoleName_Rqd.Text.Trim();
                lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles[this.lstRoles.SelectedIndex].RoleDescription = this.txtRoleDesc_Rqd.Text.Trim();
                lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles[this.lstRoles.SelectedIndex].LstRoleMenus.Clear();
                foreach (GridViewRow row in this.grdApplMenus.Rows)
                {
                    CheckBox cbSelMnu     = (CheckBox)(row.Cells[5].FindControl("chkSelectMenu"));
                    CheckBox cbOldSelMnu  = (CheckBox)(row.Cells[6].FindControl("chkOldSelectMenu"));
                    CheckBox cbAddMnu     = (CheckBox)(row.Cells[7].FindControl("chkAddMenu"));
                    CheckBox cbOldAddMnu  = (CheckBox)(row.Cells[8].FindControl("chkOldAddMenu"));
                    CheckBox cbEditMnu    = (CheckBox)(row.Cells[9].FindControl("chkEditMenu"));
                    CheckBox cbOldEditMnu = (CheckBox)(row.Cells[10].FindControl("chkOldEditMenu"));
                    CheckBox cbDelMnu     = (CheckBox)(row.Cells[11].FindControl("chkDelMenu"));
                    CheckBox cbOldDelMnu  = (CheckBox)(row.Cells[12].FindControl("chkOldDelMenu"));
                    RoleMenus = new ATTRoleMenus(roleID, int.Parse(row.Cells[2].Text.ToString()),
                                                 int.Parse(row.Cells[0].Text.ToString()), int.Parse(row.Cells[1].Text.ToString()),
                                                 (cbSelMnu.Checked == true ? "Y" : "N"), (cbAddMnu.Checked == true ? "Y" : "N"),
                                                 (cbEditMnu.Checked == true ? "Y" : "N"), (cbDelMnu.Checked == true ? "Y" : "N"));
                    lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles[this.lstRoles.SelectedIndex].LstRoleMenus.Add(RoleMenus);
                }
            }
            else
            {
                RolesAtt = new ATTRoles(newroleID, int.Parse(this.ddlApplication_Rqd.SelectedValue.ToString()),
                                        this.txtRoleName_Rqd.Text, this.txtRoleDesc_Rqd.Text, "");
                foreach (GridViewRow row in this.grdApplMenus.Rows)
                {
                    CheckBox cbSelMnu     = (CheckBox)(row.Cells[5].FindControl("chkSelectMenu"));
                    CheckBox cbOldSelMnu  = (CheckBox)(row.Cells[6].FindControl("chkOldSelectMenu"));
                    CheckBox cbAddMnu     = (CheckBox)(row.Cells[7].FindControl("chkAddMenu"));
                    CheckBox cbOldAddMnu  = (CheckBox)(row.Cells[8].FindControl("chkOldAddMenu"));
                    CheckBox cbEditMnu    = (CheckBox)(row.Cells[9].FindControl("chkEditMenu"));
                    CheckBox cbOldEditMnu = (CheckBox)(row.Cells[10].FindControl("chkOldEditMenu"));
                    CheckBox cbDelMnu     = (CheckBox)(row.Cells[11].FindControl("chkDelMenu"));
                    CheckBox cbOldDelMnu  = (CheckBox)(row.Cells[12].FindControl("chkOldDelMenu"));
                    RoleMenus = new ATTRoleMenus(roleID, int.Parse(row.Cells[2].Text.ToString()),
                                                 int.Parse(row.Cells[0].Text.ToString()), int.Parse(row.Cells[1].Text.ToString()),
                                                 (cbSelMnu.Checked == true ? "Y" : "N"), (cbAddMnu.Checked == true ? "Y" : "N"),
                                                 (cbEditMnu.Checked == true ? "Y" : "N"), (cbDelMnu.Checked == true ? "Y" : "N"));
                    RolesAtt.LstRoleMenus.Add(RoleMenus);
                }
                lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles.Add(RolesAtt);
            }
            this.lstRoles.DataSource = lstApplicationsDetails[this.ddlApplication_Rqd.SelectedIndex].LstRoles;
            this.lstRoles.DataBind();
            lstRoles_SelectedIndexChanged(sender, e);
            #endregion
            this.lblStatusMessage.Text = "Role Details Successfully Saved.";
            this.programmaticModalPopup.Show();
        }


        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message;
            this.programmaticModalPopup.Show();
        }
    }