Esempio n. 1
0
        void BtnewruleClick(object sender, EventArgs e)
        {
            Button b = (Button)sender;

            if (b.Text.Equals("Save") && !tbrulename.Text.Equals(""))
            {
                RuleC rule = new RuleC();

                PermissionTableC pt     = new PermissionTableC();
                StoreC           stores = new StoreC();
                StoreRulesC      src    = new StoreRulesC();
                rule.Insert(new Rules()
                {
                    Name  = tbrulename.Text,
                    Descr = tbrulenote.Text
                });
                int id = rule.GetRuleByName(tbrulename.Text).Id;
                pt.InsertList(new DefaultValues().GetDefaultPermission(new Rules()
                {
                    Id = id
                }));
                src.InsertList(stores.GetStore(), new Rules()
                {
                    Id = id
                });
                ShowRuleAsListView();
            }
            else
            {
                //	EnableItem();

                tbrulename.Enabled = true;
                tbrulenote.Enabled = true;
                tbrulename.Text    = "";
                b.Text             = "Save";
            }
        }
        void CbruleSelectedIndexChanged(object sender, EventArgs e)
        {
            PermissionTableC pts   = new PermissionTableC();
            RuleC            rules = new RuleC();
            StoreC           ssc   = new StoreC();
            StoreRulesC      src   = new StoreRulesC();


            Rules             rule = rules.GetRuleByName(cbrule.Text);
            List <Permission> lpt  = pts.GetPermissionTable(rule);
            List <StoreRules> lsr  = src.GetStoreRule(rule);

            _rule.Id = rule.Id;
            ComboBox b = (ComboBox)sender;

            tvfalse.Nodes.Clear();
            tvtrue.Nodes.Clear();
            tvstorefalse.Nodes.Clear();
            tvstoretrue.Nodes.Clear();

            src = new StoreRulesC();
            if (ssc.Count() > src.Count(_rule.Id))
            {
                Debug.WriteLine("Store In DataBase More Than StoreRules Store=" + ssc.Count() + " StoreRules=" + src.Count(_rule.Id));

                StoreC      stores = new StoreC();
                StoreRulesC sRc    = new StoreRulesC();
                sRc.InsertList(stores.GetStore(), new Rules()
                {
                    Id = _rule.Id
                });
            }
            else
            {
                Debug.WriteLine("Store In DataBase Less Than StoreRulesStore=" + ssc.Count() + " StoreRules=" + src.Count(_rule.Id));
            }

            foreach (Permission pt in lpt)
            {
                if (pt.Rule_id != 1)
                {
                    if (pt.Values.Equals("0"))
                    {
                        var tvfalsenode = new TreeNode(pt.Name);
                        tvfalse.Nodes.Add(tvfalsenode);
                    }
                    else
                    {
                        var tvtruenode = new TreeNode(pt.Name);
                        tvtrue.Nodes.Add(tvtruenode);
                    }
                }
            }

            foreach (StoreRules sr in lsr)
            {
                StoreC storec = new StoreC();
                Store  sstore = storec.GetOneStore(new Store()
                {
                    Id = sr.Store_id
                });
                if (sr.Rules_id != 1)
                {
                    if (sr.Val == 0)
                    {
                        var tvstorefalsenode = new TreeNode(sstore.Name);
                        tvstorefalse.Nodes.Add(tvstorefalsenode);
                    }
                    else
                    {
                        var tvstoretruenode = new TreeNode(sstore.Name);
                        tvstoretrue.Nodes.Add(tvstoretruenode);
                    }
                }
            }

            _pt.Name     = "!";
            _sr.Store_id = -1;
        }