Ejemplo n.º 1
0
        private void Init()
        {
            txtPass.Properties.UseSystemPasswordChar    = true;
            txtXacNhan.Properties.UseSystemPasswordChar = true;

            //Khởi tạo nhân viên bán hàng
            leNhanVien.Properties.TextEditStyle = TextEditStyles.Standard;
            leNhanVien.Properties.BestFitMode   = BestFitMode.BestFit;
            SetDataSource(leNhanVien, BUS_NhanVien.LayNhanVienDonGian(), "EMPLOYEE_Name", "EMPLOYEE_ID");
            leNhanVien.Properties.Columns[0].FieldName = "EMPLOYEE_Name";
            leNhanVien.Properties.Columns[1].FieldName = "EMPLOYEE_ID";

            //Khởi tạo vai trò
            leVaiTro.Properties.TextEditStyle = TextEditStyles.Standard;
            leVaiTro.Properties.BestFitMode   = BestFitMode.BestFit;
            SetDataSource(leVaiTro, BUS_PhanQuyen.LoadPermision(), "Description", "ID");
            leVaiTro.Properties.Columns[0].FieldName = "ID";
            leVaiTro.Properties.Columns[1].FieldName = "Description";


            if (add == true)
            {
                phatSinhMa();
            }
            else
            {
                LoadDuLieuBP();
            }
        }
Ejemplo n.º 2
0
        private void phatSinhMa()
        {
            DataTable table = BUS_PhanQuyen.LoadUser();
            var       query = from tb in table.AsEnumerable()
                              where tb.Field <string>("UserID").Contains("US")
                              select new
            {
                maND = tb.Field <string>("UserID")
            };

            DataTable dttb = new DataTable();

            dttb.Columns.Add("UserID", typeof(string));

            foreach (var item in query)
            {
                dttb.Rows.Add(item.maND);
            }

            string max, currentMa;
            int    num;

            try
            {
                max       = dttb.Compute("Max(UserID)", "").ToString();
                num       = int.Parse(max.Substring(2)) + 1;
                currentMa = "US" + num.ToString("000000");
                Ma        = currentMa;
            }
            catch
            {
                currentMa = "US000001";
                Ma        = currentMa;
            }
        }
Ejemplo n.º 3
0
        private void Init()
        {
            gcUser.DataSource = BUS_PhanQuyen.LoadUser();

            gvUser.Columns[0].FieldName = "UserID";
            gvUser.Columns[1].FieldName = "UserName";
            gvUser.Columns[2].FieldName = "Group_ID";
            gvUser.Columns[3].FieldName = "Description";
            gvUser.Columns[4].FieldName = "Active";

            gcPermision.DataSource           = BUS_PhanQuyen.LoadPermision();
            gvPermision.Columns[0].FieldName = "ID";
            gvPermision.Columns[1].FieldName = "Name";
            gvPermision.Columns[2].FieldName = "Description";
            gvPermision.Columns[3].FieldName = "ACTIVE";

            gvRule.Columns[0].FieldName = "PER_ID";
            gvRule.Columns[1].FieldName = "Object_ID";
            gvRule.Columns[2].FieldName = "AllowView";
            gvRule.Columns[3].FieldName = "AllowEdit";
            gvRule.Columns[4].FieldName = "AllowAdd";
            gvRule.Columns[5].FieldName = "AllowDelete";
            gvRule.Columns[6].FieldName = "Active";

            gvUser.FocusedRowChanged += GvUser_FocusedRowChanged;
            btnLamMoi.ItemClick      += BtnLamMoi_ItemClick;
            btnXoa.ItemClick         += BtnXoa_ItemClick;
            btnSua.ItemClick         += BtnSua_ItemClick;
            btnThem.ItemClick        += BtnThem_ItemClick;
        }
        public UI_ThemNhanVien(Grid gridMain, DTO_NhanVien obj)
        {
            InitializeComponent();
            DataContext                     = new TextFieldsViewModel();
            this.gridMain                   = gridMain;
            isChangingVisible               = false;
            cbbPermissionName.ItemsSource   = BUS_PhanQuyen.showData();
            cbbPermissionName.SelectedIndex = 0;
            if (obj == null)
            {
                AutoGenerateID();
                btnVisible.IsChecked = true;
                isNew = true;
            }
            else
            {
                txtEmployeesID.Text       = obj.MaNhanVien;
                txtEmployeesName.Text     = obj.TenNhanVien;
                txtEmployeesUserName.Text = obj.UserName;
                txtEmployeesPass.Password = obj.Password;
                cbbPermissionName.Text    = obj.TenPhanQuyen;

                if (obj.TrangThai == false)
                {
                    btnVisible.IsChecked           = false;
                    txtEmployeesID.FontStyle       = FontStyles.Oblique;
                    txtEmployeesName.FontStyle     = FontStyles.Oblique;
                    txtEmployeesUserName.FontStyle = FontStyles.Oblique;
                    txtEmployeesPass.FontStyle     = FontStyles.Oblique;
                    cbbPermissionName.FontStyle    = FontStyles.Oblique;
                }
                isNew = false;
            }
        }
