Esempio n. 1
0
        protected override bool OnSave()
        {
            layoutControl1.Validate();

            //if (!txtMatKhauMoi.Text.Equals(txtXacNhan.Text))
            //{
            //    txtXacNhan.ErrorText = "Xác nhận mật mới khẩu không khớp";
            //    return false;
            //}
            //try
            //{
            //    _nguoidung.MatKhau = txtMatKhauMoi.Text;

            //    var ad = new NguoiDungTableAdapter();
            //    ad.Update(_nguoidung);
            //    ShowAlert("Đã thay đổi mật khẩu");
            //    ad.Dispose();
            //    this.Close();
            //    return true;
            //}
            //catch (Exception ex)
            //{
            //    MsgBox.ShowErrorDialog(ex.Message);
            //    return false;
            //}

            if (string.IsNullOrEmpty(txtMatKhau.Text))
            {
                txtMatKhau.ErrorText = "Mật khẩu không hợp lệ";
                return(false);
            }
            else if (_nguoidung.MatKhau != HeThong.MaHoaMD5(txtMatKhau.Text))
            {
                txtMatKhau.ErrorText = "Mật khẩu không hợp lệ";
                return(false);
            }



            if (!txtMatKhauMoi.Text.Equals(txtXacNhan.Text))
            {
                txtXacNhan.ErrorText = "Xác nhận mật mới khẩu không khớp";
                return(false);
            }
            try
            {
                _nguoidung.MatKhau = HeThong.MaHoaMD5(txtMatKhauMoi.Text);

                var ad = new NguoiDungTableAdapter();
                ad.Update(_nguoidung);
                ad.Dispose();
                this.Close();
                return(true);
            }
            catch (Exception ex)
            {
                MsgBox.ShowErrorDialog(ex.Message);
                return(false);
            }
        }
Esempio n. 2
0
        public static DATA.NguoiDungRow LayNguoiDungDangNhap(string tendangnhap)
        {
            NguoiDungTableAdapter ad = new NguoiDungTableAdapter();
            var dt = ad.GetDataByTenDangNhap(tendangnhap);

            ad.Dispose();
            if (dt == null)
            {
                return(null);
            }
            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            return(dt.Rows[0] as DATA.NguoiDungRow);
        }