Esempio n. 1
0
        public static List <ATTRoleMenus> GetRoleMenus(int ApplID, int RoleID, int FormID, int MenuID)
        {
            List <ATTRoleMenus> lstRoleMenus = new List <ATTRoleMenus>();

            foreach (DataRow row in DLLRoleMenus.GetRoleMenusTable(ApplID, RoleID, FormID, MenuID).Rows)
            {
                ATTRoleMenus RoleMenusObj = new ATTRoleMenus(int.Parse(row["ROLE_ID"].ToString()),
                                                             int.Parse(row["MENU_ID"].ToString()), int.Parse(row["APPL_ID"].ToString()),
                                                             int.Parse(row["FORM_ID"].ToString()), row["P_SELECT"].ToString(),
                                                             row["P_ADD"].ToString(), row["P_EDIT"].ToString(), row["P_DELETE"].ToString());
                //RoleMenusObj.MenuName = (string)(row["MENU_NAME"]);

                lstRoleMenus.Add(RoleMenusObj);
            }

            return(lstRoleMenus);
        }
        public static bool AddRoleMenus1(ATTRoleMenus objATT)
        {
            PCS.COREDL.GetConnection Conn = new GetConnection();
            OracleConnection         DBConn;

            try
            {
                DBConn = Conn.GetDbConn();

                string InsertUpdateSQL = "";

                if (objATT.RoleID <= 0)
                {
                    InsertUpdateSQL = "SP_ADD_ROLE_MENUS";
                }
                else
                {
                    InsertUpdateSQL = "SP_EDIT_ROLE_MENUS";
                }

                OracleParameter[] ParamArray = new OracleParameter[4];

                ParamArray[0] = Utilities.GetOraParam(":p_ROLE_ID", objATT.RoleID, OracleDbType.Int64, ParameterDirection.InputOutput);
                ParamArray[1] = Utilities.GetOraParam(":p_MENU_ID", objATT.MenuID, OracleDbType.Int64, ParameterDirection.InputOutput);
                ParamArray[2] = Utilities.GetOraParam(":p_APPL_ID", objATT.ApplicationID, OracleDbType.Int64, ParameterDirection.InputOutput);
                ParamArray[3] = Utilities.GetOraParam(":p_FORM_ID", objATT.FormID, OracleDbType.Int64, ParameterDirection.InputOutput);

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

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Conn.CloseDbConn();
            }
        }
Esempio n. 3
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();
        }
    }