Ejemplo n.º 5
0
 private void GvUser_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     if (gvUser.FocusedRowHandle >= 0 && gvUser.FocusedRowHandle <= gvUser.RowCount)
     {
         string ma = gvUser.GetFocusedRowCellValue("Group_ID").ToString();
         gcRule.DataSource = BUS_PhanQuyen.LoadPhanQuyen(ma);
     }
 }
Ejemplo n.º 6
0
        private void xl()
        {
            List <CQuyenHan> lqh     = new List <CQuyenHan>();
            string           _PER_ID = editq.ID;
            string           _Object_ID;
            bool             _AllowView;
            bool             _AllowAdd;
            bool             _AllowDelete;
            bool             _AllowEdit;
            bool             _Active;

            GridView gv = gvRule as GridView;

            for (int i = 0; i < gvRule.RowCount; i++)
            {
                _Object_ID   = gv.GetRowCellValue(i, "Object_ID").ToString();
                _AllowView   = bool.Parse(gv.GetRowCellValue(i, "AllowView").ToString());
                _AllowAdd    = bool.Parse(gv.GetRowCellValue(i, "AllowAdd").ToString());
                _AllowDelete = bool.Parse(gv.GetRowCellValue(i, "AllowDelete").ToString());
                _AllowEdit   = bool.Parse(gv.GetRowCellValue(i, "AllowEdit").ToString());
                _Active      = bool.Parse(gv.GetRowCellValue(i, "Active").ToString());

                CQuyenHan qh = new CQuyenHan
                               (
                    _PER_ID,
                    _Object_ID,
                    _AllowView,
                    _AllowAdd,
                    _AllowDelete,
                    _AllowEdit,
                    _Active
                               );

                lqh.Add(qh);
            }
            if (add == true)
            {
                BUS_PhanQuyen.ThemVaiTro(editq, lqh);

                Action.Module     = "Vai Trò";
                Action.ActionName = "Thêm";
                Action.Reference  = editq.ID;
                Action.LuuThongTin();
            }
            else
            {
                BUS_PhanQuyen.SuaVaiTro(editq, lqh);

                Action.Module     = "Vai Trò";
                Action.ActionName = "Sửa";
                Action.Reference  = editq.ID;
                Action.LuuThongTin();
            }

            Close();
        }
Ejemplo n.º 7
0
 public static DataTable LayQuyenNguoiDung()
 {
     try
     {
         return(BUS_PhanQuyen.LoadPhanQuyen(vaitro));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 8
0
        private void BtnLamMoi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gcUser.DataSource      = BUS_PhanQuyen.LoadUser();
            gcPermision.DataSource = BUS_PhanQuyen.LoadPermision();
            string ma = string.Empty;

            try
            {
                ma = gvUser.GetFocusedRowCellValue("Group_ID").ToString();
            }
            catch
            { }

            gcRule.DataSource = BUS_PhanQuyen.LoadPhanQuyen(ma);
        }
Ejemplo n.º 9
0
        private void xlSua()
        {
            editUser.UserName    = txtUserName.Text;
            editUser.Password    = txtPass.Text;
            editUser.GroupID     = leVaiTro.EditValue.ToString();
            editUser.PartID      = leNhanVien.Text == "" ? "" : leNhanVien.EditValue.ToString();
            editUser.Description = txtDienGiai.Text;
            editUser.Active      = checkConQL.Checked;
            BUS_PhanQuyen.SuaUser(editUser);

            Action.Module     = "Người Dùng";
            Action.ActionName = "Sửa";
            Action.Reference  = Ma;
            Action.LuuThongTin();

            Close();
        }
Ejemplo n.º 10
0
        private void BtnXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DialogResult rs = lc.ShowDialog();

            if (rs == DialogResult.OK)//Vai trò
            {
                string ma = gvPermision.GetFocusedRowCellValue("ID").ToString();
                BUS_PhanQuyen.XoaVaiTro(ma);
                return;
            }
            else if (rs == DialogResult.Yes)//Người dùng
            {
                string ma = gvUser.GetFocusedRowCellValue("UserID").ToString();
                BUS_PhanQuyen.XoaUser(ma);
                return;
            }
        }
Ejemplo n.º 11
0
        public static void LayQuyenNguoiDungTheoChucNang(string form)
        {
            try
            {
                DataTable table = BUS_PhanQuyen.LoadPhanQuyen(vaitro, form);


                Xem         = bool.Parse(table.Rows[0]["AllowView"].ToString());
                Sua         = bool.Parse(table.Rows[0]["AllowEdit"].ToString());
                Xoa         = bool.Parse(table.Rows[0]["AllowDelete"].ToString());
                Them        = bool.Parse(table.Rows[0]["AllowAdd"].ToString());
                ConHoatDong = bool.Parse(table.Rows[0]["Active"].ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 12
0
        public fSuaVaiTro(bool isAdd = true, CQuyen q = null)
        {
            InitializeComponent();

            if (isAdd == false && q == null)
            {
                XtraMessageBox.Show("ERROR : Dữ liệu không được cung cấp để thực hiện hành động !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
            if (isAdd == true)
            {
                table = BUS_PhanQuyen.LoadPhanQuyen("admin");
                Text  = "Thêm Vai Trò";
            }
            else
            {
                editq = q;
                table = BUS_PhanQuyen.LoadPhanQuyen(q.ID);
                Text  = "Sửa thông tin vai trò";
            }
            add = isAdd;
            gcRule.DataSource = table;
            Init();
        }
Ejemplo n.º 13
0
        public void Login()
        {
            try
            {
                data = bUS_NguoiDung.GetData();
                if (data != null && !string.IsNullOrEmpty(txtUserName.Text) && !string.IsNullOrEmpty(txtPassWord.Text))
                {
                    if (CheckUsername(txtUserName.Text))
                    {
                        if (CheckPass(HashPassword(txtPassWord.Text)))
                        {
                            //mở chức năng tương ứng với user
                            //MessageBox.Show(Const.CurrentUser.TenDangNhap + " đăng nhập thành công!");

                            if (Const.CurrentUser.TenDangNhap == "admin")
                            {
                                Const.isFullOp = true;
                                Const.isLogin  = true;
                                NhatKyHoatDong nhatKy = new NhatKyHoatDong();
                                nhatKy.NguoiDungId = Const.CurrentUser.NguoiDungId;
                                nhatKy.NoiDung     = "Tài khoản: admin đã đăng nhập";
                                nhatKy.ThaoTac     = "";
                                nhatKy.ThoiGian    = DateTime.Now;
                                nhatKy.ChucNang    = "Đăng nhập";



                                Const.NhatKyHoatDong.Insert(nhatKy);
                                return;
                            }

                            BUS_PhanQuyen bUS_PhanQuyen = new BUS_PhanQuyen();
                            data = bUS_PhanQuyen.GetDetailPhanQuyen(Const.CurrentUser.NguoiDungId);
                            for (int i = 0; i < data.Rows.Count; i++)
                            {
                                PhanQuyen quyen = new PhanQuyen();

                                quyen.TenNhomChucNang = data.Rows[i][1].ToString();
                                quyen.TenChucNang     = data.Rows[i][2].ToString();
                                quyen.ChucNangThem    = (bool)data.Rows[i][3];

                                quyen.ChucNangSua = (bool)data.Rows[i][4];
                                quyen.ChucNangXoa = (bool)data.Rows[i][5];
                                quyen.ChucNangDoc = (bool)data.Rows[i][6];
                                Const.PhanQuyens.Add(quyen);
                            }


                            Const.isLogin = true;

                            NhatKyHoatDong nhatKyHoatDong = new NhatKyHoatDong();
                            nhatKyHoatDong.NguoiDungId = Const.CurrentUser.NguoiDungId;
                            nhatKyHoatDong.NoiDung     = "Tài khoản: " + Const.CurrentUser.TenDangNhap + " đã đăng nhập";
                            nhatKyHoatDong.ThaoTac     = "";
                            nhatKyHoatDong.ThoiGian    = DateTime.Now;
                            nhatKyHoatDong.ChucNang    = "Đăng nhập";
                            Const.NhatKyHoatDong.Insert(nhatKyHoatDong);
                        }
                        else
                        {
                            MessageBox.Show(CheckPass(txtPassWord.Text).ToString());
                            errorProvider1.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError;
                            errorProvider1.BlinkRate  = 500;
                            errorProvider1.SetError(txtPassWord, "Sai mật khâu người dùng!");
                            Const.isLogin = false;
                        }
                    }
                    else
                    {
                        errorProvider1.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError;
                        errorProvider1.BlinkRate  = 500;
                        errorProvider1.SetError(txtUserName, "Sai tên tài khoản người dùng!");
                        Const.isLogin = false;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }