Пример #1
0
        private void btnLuuPhong_Click(object sender, EventArgs e)
        {
            int focusRowHandle = gridViewTaiKhoan.FocusedRowHandle;

            // kiểm tra focusRowHandle hợp lệ
            if (focusRowHandle == GridControl.InvalidRowHandle || focusRowHandle < 0)
            {
                ACMessageBox.Show("Bạn chưa chọn tài khoản để thao tác.", Resources.Caption_ThongBao, 2000);
                return;
            }

            //kiểm tra kết nối csdl
            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                return;
            }

            DataRow selectedDataRow_TaiKhoan = gridViewTaiKhoan.GetDataRow(focusRowHandle);
            int     userID = (int)selectedDataRow_TaiKhoan["UserID"];

            List <int> dsPhong_DuocThaoTac   = new List <int>();
            List <int> dsPhong_KoDuocThaoTac = new List <int>();
            TreeNode   root = GeneralBUS.ReturnRootNode(treePhongBan.TopNode);

            LayDSPhongBanDuocPhanQuyen(root, dsPhong_DuocThaoTac, dsPhong_KoDuocThaoTac);
            LuuPhanQuyenPhongBan(userID, dsPhong_DuocThaoTac, true);
            LuuPhanQuyenPhongBan(userID, dsPhong_KoDuocThaoTac, false);
        }
Пример #2
0
        private void PopulateData_ToTreePhong(DataTable tablePhanQuyenPhongBan)
        {
            //logic: thực hiện load trạng thái ban đầu (uncheck toàn bộ): đưa về root và thực hiện từ trên xuống
            TreeNode root = GeneralBUS.ReturnRootNode(treePhongBan.TopNode);

            SetCheckStatus_AllTreeNode(root, false);
            treePhongBan.Invalidate();
            // duyệt từ root và check những phòng được thao tác, uncheck và phòng ko được thao tác
            root = GeneralBUS.ReturnRootNode(root);
            SetCheckNode_PhongBanThaoTac(root, tablePhanQuyenPhongBan);
        }
Пример #3
0
 private void SetCheckNode_PhongBanThaoTac(TreeNode root, DataTable tablePhanQuyenPhongBan)
 {
     foreach (DataRow dataRow in tablePhanQuyenPhongBan.Rows)
     {
         root = GeneralBUS.ReturnRootNode(root);
         int      idPhong = (int)dataRow["IDDepartment"];
         TreeNode node    = FindNode(idPhong, root);
         if (node == null)
         {
             continue;                               // ko tìm thấy  node thì đi tiếp
         }
         node.Checked = true;
     }
 }
Пример #4
0
        private void treePhongBan_OnAfterCheck(object sender, TreeViewEventArgs treeViewEventArgs)
        {
            // xác định trạng thái node hiện hành để set trạng thái cho node con
            TreeNode root        = treeViewEventArgs.Node;
            DataRow  dataRow     = (DataRow)root.Tag;
            var      checkStatus = root.Checked;
            int      idPhong     = (int)dataRow["ID"];   // giữ lại id của node hiện tại để sau khi check xong thì chọn lại node này

            // thực hiện set trạng thái cho các node con
            treePhongBan.AfterCheck -= treePhongBan_OnAfterCheck;
            SetCheckStatus_AllTreeNode(root, checkStatus);
            treePhongBan.AfterCheck += treePhongBan_OnAfterCheck;
            // sau khi set xong thì focus lại node hiện tại
            root = GeneralBUS.ReturnRootNode(root);
            root = FindNode(idPhong, root);
        }
Пример #5
0
        private void gridViewTaiKhoan_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // nếu ko có focus vào dòng nào thì thoát form, nếu có thì xử lý load phòng ban thao tác và phân quyền
            if (e.FocusedRowHandle == GridControl.InvalidRowHandle)
            {
                ACMessageBox.Show("Không có dòng dữ liệu nào được chọn. Form tự động đóng.", Resources.Caption_ThongBao, 2000);
                Close();
            }
            if (e.FocusedRowHandle < 0)
            {
                return;
            }
            //có focus, load phòng và phân quyền theo tài khoản này
            //xác định userID
            DataRow dataRow = gridViewTaiKhoan.GetDataRow(e.FocusedRowHandle);

            if (dataRow == null)
            {
                return;
            }
            int userID = (int)dataRow["UserID"];
            // uncheck all treeNode Phòng ban
            TreeNode root = GeneralBUS.ReturnRootNode(treePhongBan.TopNode);

            SetCheckStatus_AllTreeNode(root, false);
            treePhongBan.Refresh();
            // load dữ liệu phân quyền phòng ban và thực hiện check
            treePhongBan.AfterCheck -= treePhongBan_OnAfterCheck;
            DataTable tablePhanQuyenPhongBan = LoadDataTable_PhanQuyenPhongBan(userID);

            PopulateData_ToTreePhong(tablePhanQuyenPhongBan);
            treePhongBan.ExpandAll();
            treePhongBan.AfterCheck += treePhongBan_OnAfterCheck;
            //load dữ liệu phân quyền chức năng và thực hiện check
            DataTable tablePhanQuyenChucNang = LoadDataTable_PhanQuyenChucNang(userID);

            PopulateData_ToCheckList(tablePhanQuyenChucNang);
        }