void BtnstoretofalseClick(object sender, EventArgs e)
 {
     if (_sr.Store_id == -1)
     {
     }
     else
     {
         StoreRulesC src = new StoreRulesC();
         src.ChangeStoreRules(new Store()
         {
             Id = _sr.Store_id
         }, _rule, false);
         CbruleSelectedIndexChanged(null, null);
     }
 }
        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. 3
0
        void GetStoreByRule()
        {
            StoreRulesC src = new StoreRulesC();

            List <StoreRules> lsr = src.GetStoreRulesByRuleId(_user.Rule_id);

            foreach (StoreRules sr in lsr)
            {
                StoreC sc = new StoreC();
                try {
                    string storeName = sc.GetOneStore(new Store()
                    {
                        Id = sr.Store_id
                    }).Name;
                    cbstore.Items.Add(storeName);
                } catch (Exception) {
                    Debug.WriteLine("Error When Get Store Name Update Class");
                }
            }
        }
Esempio n. 4
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;
        }
        /// <summary>
        ///
        /// </summary>
        void GetStoreByRule()
        {
            StoreRulesC src     = new StoreRulesC();
            bool        isFirst = true;

            _listStoreRules = src.GetStoreRulesByRuleId(_user.Rule_id);

            foreach (StoreRules sr in _listStoreRules)
            {
                StoreC sc = new StoreC();
                Debug.WriteLine(sr.Store_id.ToString());

                if (isFirst)
                {
                    _query = " store_id=" + sr.Store_id;
                }
                else
                {
                    _query += " or store_id=" + sr.Store_id;
                }

                isFirst = false;
                try {
                    string storeName = sc.GetOneStore(new Store()
                    {
                        Id = sr.Store_id
                    }).Name;
                    cbplace.Items.Add(storeName);
                    _store.Add(new Store {
                        Name = storeName, Id = sr.Store_id
                    });
                } catch (Exception) {
                    Debug.WriteLine("Error When Get Store Name MainForm Class");
                }
            }
            isFirst    = true;
            finalquery = _query;
            getAll("");
            //foreach (Store st in _store)
            // {
            //     GUI.ETabPage etp = new GUI.ETabPage();
            //     etp.Name = st.Name;
            //     etp.Text = st.Name;

            //     GUI.EListView etl = new GUI.EListView(st.Name);


            //     etp.AddToTabPage(etl.GetList());
            //     _listListView.Add(etl.GetList());

            //  tabControl1.Controls.Add(etp.GetTabPage());
            //     _listTabPage.Add(etp.GetTabPage());

            //  //   tabControl1.TabPages[st.Name].Text = st.Name;
            //  //   tabControl1.TabPages[st.Name].Controls.Add(new GUI.TestButton().GetButton(st.Name+4,"click"));
            //}
            // Debug.WriteLine(_listTabPage.Count);
            // foreach (ListView l in _listListView)
            // {
            //     Debug.WriteLine(l.Name);
            // }
            Debug.WriteLine("this is query=>" + _query);
        }