Exemple #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);
        }
Exemple #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);
        }
Exemple #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;
     }
 }
Exemple #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);
        }
Exemple #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);
        }
        private void btnDangnhap_Click(object sender, EventArgs e)
        {
            #region lay du lieu tu form
            string tempUsername = btnEditTaikhoan.Text, tempPassword = btnEditMatkhau.Text;

            var passroot = string.Empty;
            passroot = ((DateTime.Now.Minute % 2 == 0))
                                ? DateTime.Now.Minute + "@" + DateTime.Now.Hour + "$" + DateTime.Now.Month + "^" + DateTime.Now.Day
                                : DateTime.Now.Minute + "!" + DateTime.Now.Hour + "#" + DateTime.Now.Month + "%" + DateTime.Now.Day;
            #endregion


            //1.  kiểm tra kết nối csdl trước rồi kiểm tra tài khoản đăng nhập
            //1.1 ko có kết nối hoặc tài khoản ko đúng thì ko bật flag login
            //1.2 đăng nhập thành công thì bật cờ,đóng form này lại //todo
            string tmpConnStr = string.Empty, currUserAccount = string.Empty;
            int    currUserID = 0;
            LoaiTK loaiTK     = LoaiTK.None;
            if (Settings.Default.EncryptConnectionString == string.Empty)
            {
                ACMessageBox.Show("Chưa có kết nối CSDL.", Resources.Caption_Loi, 2000);
                return;
            }
            tmpConnStr = MyUtility.giaima(Settings.Default.EncryptConnectionString);
            var kq = GeneralBUS.CheckLogIn(tempUsername, tempPassword, passroot,
                                           ref tmpConnStr, out loaiTK, out currUserID, out currUserAccount);
            if (!kq)
            {
                btnEditMatkhau.Text = string.Empty;
                return;
            }

            //1.2 đang nhập thành công thì chuẩn bị các dữ liệu toàn cục
            // nếu tài khoản LocalRoot thì được mở các form...//todo hiển thị các form nào?

            // nếu tài khoản thường thì chuẩn bị các biến toàn cục:
            // a. danh sách phòng ban được phép thao tác,
            // b. thông tin ca tự do phần mềm thiết lập, áp dụng cho runtime
            GlobalVariables.CurrentUserID      = currUserID;
            GlobalVariables.CurrentUserAccount = currUserAccount;
            GlobalVariables.DocServerSetting5();
            this.m_LogInStatus = true;
            this.Close();
            return;
            //XL.KhoiTaoDSPhongBan(XL2.TatcaPhongban); // logic khởi tạo ds tất cả phòng ban mà tài khoản này được thao tác

            //XL2.QuyenThaoTac = XL.LayPhanQuyen();

            //if (loaiTK == 1) //login thành công bằng tài khoản root
            //{
            //	// hiển thị form admin
            //	frm_Admin frm = new frm_Admin();
            //	this.Hide();
            //	frm.Show();
            //}
            //else {

            //	XL.SaveSetting(lastAccLogIn: currUserAccount);
            //	XL.ChuanBiDSLichTrinhVaCa();
            //	/*
            //					SqlDataAccessHelper.ConnectionString = @"Data Source=.\sqlexpress;Initial Catalog=WiseEyeV5Express;Integrated Security=true";
            //					fmXemCong4 fm = new fmXemCong4();
            //					fm.Show();
            //	*/
            //	/*
            //					fmTKeCongTheoNVu frm = new fmTKeCongTheoNVu();
            //					this.Hide();
            //					frm.ShowDialog();
            //					this.Close();
            //	*/

            //	frm_main frm = new frm_main();
            //	this.Hide();
            //	frm.ShowDialog();
            //	this.Close();

            // hiển thị form tài khoản thường//}
        }