コード例 #1
0
        private void btnSave_Click(Object sender, EventArgs e)
        {
            #region kiểm tra điều kiện
            List<KiemTra> kiemTras = new List<KiemTra>() {
            new KiemTra() { _Control = iTen } };

            XuLyGiaoDien.KiemTra(kiemTras, dxValidationProvider1);
            if (!dxValidationProvider1.Validate())
            {
                XuLyGiaoDien.Alert("Thông tin không hợp lệ", Form_Alert.enmType.Warning);
                return;
            }
            #endregion

            D_NHOMQUYEN cvb = new D_NHOMQUYEN();

            #region Kiểm tra tên tắt hãng bay
            if (cvb.KiemTraTonTai(iTen.Text, ID))
            {
                XuLyGiaoDien.Alert("Tên nhóm quyền đã tồn tại", Form_Alert.enmType.Warning);
                return;
            }
            #endregion

            #region Lưu
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("Ten", iTen.Text);
            foreach (Control ctl in Controls)
            {
                if (ctl is GroupControl)
                {
                    if ((ctl as GroupControl).CustomHeaderButtons.Count > 0)
                        dic.Add(ctl.Name, (ctl as GroupControl).CustomHeaderButtons[0].Properties.Checked);
                    foreach (Control ctl1 in (ctl as GroupControl).Controls)
                    {
                        if (ctl1 is CheckEdit)
                            dic.Add(ctl1.Name, (ctl1 as CheckEdit).Checked);
                        else if (ctl1 is GroupControl)
                        {
                            if ((ctl1 as GroupControl).CustomHeaderButtons.Count > 0)
                                dic.Add(ctl1.Name, (ctl1 as GroupControl).CustomHeaderButtons[0].Properties.Checked);
                            foreach (Control ctl2 in (ctl1 as GroupControl).Controls)
                            {
                                dic.Add(ctl2.Name, (ctl2 as CheckEdit).Checked);
                            }
                        }
                    }
                }
            }
            if (XuLyGiaoDien.ThongBao(Text, (ID != 0) ? (cvb.CapNhat(dic, ID) > 0) : (cvb.ThemMoi(dic) > 0)))
            {
                (Owner.ActiveMdiChild as frmQuyenNhanVien).QuyenNhanVienOBindingSource.DataSource = new D_NHOMQUYEN().DuLieu();
                Close();
            }
            #endregion
        }
コード例 #2
0
        void isLogin()
        {
            D_NHOMQUYEN    nqb = new D_NHOMQUYEN();
            D_DAILY        nvb = new D_DAILY();
            List <O_DAILY> nvo = nvb.NhanVien(txtUserName.Text, TMD5.TMd5Hash(txtPassword.Text));

            if (nvo.Count == 1)
            {
                if (!nvo[0].Nghi)
                {
                    RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\THCRM", true);
                    if (key == null)
                    {
                        key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\THCRM");
                    }

                    if (chk.Checked)
                    {
                        key.SetValue("cmra", txtUserName.Text);
                        key.SetValue("cmrp", txtPassword.Text);
                    }
                    else
                    {
                        key.SetValue("cmra", string.Empty);
                        key.SetValue("cmrp", string.Empty);
                    }
                    key.Close();

                    DuLieuTaoSan.NV = nvo[0];
                    DuLieuTaoSan.Q  = (nvo[0].TenDangNhapCty.ToLower().Equals("itadmin")) ? nqb.QuyenAdmin() : nqb.LayQuyenNhanVien(nvo[0].ChinhSach);
                    frmChinh f = new frmChinh();
                    XuLyGiaoDien.SplashScreen(f);
                    TopMost = false;
                    Hide();
                    f.Show(this);
                }

                else
                {
                    XtraMessageBox.Show("Tài khoản đã bị khóa vui lòng liên hệ ban quản lý...", "T-CMR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                XtraMessageBox.Show("Sai tên đăng nhập hoặc mật khẩu...", "T-CMR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }