Esempio n. 1
0
        private void SetCheckedParentNodes(TreeListNode node, TreeListColumn col, bool check)
        {
            if (node.ParentNode != null)
            {
                var  b = false;
                bool state;
                for (var i = 0; i < node.ParentNode.Nodes.Count; i++)
                {
                    state = (bool)node.ParentNode.Nodes[i][col];
                    if (!check.Equals(state))
                    {
                        b = !b;
                        break;
                    }
                }
                var bb = b ? false : check;
                node.ParentNode[col] = bb;

                var allowShow   = (bool)node.ParentNode.GetValue(cxem);
                var allowAddNew = (bool)node.ParentNode.GetValue(cthem);
                var allowEdit   = (bool)node.ParentNode.GetValue(csua);
                var allowDelete = (bool)node.ParentNode.GetValue(cxoa);


                // viet o day
                //var user = gridView1.GetFocusedRow() as account;
                var phongban = gv.GetFocusedRow() as phongban;

                var obj = treeList1.GetDataRecordByNode(node.ParentNode) as ObjPhanQuyen;

                //var find = db.PhanQuyen2s.FirstOrDefault(q => q.ChucNang == obj.MaChucNang && q.TaiKhoan == user.id);
                var find = dbData.PhanQuyen2s.FirstOrDefault(q => q.ChucNang == obj.MaChucNang && q.TaiKhoan == phongban.id);

                if (find == null)
                {
                    find = new PhanQuyen2();
                    //find.TaiKhoan = user.id;
                    find.TaiKhoan = phongban.id;
                    find.ChucNang = obj.MaChucNang;
                    find.Xem      = allowShow;
                    find.Them     = allowAddNew;
                    find.Sua      = allowEdit;
                    find.Xoa      = allowDelete;

                    dbData.PhanQuyen2s.InsertOnSubmit(find);
                    dbData.SubmitChanges();
                }
                else
                {
                    find.Xem  = allowShow;
                    find.Them = allowAddNew;
                    find.Sua  = allowEdit;
                    find.Xoa  = allowDelete;
                    dbData.SubmitChanges();
                }
                SetCheckedParentNodes(node.ParentNode, col, check);
            }
        }
Esempio n. 2
0
        private void treeList1_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            //var user = gridView1.GetFocusedRow() as account;
            var phongban = gv.GetFocusedRow() as phongban;

            if (phongban == null)
            {
                return;
            }

            e.Node.SetValue(e.Column, e.Value);

            var obj = treeList1.GetDataRecordByNode(treeList1.FocusedNode) as ObjPhanQuyen;

            //var find = db.PhanQuyen2s.FirstOrDefault(q => q.ChucNang == obj.MaChucNang && q.TaiKhoan == user.id);
            var find = dbData.PhanQuyen2s.FirstOrDefault(q => q.ChucNang == obj.MaChucNang && q.TaiKhoan == phongban.id);

            if (find == null)
            {
                find = new PhanQuyen2();
                //find.TaiKhoan = user.id;
                find.TaiKhoan = phongban.id;
                find.ChucNang = obj.MaChucNang;
                find.Xem      = obj.Xem;
                find.Them     = obj.Them;
                find.Sua      = obj.Sua;
                find.Xoa      = obj.Xoa;

                dbData.PhanQuyen2s.InsertOnSubmit(find);
                dbData.SubmitChanges();
            }
            else
            {
                find.Xem  = obj.Xem;
                find.Them = obj.Them;
                find.Sua  = obj.Sua;
                find.Xoa  = obj.Xoa;
                dbData.SubmitChanges();
            }

            SetCheckedChildNodes(e.Node, e.Column, (bool)e.Value);
            SetCheckedParentNodes(e.Node, e.Column, (bool)e.Value);
        }
Esempio n. 3
0
        protected override void OnActivated(EventArgs e)
        {
            QuyenDangChon = Biencucbo.QuyenDangChon;
            base.OnActivated(e);
            var q = QuyenDangChon;

            if (q == null)
            {
                return;
            }

            if ((bool)q.Them)
            {
                btnthem.Visibility = BarItemVisibility.Always;
            }
            else
            {
                btnthem.Visibility = BarItemVisibility.Never;
            }
            if ((bool)q.Sua)
            {
                btnsua.Visibility = BarItemVisibility.Always;
            }
            else
            {
                btnsua.Visibility = BarItemVisibility.Never;
            }
            if ((bool)q.Xoa)
            {
                btnxoa.Visibility = BarItemVisibility.Always;
            }
            else
            {
                btnxoa.Visibility = BarItemVisibility.Never;
            }
        }
Esempio n. 4
0
        public void duyetRibbon(RibbonControl ribbonControl)
        {
            {
                foreach (RibbonPage page in ribbonControl.Pages)
                {
                    t_cn.moi(page.Name, page.Text, string.Empty);
                    foreach (RibbonPageGroup g in page.Groups)
                    {
                        t_cn.moi(g.Name, g.Text, page.Name);
                        bool showgrpage = false;
                        foreach (BarItemLink i in g.ItemLinks)
                        {
                            if (i.Item == btndxuat)
                            {
                                showquyen(i, true);
                                showgrpage = true;
                                continue;
                            }

                            t_cn.moi(i.Item.Name, i.Item.Caption, g.Name);

                            var quyen = db.PhanQuyen2s
                                        .FirstOrDefault(p => p.TaiKhoan == Biencucbo.phongban && p.ChucNang == i.Item.Name);

                            if (Biencucbo.phongban == "admin")
                            {
                                if (quyen == null)
                                {
                                    quyen          = new PhanQuyen2();
                                    quyen.TaiKhoan = Biencucbo.phongban;
                                    quyen.ChucNang = i.Item.Name;

                                    quyen.Xem = quyen.Them = quyen.Sua = quyen.Xoa = true;

                                    db.PhanQuyen2s.InsertOnSubmit(quyen);
                                    db.SubmitChanges();
                                }
                            }



                            if (showquyen(i, quyen == null ? false : Convert.ToBoolean(quyen.Xem)))
                            {
                                showgrpage = true;
                            }
                            // luu vào tag của nút tren ribbon de xu ly sau
                            i.Item.Tag = quyen;


                            if (i.Item is BarSubItem)
                            {
                                var sub = i.Item as BarSubItem;
                                sub.Enabled = true;
                                foreach (BarItemLink y in sub.ItemLinks)
                                {
                                    t_cn.moi(y.Item.Name, y.Item.Caption, i.Item.Name);
                                    // lay quyen
                                    //quyen = db.PhanQuyen2s
                                    //    .FirstOrDefault(p => p.TaiKhoan == Biencucbo.idnv && p.ChucNang == y.Item.Name);
                                    quyen = db.PhanQuyen2s
                                            .FirstOrDefault(
                                        p => p.TaiKhoan == Biencucbo.phongban && p.ChucNang == y.Item.Name);

                                    // cheat tài khoản quan tri
                                    //if (Biencucbo.idnv == "AD")
                                    if (Biencucbo.phongban == "admin")
                                    {
                                        if (quyen == null)
                                        {
                                            quyen = new PhanQuyen2();
                                            //quyen.TaiKhoan = Biencucbo.idnv;
                                            quyen.TaiKhoan = Biencucbo.phongban;
                                            quyen.ChucNang = y.Item.Name;

                                            quyen.Xem = quyen.Them = quyen.Sua = quyen.Xoa = true;

                                            db.PhanQuyen2s.InsertOnSubmit(quyen);
                                            db.SubmitChanges();
                                        }
                                    }

                                    if (showquyen(y, quyen == null ? false : Convert.ToBoolean(quyen.Xem)))
                                    {
                                        showgrpage = true;
                                    }
                                    // luu vào tag của nút tren ribbon de xu ly sau
                                    y.Item.Tag = quyen;
                                }
                            }
                        }
                        g.Visible = showgrpage;
                    }
                }
            }
        }