Exemple #1
0
        public bool kiemTraDangNhap()
        {
            List <QL_NguoiDung> listTK = getTenDN();
            string       tendn         = txtUsername.Text;
            string       matkhau       = txtPassword.Text;
            QL_NguoiDung taikhoan      = null;

            foreach (QL_NguoiDung tk in listTK)
            {
                if (tk.TenDangNhap.Equals(tendn))
                {
                    taikhoan = new QL_NguoiDung();
                    taikhoan = tk;
                    break;
                }
            }
            if (taikhoan == null)
            {
                MessageBox.Show("Tên đăng nhập không tồn tại.", "Thông báo", MessageBoxButtons.OK);
                return(false);
            }
            else
            {
                if (taikhoan.MatKhau.Equals(matkhau))
                {
                    //loaiTaiKhoan = taikhoan.LoaiTaiKhoan;
                    return(true);
                }
                else
                {
                    MessageBox.Show("Mật khẩu không đúng.", "Thông báo", MessageBoxButtons.OK);
                    return(false);
                }
            }
        }
Exemple #2
0
        public bool AddNguoiDung(DTO_QLNguoiDung a)
        {
            try
            {
                QL_NguoiDung insert = new QL_NguoiDung();

                insert.TenDangNhap = a.TenDangNhap;
                insert.MatKhau     = "123";
                insert.TinhTrang   = a.TinhTrang;
                insert.Ho          = a.Ho;
                insert.Ten         = a.Ten;
                insert.NamSinh     = a.NamSinh;
                insert.GioiTinh    = a.GioiTinh;
                insert.Luong       = a.Luong;

                db.QL_NguoiDungs.InsertOnSubmit(insert);
                db.SubmitChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #3
0
        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            QL_NguoiDung.SaveConfig(cbbServerName.Text, txtUser.Text, txtPassword.Text, cbbDataBase.Text);
            frm_DangNhap dn = new frm_DangNhap();

            dn.Show();
            this.Close();
        }
Exemple #4
0
        public bool kiemTraTaiKhoan(string tenDN)
        {
            QL_NguoiDung tk = qlcf.QL_NguoiDungs.Where(t => t.TenDangNhap == tenDN).FirstOrDefault();

            if (tk != null)
            {
                return(true);
            }
            return(false);
        }
        public int ktNguoidung(QL_NguoiDung nguoidung)
        {
            var ng = qldd.QL_NguoiDungs.Where(t => t.TenDangNhap == nguoidung.TenDangNhap && t.MatKhau == nguoidung.MatKhau).FirstOrDefault();

            if (ng != null)
            {
                return(1);
            }
            return(0);
        }
Exemple #6
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtTenTaiKhoan.Text.Trim()))
            {
                MessageBox.Show("Không được bỏ trống tài khoản");
                this.txtTenTaiKhoan.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtMatKhau.Text.Trim()))
            {
                MessageBox.Show("Không được bỏ trống mật khẩu");
                this.txtMatKhau.Focus();
                return;
            }

            int kq = QL_NguoiDung.Check_Config();

            if (kq == 0)
            {
                try
                {
                    nv = dn.getNV(txtTenTaiKhoan.Text);
                    if (nv != null)
                    {
                        MessageBox.Show("ĐĂNG NHẬP THÀNH CÔNG");
                        FormMenu from = new FormMenu();
                        from.nv = nv;
                        this.Hide();
                        from.Show();
                    }
                    else
                    {
                        MessageBox.Show("ĐĂNG NHẬP THẤT BẠI");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Lỗi kết nối");
                }
            }
            else if (kq == 1)
            {
                MessageBox.Show("Chuỗi cấu hình không tồn tại");
                frmConfig cn = new frmConfig();
                cn.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Chuỗi cấu hình không phù hợp");
                frmConfig cn = new frmConfig();
                cn.Show();
                this.Hide();
            }
        }
Exemple #7
0
        public bool kiemTra(string tendangnhap)
        {
            QLTVDataContext qltv = new QLTVDataContext();
            QL_NguoiDung    nd   = qltv.QL_NguoiDungs.Where(t => t.TenDangNhap == tendangnhap).FirstOrDefault();

            if (nd != null)
            {
                return(true);
            }
            return(false);
        }
