private void btnDongY_Click(object sender, EventArgs e)
        {
            List <KiemTra> kiemTras = new List <KiemTra>()
            {
                new KiemTra()
                {
                    _Control = txtMatKhauCu, _ChoQuaThang = TMD5.TMd5Hash(txtMatKhauCu.Text) == DuLieuTaoSan.NV.MatKhauCty, _ThongBao2 = "Mật khẩu sai"
                },
                new KiemTra()
                {
                    _Control = txtMatKhauMoi
                },
                new KiemTra()
                {
                    _Control = iMatKhauCty, _ChoQuaThang = iMatKhauCty.Text == txtMatKhauMoi.Text, _ThongBao2 = "Mật khẩu mới không khớp"
                }
            };

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

            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("MatKhauCty", TMD5.TMd5Hash(iMatKhauCty.Text));

            if (XuLyGiaoDien.ThongBao(Text, new D_DAILY().CapNhat(dic, DuLieuTaoSan.NV.ID) > 0))
            {
                Close();
            }
        }
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            List <KiemTra> kiemTras = new List <KiemTra>();

            kiemTras.Add(new KiemTra()
            {
                _Control = iTenDangNhapCty, _Tu = 5, _Den = 30, _ChoQua = !_DaiLyD.DaTonTai("TenDangNhapCty", iTenDangNhapCty.Text, _KhachHangO.ID), _ThongBao2 = "Đã tồn tại"
            });
            kiemTras.Add(new KiemTra()
            {
                _Control = txtMatKhauCty, _Tu = 5, _Den = 30, _ChoQuaThang = !txtMatKhauCty.Enabled
            });

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

            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic = XuLyDuLieu.FormToDictionary(this, dic);
            dic.Add("Ten", iTenDangNhapCty.Text);
            if (txtMatKhauCty.Enabled)
            {
                dic.Add("MatKhauCty", TMD5.TMd5Hash(txtMatKhauCty.Text));
            }
            dic.Add("LoaiKhachHang", 0);
            NguoiThanKhach(false);
            dic.Add("ThongTinLienLac", _HoHang);
            long a = (_KhachHangO.ID > 0) ? _DaiLyD.CapNhat(dic, _KhachHangO.ID) : _DaiLyD.ThemMoi(dic, true);

            if (XuLyGiaoDien.ThongBao(Text, a > 0))
            {
                if (_KhachHangO.ID < 1)
                {
                    List <Dictionary <string, object> > lstDicS = new List <Dictionary <string, object> >();
                    for (int i = 0; i < 90; i++)
                    {
                        dic = new Dictionary <string, object>();
                        dic.Add("LoaiKhachHangSD", _KhachHangO.LoaiKhachHang);
                        dic.Add("ChinhSachID", iChinhSach.EditValue);
                        dic.Add("DaiLyID", a);
                        dic.Add("Ngay", "getdate() - " + i);
                        lstDicS.Add(dic);
                    }
                    new D_SODU_DAILY().ThemNhieu1Ban(lstDicS);
                }
                (Owner.ActiveMdiChild as frmNhanVien).DuLieu();
                Close();
            }
        }
Exemple #3
0
        public void CheckBanQuyen()
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\THCRM", true);

            if (key != null && key.GetValue("MaKichHoat") != null)
            {
                string   Key    = TMD5.Base64Decode(TMD5.Base64Decode(TMD5.Base64Decode(key.GetValue("MaKichHoat").ToString())));
                string[] subs   = Key.Split(new char[] { '@' });
                DateTime ngayBQ = new DateTime(int.Parse(subs[2].Substring(4)), int.Parse(subs[2].Substring(2, 2)), int.Parse(subs[2].Substring(0, 2)));
                DateTime ngaySV = DateTime.Now;

                if (subs.Length != 4 || subs[0] != "ThanhHoangCRM" || subs[1] != "TTTTUNG")
                {
                    XtraMessageBox.Show("Mã kích hoạt không hợp lệ");
                    new frmNhapMa().ShowDialog(this);
                }
                else if (ngaySV.Date.Subtract(ngayBQ.Date.AddYears(int.Parse(subs[3]))).Days > 0)
                {
                    XtraMessageBox.Show("Mã kích hoạt hết hạn sử dụng");
                    new frmNhapMa().ShowDialog(this);
                }
                else
                {
                    XuLyGiaoDien.OpenForm(this);
                    if (key != null)
                    {
                        if (key.GetValue("cmra") != null && key.GetValue("cmrp") != null)
                        {
                            if (key.GetValue("cmra").ToString().Length > 0)
                            {
                                chk.Checked      = true;
                                txtUserName.Text = key.GetValue("cmra").ToString();
                                txtPassword.Text = key.GetValue("cmrp").ToString();
                            }
                        }
                        if (key.GetValue("TKNC") != null)
                        {
                            key.SetValue("TKNC", "true");
                        }
                    }
                }
            }
            else
            {
                new frmNhapMa().ShowDialog(this);
            }
            if (key != null)
            {
                key.Close();
            }
        }
Exemple #4
0
        void ActiveSoft()
        {
            if (btnActive.Text != "Tiếp tục")
            {
                try
                {
                    string   Key    = TMD5.Base64Decode(TMD5.Base64Decode(TMD5.Base64Decode(txtKey.Text)));
                    string[] subs   = Key.Split(new char[] { '@' });
                    DateTime ngayBQ = new DateTime(int.Parse(subs[2].Substring(4)), int.Parse(subs[2].Substring(2, 2)), int.Parse(subs[2].Substring(0, 2)));
                    DateTime ngaySV = DateTime.Now;

                    if (subs.Length != 4 || subs[0] != "ThanhHoangCRM" || subs[1] != "TTTTUNG")
                    {
                        BaoLoi(false, "Mã kích hoạt không bợp lệ !!", Color.Crimson);
                        return;
                    }
                    else if (ngaySV.Date.Subtract(ngayBQ.Date.AddYears(int.Parse(subs[3]))).Days > 0)
                    {
                        BaoLoi(false, "Key hết hạn", Color.Crimson);
                        return;
                    }
                    else
                    {
                        RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\THCRM", true);
                        if (key == null)
                        {
                            key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\THCRM");
                        }

                        key.SetValue("MaKichHoat", txtKey.Text);
                        key.Close();
                        BaoLoi(true, "Kích hoạt thành công", Color.Green);
                    }
                }
                catch
                {
                    BaoLoi(false, "Mã kích hoạt không bợp lệ !!", Color.Crimson);
                    return;
                }
            }
            else
            {
                if (Owner is frmDangNhap)
                {
                    (Owner as frmDangNhap).CheckBanQuyen();
                }
                this.Close();
            }
        }
Exemple #5
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);
            }
        }