Esempio n. 1
0
        void BtnewClick(object sender, EventArgs e)
        {
            btnedit.Enabled   = false;
            btnremove.Enabled = false;
            if (btnew.Text.Equals("Save") && !username.Text.Equals("") && !tbname.Text.Equals(""))
            {
                LogOnC users = new LogOnC();
                RuleC  rules = new RuleC();
                Rules  rule  = rules.GetRuleByName(cbrule_set_user_rule.Text);

                if (users.AddUser(new UserM()
                {
                    UserName = username.Text, Name = tbname.Text, Password = "******", Phone = tbphone.Text, Rule_id = rule.Id
                }))
                {
                    MessageBox.Show("User " + tbname.Text.ToUpper() + " Done!");

                    ShowUserList();
                    username.Text = "";
                    tbname.Text   = "";
                    tbphone.Text  = "";
                    btnew.Text    = "New";
                }
            }
            else
            {
                username.Text = "";
                tbname.Text   = "";
                tbphone.Text  = "";

                Enable();
                btnew.Text = "Save";
            }
        }
Esempio n. 2
0
        void BtneditClick(object sender, EventArgs e)
        {
            if (btnedit.Text.Equals("Save") && !username.Text.Equals("") && !tbname.Text.Equals(""))
            {
                LogOnC users = new LogOnC();
                RuleC  rules = new RuleC();
                Rules  rule  = rules.GetRuleByName(cbrule_set_user_rule.Text);
                Debug.WriteLine(cbrule_set_user_rule.Text);
                if (users.Update(new UserM()
                {
                    UserName = username.Text, Name = tbname.Text, Email = "@", Phone = tbphone.Text, Rule_id = rule.Id
                }, treeView1.SelectedNode.Text))
                {
                    MessageBox.Show("Update user done!");

                    ShowUserList();
                }
            }
            else
            {
                Enable();
                btnew.Enabled     = false;
                btnremove.Enabled = false;

                btnedit.Text = "Save";
            }
        }
        void PermissionFormLoad(object sender, EventArgs e)
        {
            RuleC rules = new RuleC();

            foreach (Rules rule in rules.GetRule())
            {
                if (rule.Id != 1)
                {
                    cbrule.Items.Add(rule.Name);
                }
            }

            _pt.Name = "!";
        }
Esempio n. 4
0
        void SetComboRule()
        {
            RuleC rule = new RuleC();

            cbrule_set_user_rule.Items.Clear();
            foreach (Rules ru in rule.GetRule())
            {
                if (ru.Id != 1)
                {
                    cbrule_set_user_rule.Items.Add(ru.Name);
                }
            }
            if (cbrule_set_user_rule.Items.Count == 0)
            {
                tControl.SelectedIndex = tControl.TabCount - 1;
            }
        }
        public MainForm()
        {
            GetStart();

            int led = 0;

            LogOnC loc = new LogOnC();

            RuleC            ruc = new RuleC();
            PermissionTableC pt  = new PermissionTableC();
            StoreRulesC      src = new StoreRulesC();

            List <Store> ls = new List <Store>();

            for (int i = 1; i < 20; i++)
            {
                ls.Add(new Store()
                {
                    Id = i
                });
            }
            if (loc.GetUser().Count == 0)
            {
                loc = new LogOnC();
                loc.AddUser(new UserM()
                {
                    UserName = "******", Name = "Abdulaziz Alfuhigi", Password = "******", Rule_id = 1, Phone = "00000000"
                });
            }
            if (ruc.GetRule().Count == 0)
            {
                ruc = new RuleC();
                ruc.Insert(new Rules()
                {
                    Name = "admin", Descr = "admin"
                });
                pt.InsertList(new DefaultValues().GetDefaultPermissionTrue(new Rules()
                {
                    Id = 1
                }));
                src.InsertListTrue(ls, new Rules()
                {
                    Id = 1
                });
            }
        }
Esempio n. 6
0
        void ShowRuleAsListView()
        {
            var rules = new RuleC();

            lvrule.Items.Clear();
            foreach (Rules rule in rules.GetRule())
            {
                if (rule.Id != 1)
                {
                    var t = new ListViewItem(rule.Id.ToString());
                    t.SubItems.Add(rule.Name);
                    lvrule.Items.Add(t);
                }
            }

            tbrulename.Text    = "";
            tbrulenote.Text    = "";
            tbrulename.Enabled = false;
            tbrulenote.Enabled = false;
            btnewrule.Text     = "New";
        }
Esempio n. 7
0
        void TreeView1AfterSelect(object sender, TreeViewEventArgs e)
        {
            var n = (TreeNode)e.Node;
            //MessageBox.Show(n.Text);

            LogOnC users = new LogOnC();
            RuleC  rules = new RuleC();
            UserM  uses  = users.GetOneUser(n.Text);

            username.Text = uses.UserName;
            tbname.Text   = uses.Name;

            tbphone.Text = uses.Phone.ToString();
            cbrule_set_user_rule.Text = rules.GetRuleById(uses.Rule_id).Name;

            btnew.Text   = "New";
            btnedit.Text = "Edit";
            DisEnable();
            btnremove.Enabled = true;
            btnedit.Enabled   = true;
            btnew.Enabled     = true;
        }
Esempio n. 8
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;
        }