Exemple #8
0
 public bool xoa(string tendangnhap)
 {
     try
     {
         QL_NguoiDung delete = qltv.QL_NguoiDungs.Where(p => p.TenDangNhap.Equals(tendangnhap)).SingleOrDefault();
         qltv.QL_NguoiDungs.DeleteOnSubmit(delete);
         qltv.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #9
0
 public bool DeleteNguoiDung(string username)
 {
     try
     {
         QL_NguoiDung a = db.QL_NguoiDungs.Where(t => t.TenDangNhap.Equals(username)).SingleOrDefault();
         db.QL_NguoiDungs.DeleteOnSubmit(a);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool UpdateNguoiDung(DTO_NguoiDung a)
 {
     try
     {
         QL_NguoiDung update = db.QL_NguoiDungs.Where(p => p.TenDangNhap.Trim().Equals(a.TenDangNhap)).SingleOrDefault();
         update.MatKhau   = a.MatKhau;
         update.TinhTrang = a.TinhTrang;
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #11
0
        public bool sua(string tendangnhap, string matkhau, string manhom)
        {
            try
            {
                QL_NguoiDung edit = qltv.QL_NguoiDungs.Where(p => p.TenDangNhap.Equals(tendangnhap)).SingleOrDefault();

                edit.MatKhau = matkhau;
                edit.MaNhom  = manhom;
                qltv.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #12
0
        public int updateNguoidung(QL_NguoiDung nguoidung)
        {
            QL_NguoiDung ng = qldd.QL_NguoiDungs.Where(t => t.TenDangNhap == nguoidung.TenDangNhap).FirstOrDefault();

            if (ng != null)
            {
                ng.TenDangNhap = nguoidung.TenDangNhap;
                ng.MatKhau     = nguoidung.MatKhau;
                ng.HoatDong    = ng.HoatDong;
                qldd.SubmitChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemple #13
0
 public bool them(string tendangnhap, string matkhau, string manhom)
 {
     try
     {
         QL_NguoiDung insert = new QL_NguoiDung();
         insert.TenDangNhap = tendangnhap;
         insert.MatKhau     = matkhau;
         insert.MaNhom      = manhom;
         qltv.QL_NguoiDungs.InsertOnSubmit(insert);
         qltv.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
 public bool InsertNguoiDung(DTO_NguoiDung a)
 {
     try
     {
         QL_NguoiDung insert = new QL_NguoiDung();
         insert.TenDangNhap = a.TenDangNhap;
         insert.MatKhau     = a.MatKhau;
         insert.TinhTrang   = a.TinhTrang;
         db.QL_NguoiDungs.InsertOnSubmit(insert);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #15
0
        private void txtUsername_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                QL_NguoiDung ql = new QL_NguoiDung();
                if (string.IsNullOrEmpty(txtUsername.Text.Trim()))
                {
                    MessageBox.Show("Không được bỏ trống username");
                    this.txtUsername.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(this.txtPassWord.Text))
                {
                    MessageBox.Show("Không được bỏ trống passwrod");
                    this.txtPassWord.Focus();
                    return;
                }

                int kq = ql.checkConfig(); // hàm check thuộc class QL_NguoiDung

                if (kq == 0)
                {
                    ProcessLogin();


                    //cấu hình phù hợp
                }

                if (kq == 1)
                {
                    MessageBox.Show("Chuỗi cấu hình không tồn tại");
                    Program.frmCapNhat = new frmCapNhatHeThong();
                    Program.frmCapNhat.Show();
                    //xử lý cấu hình (không tồn tại)
                }

                if (kq == 2)
                {
                    MessageBox.Show("Chuỗi cấu hình không phù hợp");
                    Program.frmCapNhat = new frmCapNhatHeThong();
                    Program.frmCapNhat.Show();
                    //xử lý cấu hình (không phù hợp)
                }
            }
        }
Exemple #16
0
 public bool UpdateNguoiDung(DTO_QLNguoiDung a)
 {
     try
     {
         QL_NguoiDung edit = db.QL_NguoiDungs.Where(p => p.TenDangNhap.Equals(a.TenDangNhap)).SingleOrDefault();
         edit.TinhTrang = a.TinhTrang;
         edit.Ho        = a.Ho;
         edit.Ten       = a.Ten;
         edit.NamSinh   = a.NamSinh;
         edit.GioiTinh  = a.GioiTinh;
         edit.Luong     = a.Luong;
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #17
0
 public int Xoa(QL_NguoiDung pNguoiDung)
 {
     try
     {
         SqlDataAdapter sqlda_NguoiDung = new SqlDataAdapter("select * from QL_NguoiDung", cnn);
         DataRow        dr_NguoiDung    = ds_QLChamCong.Tables["QL_NguoiDung"].Rows.Find(pNguoiDung.TenDangNhap);
         if (dr_NguoiDung != null)
         {
             dr_NguoiDung.Delete();
         }
         SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(sqlda_NguoiDung);
         sqlda_NguoiDung.Update(ds_QLChamCong, "QL_NguoiDung");
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Exemple #18
0
 public int Them(QL_NguoiDung pNguoiDung)
 {
     try
     {
         SqlDataAdapter sqlda_NguoiDung = new SqlDataAdapter("select * from QL_NguoiDung", cnn);
         DataRow        dr_NguoiDung    = ds_QLChamCong.Tables["QL_NguoiDung"].NewRow();
         dr_NguoiDung["TenDangNhap"] = pNguoiDung.TenDangNhap;
         dr_NguoiDung["MatKhau"]     = pNguoiDung.MatKhau;
         dr_NguoiDung["MaNhom"]      = pNguoiDung.MaNhom;
         ds_QLChamCong.Tables["QL_NguoiDung"].Rows.Add(dr_NguoiDung);
         SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(sqlda_NguoiDung);
         sqlda_NguoiDung.Update(ds_QLChamCong, "QL_NguoiDung");
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Exemple #19
0
        private void btn_Them_Click(object sender, EventArgs e)
        {
            QL_NguoiDung nd = new QL_NguoiDung();

            nd.TenDangNhap = txt_TenDangNhap.Text;
            nd.MatKhau     = txt_MatKhau.Text;
            nd.MaNhom      = cbo_NhomNguoiDung.SelectedValue.ToString();
            if (txt_TenDangNhap.Text == "" && txt_MatKhau.Text == "")
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin");
            }
            else
            {
                if (busNguoiDung.Them(nd) == 1)
                {
                    MessageBox.Show("Thành công");
                }
                else
                {
                    MessageBox.Show("Thất bại");
                }
            }
        }
Exemple #20
0
        public void ProcessLogin()
        {
            QL_NguoiDung ql     = new QL_NguoiDung();
            int          result = ql.CheckUser(txtUsername.Text, txtPassWord.Text); //Trong class QL_NguoiDung

            if (result == 99)
            {
                MessageBox.Show("Sai username hoặc password");
                return;
            }
            else
            {
                if (result == 101)
                {
                    if (Program.frmMain == null || Program.frmMain.IsDisposed)
                    {
                        Program.frmMain = new frmMain();
                    }
                    this.Visible     = false;
                    ThongTin.MaNhom1 = pq.GetMaNhom(txtUsername.Text);
                    Program.frmMain.Show();
                }
            }
        }
Exemple #21
0
        void UpdateAccCountProfile()
        {
            string username  = txtUserName.Text;
            string pass      = txtPassword.Text;
            string newpass   = txtNewPass.Text;
            string passAgain = txtPasswordAgain.Text;

            if (!newpass.Equals(passAgain))
            {
                MessageBox.Show("Mật khẩu không giống nhau.Vui lòng nhập lại! ");
            }
            else
            {
                QL_NguoiDung nguoidung = new QL_NguoiDung();
                nguoidung.TenDangNhap = username;
                nguoidung.MatKhau     = pass;
                nguoidung.HoatDong    = 0;
                int kt = lqNguoidung.ktNguoidung(nguoidung);
                if (kt == 1)
                {
                    nguoidung.MatKhau = newpass;
                    lqNguoidung.updateNguoidung(nguoidung);
                    MessageBox.Show("Cập nhật dữ liệu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.None);
                    this.Close();
                    onUpdate();
                }
                else
                {
                    MessageBox.Show("Mật khẩu hiện tại không chính xác!");
                    txtPassword.Clear();
                    txtNewPass.Clear();
                    txtPasswordAgain.Clear();
                    txtPassword.Focus();
                }
            }
        }
 public int Them(QL_NguoiDung pNguoiDung)
 {
     return(dalND.Them(pNguoiDung));
 }
 public int Xoa(QL_NguoiDung pNguoiDung)
 {
     return(dalND.Xoa(pNguoiDung));
 }
Exemple #24
0
 private void cbbDataBase_DropDown(object sender, EventArgs e)
 {
     cbbDataBase.DataSource    = QL_NguoiDung.GetDataBaseName(cbbServerName.Text, txtUser.Text, txtPassword.Text);
     cbbDataBase.DisplayMember = "name";
 }
Exemple #25
0
 private void LoadCB()
 {
     cbbServerName.DataSource    = QL_NguoiDung.GetServerName();
     cbbServerName.DisplayMember = "ServerName";
 }
 public int Sua(QL_NguoiDung pNguoiDung)
 {
     return(dalND.Sua(pNguoiDung));
 }
Exemple #27
0
 void loadAccountProfide(QL_NguoiDung acc)
 {
     txtUserName.Text = acc.TenDangNhap;
 }
Exemple #28
0
 public frmDoiMatkhau(QL_NguoiDung nguoidung)
 {
     InitializeComponent();
     this.NguoiDung = nguoidung;
 }
Exemple #29
0
 public AccountEvent(QL_NguoiDung acc)
 {
     this.Acc = acc;
 }