Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                CustomList <SECURITY.DAO.SecurityRule> lstSecurityRule = SecurityRuleList;
                if (lstSecurityRule.Count == 0)
                {
                    SECURITY.DAO.SecurityRule newSecurityRule = new SECURITY.DAO.SecurityRule();
                    lstSecurityRule.Add(newSecurityRule);
                }

                SetDataControlsToSecurityRuleObject(ref lstSecurityRule);
                CustomList <SECURITY.DAO.Menu> AllMenu      = (CustomList <SECURITY.DAO.Menu>)Session["SecurityRule_MenuList"];
                CustomList <SECURITY.DAO.Menu> selectedMenu = AllMenu.FindAll(f => f.CanSelect || f.CanInsert || f.CanUpdate || f.CanDelete);
                objSecurityRuleDetailList = new CustomList <RuleDetails>();
                foreach (SECURITY.DAO.Menu m in selectedMenu)
                {
                    RuleDetails obj = new RuleDetails();
                    obj.ApplicationID = m.ApplicationID;
                    obj.ObjectID      = m.MenuID;
                    obj.ObjectType    = "menu";
                    obj.CanSelect     = m.CanSelect;
                    obj.CanInsert     = m.CanInsert;
                    obj.CanUpdate     = m.CanUpdate;
                    obj.CanDelete     = m.CanDelete;
                    objSecurityRuleDetailList.Add(obj);
                }
                //objSecurityRuleDetailList = SecurityRuleDetailList;
                if (!CheckUserAuthentication(lstSecurityRule, objSecurityRuleDetailList))
                {
                    return;
                }
                if (lstSecurityRule.IsNotNull())
                {
                    #region Delete
                    CustomList <RuleDetails> securityRuleObject = manager.GetAllSecurityRule_ObjectWithSecurityRule(lstSecurityRule[0].SecurityRuleCode);
                    if (securityRuleObject.Count != 0)
                    {
                        foreach (RuleDetails obj in securityRuleObject)
                        {
                            obj.Delete();
                        }
                        manager.TempSecurityRule_ObjectDelete(ref securityRuleObject);
                    }
                    #endregion

                    manager.SaveSecurityRule(ref lstSecurityRule, ref objSecurityRuleDetailList);
                    txtSecurityRuleCode.Text = manager.SecurityRuleInfoID;
                    this.SuccessMessage      = (StaticInfo.SavedSuccessfullyMsg);
                }
            }
            catch (SqlException ex)
            {
                this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex));
            }
            catch (Exception ex)
            {
                this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
            }
        }
Exemplo n.º 2
0
 private void SetDataControlsToSecurityRuleObject(ref CustomList <SECURITY.DAO.SecurityRule> securityRuleList)
 {
     try
     {
         SECURITY.DAO.SecurityRule objSecurityRule = securityRuleList[0];
         objSecurityRule.SecurityRuleCode = txtSecurityRuleCode.Text;
         objSecurityRule.SecurityRuleName = txtSecurityRuleName.Text;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
        //private void CheckedApplicationList()
        //{
        //    try
        //    {
        //        foreach (Application a in ApplicationList)
        //        {
        //            CustomList<RuleDetails> upDate = SecurityRuleDetailList.FindAll(f => f.ApplicationID == a.ApplicationID);
        //            CustomList<RuleDetails> newUpdate = new CustomList<RuleDetails>();
        //            newUpdate = upDate.FindAll(f => f.CanInsert == true || f.CanSelect == true || f.CanUpdate == true || f.CanDelete == true);
        //            if (newUpdate.Count != 0)
        //                a.IsSaved = true;
        //            else
        //                a.IsSaved = false;
        //        }
        //    }
        //    catch (Exception ex)
        //    {

        //        throw ex;
        //    }
        //}
        private void SetDataInControls(SECURITY.DAO.SecurityRule sR)
        {
            try
            {
                txtSecurityRuleCode.Text = sR.SecurityRuleCode.ToString();
                //cboCompany.SelectedValue = sR.CompanyID.ToString();
                txtSecurityRuleName.Text = sR.SecurityRuleName.ToString();
                //txtSecurityRuleDescription.Text = sR.SecurityRuleDescription.ToString();
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (IsPostBack.IsFalse())
         {
             InitializieCombo();
             ClearControls();
             InitializeSession();
             EnableAllControls(false);
             btnRefresh.Visible = false;
         }
         else
         {
             Page.ClientScript.GetPostBackEventReference(this, String.Empty);
             String eventTarget = Request["__EVENTTARGET"].IsNullOrEmpty() ? String.Empty : Request["__EVENTTARGET"];
             //if (eventTarget.Equals("SelectGridRow"))
             //{
             //    CustomList<ST.SECURITY.DAO.Menu> menu = manager.GetAllMenuByApplicationID(hfApplicationID.Value.ToString());
             //    MenuList = menu.FindAll(f => f.FormName != "");
             //    foreach (ST.SECURITY.DAO.Menu m in MenuList)
             //    {
             //        CustomList<RuleDetails> tSROList = SecurityRuleDetailList.FindAll(f => f.ObjectID == m.MenuID && f.ApplicationID == m.ApplicationID);
             //        foreach (RuleDetails tSRO in tSROList)
             //        {
             //            m.CanInsert = tSRO.CanInsert;
             //            m.CanSelect = tSRO.CanSelect;
             //            m.CanUpdate = tSRO.CanUpdate;
             //            m.CanDelete = tSRO.CanDelete;
             //        }
             //    }
             //}
             if (Request["__EVENTTARGET"] == "SearchSecurityRule")
             {
                 SECURITY.DAO.SecurityRule searchSecurityRule = Session[STATIC.StaticInfo.SearchSessionVarName] as SECURITY.DAO.SecurityRule;
                 objSecurityRuleList.Add(searchSecurityRule);
                 SecurityRuleList = objSecurityRuleList;
                 if (searchSecurityRule.IsNotNull())
                 {
                     PopulateSecurityRuleInformation(searchSecurityRule);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
        private void PopulateSecurityRuleInformation(SECURITY.DAO.SecurityRule sR)
        {
            try
            {
                SetDataInControls(sR);
                objSecurityRuleDetailList = manager.GetAllSecurityRule_ObjectWithSecurityRule(sR.SecurityRuleCode);
                SecurityRuleDetailList    = objSecurityRuleDetailList;
                if (SecurityRuleDetailList.Count != 0)
                {
                    cboApplication.SelectedValue = SecurityRuleDetailList[0].ApplicationID;

                    CustomList <SECURITY.DAO.Menu> menu = manager.GetAllMenuByApplicationID(SecurityRuleDetailList[0].ApplicationID);
                    MenuList = menu.FindAll(f => f.FormName != "");
                    CustomList <RuleDetails> tSROList = SecurityRuleDetailList.FindAll(f => f.ApplicationID == SecurityRuleDetailList[0].ApplicationID);
                    foreach (RuleDetails tSRO in tSROList)
                    {
                        CustomList <SECURITY.DAO.Menu> sMemuList = MenuList.FindAll(f => f.ApplicationID == tSRO.ApplicationID && f.MenuID == tSRO.ObjectID);
                        foreach (SECURITY.DAO.Menu m in sMemuList)
                        {
                            m.CanInsert = tSRO.CanInsert;
                            m.CanSelect = tSRO.CanSelect;
                            m.CanUpdate = tSRO.CanUpdate;
                            m.CanDelete = tSRO.CanDelete;
                        }
                    }
                }

                //if (SecurityRuleDetailList.Count != 0)
                //{
                //    foreach (RuleDetails sRO in SecurityRuleDetailList)
                //    {
                //        TempRuleDetails objNewSRO = new TempRuleDetails();
                //        objNewSRO.ApplicationID = sRO.ApplicationID;
                //        objNewSRO.ObjectID = sRO.ObjectID;
                //        objNewSRO.ObjectType = "Menu";
                //        objNewSRO.CanInsert = sRO.CanInsert;
                //        objNewSRO.CanSelect = sRO.CanSelect;
                //        objNewSRO.CanUpdate = sRO.CanUpdate;
                //        objNewSRO.CanDelete = sRO.CanDelete;
                //        TempSecurityRuleDetailList.Add(objNewSRO);
                //    }
                //}

                //CheckedApplicationList();
                //foreach (Application a in ApplicationList)
                //{
                //    if (a.IsSaved == true)
                //    {
                //CustomList<ST.SECURITY.DAO.Menu> menu = manager.GetAllMenuByApplicationID(a.ApplicationID);
                //MenuList = menu.FindAll(f => f.FormName != "");
                //CustomList<RuleDetails> tSROList = SecurityRuleDetailList.FindAll(f => f.ApplicationID == a.ApplicationID);
                //foreach (RuleDetails tSRO in tSROList)
                //{
                //    CustomList<ST.SECURITY.DAO.Menu> sMemuList = MenuList.FindAll(f => f.ApplicationID == tSRO.ApplicationID && f.MenuID == tSRO.ObjectID);
                //    foreach (ST.SECURITY.DAO.Menu m in sMemuList)
                //    {
                //        m.CanInsert = tSRO.CanInsert;
                //        m.CanSelect = tSRO.CanSelect;
                //        m.CanUpdate = tSRO.CanUpdate;
                //        m.CanDelete = tSRO.CanDelete;
                //    }
                //}
                //break;
                //    }
                //}
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                CustomList<SECURITY.DAO.SecurityRule> lstSecurityRule = SecurityRuleList;
                if (lstSecurityRule.Count == 0)
                {
                    SECURITY.DAO.SecurityRule newSecurityRule = new SECURITY.DAO.SecurityRule();
                    lstSecurityRule.Add(newSecurityRule);
                }

                SetDataControlsToSecurityRuleObject(ref lstSecurityRule);
                CustomList<SECURITY.DAO.Menu> AllMenu = (CustomList<SECURITY.DAO.Menu>)Session["SecurityRule_MenuList"];
                CustomList<SECURITY.DAO.Menu> selectedMenu = AllMenu.FindAll(f => f.CanSelect || f.CanInsert || f.CanUpdate || f.CanDelete);
                objSecurityRuleDetailList = new CustomList<RuleDetails>();
                foreach (SECURITY.DAO.Menu m in selectedMenu)
                {
                    RuleDetails obj = new RuleDetails();
                    obj.ApplicationID = m.ApplicationID;
                    obj.ObjectID = m.MenuID;
                    obj.ObjectType = "menu";
                    obj.CanSelect = m.CanSelect;
                    obj.CanInsert = m.CanInsert;
                    obj.CanUpdate = m.CanUpdate;
                    obj.CanDelete = m.CanDelete;
                    objSecurityRuleDetailList.Add(obj);
                }
                //objSecurityRuleDetailList = SecurityRuleDetailList;
                if (!CheckUserAuthentication(lstSecurityRule, objSecurityRuleDetailList)) return;
                if (lstSecurityRule.IsNotNull())
                {
                    #region Delete
                    CustomList<RuleDetails> securityRuleObject = manager.GetAllSecurityRule_ObjectWithSecurityRule(lstSecurityRule[0].SecurityRuleCode);
                    if (securityRuleObject.Count != 0)
                    {
                        foreach (RuleDetails obj in securityRuleObject)
                        {
                            obj.Delete();
                        }
                        manager.TempSecurityRule_ObjectDelete(ref securityRuleObject);
                    }
                    #endregion

                    manager.SaveSecurityRule(ref lstSecurityRule, ref objSecurityRuleDetailList);
                    txtSecurityRuleCode.Text = manager.SecurityRuleInfoID;
                    this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg);
                }
            }
            catch (SqlException ex)
            {
                this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex));
            }
            catch (Exception ex)
            {
                this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
            }
        }
Exemplo n.º 7
0
        public static CustomList<SecurityRule> doSearch(string whereClause)
        {
            ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan);
            CustomList<SecurityRule> tblSecurityRuleCollection = new CustomList<SecurityRule>();
            IDataReader reader = null;
            String sql = string.Format("Select * from [Rule] Where 1=1 {0}", whereClause);

            try
            {
                conManager.OpenDataReader(sql, out reader);
                while (reader.Read())
                {
                    SecurityRule newtblSecurityRule = new SecurityRule();
                    newtblSecurityRule.SetData(reader);
                    tblSecurityRuleCollection.Add(newtblSecurityRule);
                }
                return tblSecurityRuleCollection;
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }
        }