Ejemplo n.º 1
0
        private void dangNhap_Click(object sender, EventArgs e)
        {
            string      userName = txtUserName.Text;
            string      passWord = txtPassWord.Text;
            NhanVienDAL nv       = new NhanVienDAL();

            nv.maNhanVien = userName;
            if (Admin_Controller.Instance.Check_Login(userName, passWord) == 1)
            {
                fAdmin admin_space = new fAdmin();
                this.Hide();
                admin_space.ShowDialog();
                this.Show();
            }
            else if (Admin_Controller.Instance.Check_Login(userName, passWord) == 0)
            {
                Home home = new Home(nv);
                this.Hide();
                home.Show();
            }
            else
            {
                MessageBox.Show("Sai ten dang nhap hoac mat khau");
            }
        }
Ejemplo n.º 2
0
        public int Add_NhanVien(NhanVienDAL nv)
        {
            string query = "insert into NHANVIEN values('" + nv.maNhanVien + "', '" + nv.matKhau + "','" + nv.hoTen + "', '" + nv.ngaySinh + "', " + nv.gioiTinh + ",'" + nv.soDienThoai + "', '" + nv.diaChi + "', '" + nv.soCMND + "','" + nv.luongCung + "'," + nv.vaiTro + ");";

            System.Windows.Forms.MessageBox.Show(query);
            return(DataProvider.Instance.ExcuteNonQuery(query));
        }
Ejemplo n.º 3
0
        private void frmNhanVien_Load(object sender, EventArgs e)
        {
            //txtMaNV.Enabled = false;
            //dgvDSNV.AutoGenerateColumns = false;
            // hiển thị dữ liệu lên DataGridView
            //bsNV.DataSource = NhanVienDAL.LietKe();
            //dgvDSNV.DataSource = bsNV;


            //hiển thị lên form
            //txtMaNV.DataBindings.Add("Text", bsNV, "MaNhanVien", true);
            //txtTenNV.DataBindings.Add("Text", bsNV, "TenNhanVien", true);
            //cboVaiTro.DataBindings.Add("SelectedValue", bsNV, "VaiTro", true);
            //txtThongTin.DataBindings.Add("Text", bsNV, "ThongTin", true);
            //txtTK.DataBindings.Add("Text", bsNV, "Taikhoan", true);
            //txtMatKhau.DataBindings.Add("text", bsNV, "MatKhau", true);
            //cboGioiTinh.DataBindings.Add("SelectedValue", bsNV, "GioiTinh", true);

            bsNV.DataSource    = NhanVienDAL.LietKe();
            dgvDSNV.DataSource = bsNV;
            //nối combobox vai trò với list true false vai trò
            cboVaiTro.DataSource    = TrueFalseList;
            cboVaiTro.DisplayMember = "Name";
            cboVaiTro.ValueMember   = "Type";
            //nối combobox vai trò với list true false 1 giới tính
            cboGioiTinh.DataSource    = TrueFalseList1;
            cboGioiTinh.DisplayMember = "Name";
            cboGioiTinh.ValueMember   = "Type";
        }
Ejemplo n.º 4
0
 public EditNhanVien(NhanVienDAL nhanvien)
 {
     InitializeComponent();
     textBox_maNhanVien.Text      = nhanvien.maNhanVien;
     textBox_hoVaTen.Text         = nhanvien.hoTen;
     textBox_diaChi.Text          = nhanvien.diaChi;
     textBox_matKhau.Text         = nhanvien.matKhau;
     textBox_soCMND.Text          = nhanvien.soCMND;
     textBox_soDienThoai.Text     = nhanvien.soDienThoai;
     textBox_Luong.Text           = nhanvien.luongCung;
     dateTimePicker_ngaySinh.Text = nhanvien.ngaySinh;
     MessageBox.Show(nhanvien.gioiTinh);
     if (nhanvien.gioiTinh == "True")
     {
         radioButton_nam.Checked = true;
         radioButton_nu.Checked  = false;
     }
     else
     {
         radioButton_nu.Checked  = true;
         radioButton_nam.Checked = false;
     }
     if (nhanvien.vaiTro == "True")
     {
         radioButton_Admin.Checked    = true;
         radioButton_NhanVien.Checked = false;
     }
     else
     {
         radioButton_NhanVien.Checked = true;
         radioButton_Admin.Checked    = false;
     }
 }
        public int Update_MyInFor(NhanVienDAL nv)
        {
            string query = "UPDATE nhanvien SET hoTen=N'" + nv.hoTen + "', diaChi=N'" + nv.diaChi + "', soCMND='" + nv.soCMND + "', soDienThoai='" + nv.soDienThoai + "' where maNhanVien='" + nv.maNhanVien + "'";

            // MessageBox.Show(query);
            return(DataProvider.Instance.ExcuteNonQuery(query));
        }
Ejemplo n.º 6
0
        private void btnDoiMK_Click(object sender, EventArgs e)
        {
            if (txtTenDangNhap.Text == "" || txtMatKhauCu.Text == "" || txtMatKhauMoi.Text == "" || txtNhapLaiMatKhauMoi.Text == "")
            {
                MessageBox.Show("Thông tin không được để trống");
                return;
            }

            if (txtMatKhauMoi.Text != txtNhapLaiMatKhauMoi.Text)
            {
                MessageBox.Show("Mật khẩu nhập lại không đúng!");
                return;
            }

            if (txtMatKhauMoi.Text.Length < 6)
            {
                MessageBox.Show("Mật khẩu mới phải có 6 ký tự trở lên!");
                return;
            }
            if (MessageBox.Show("Bạn có chắc muốn sửa mật khẩu?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                var NhanVien = new NhanVien
                {
                    MaNhanVien = frmDangNhap.MaNV,
                    MatKhau    = txtMatKhauMoi.Text
                };
                NhanVienDAL.SuaMatKhau(NhanVien);
                MessageBox.Show("Thao tác thành công!");
            }
        }
Ejemplo n.º 7
0
 public static bool SuaNhanVien(DTO.NhanVienDTO nvDTO)
 {
     if (!NhanVienDAL.CheckNhanVienByMaNhanVien(nvDTO.MaNhanVien))
     {
         throw new Exception("Mã nhân viên không tồn tại");
     }
     return(NhanVienDAL.SuaNhanVien(nvDTO));
 }
Ejemplo n.º 8
0
        public int Update_NhanVien(NhanVienDAL nv)
        {
            //Check bieu thuc chinh quy
            string query = "UPDATE NhanVien SET hoTen=N'" + nv.hoTen + "', ngaySinh='" + nv.ngaySinh + "', gioiTinh=" + nv.gioiTinh + ",soDienThoai='" + nv.soDienThoai + "', soCMND='" + nv.soCMND + "', vaiTro =" + nv.vaiTro + ", luongCung = '" + nv.luongCung + "' where maNhanVien='" + nv.maNhanVien + "'";

            MessageBox.Show(query);
            return(DataProvider.Instance.ExcuteNonQuery(query));
            //Return Thong bao loi hoac thanh cong
        }
Ejemplo n.º 9
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            //txtMaNV.Enabled = true;
            //bsNV.AddNew();
            if (txtMaNV.Text == "" || txtTenNV.Text == "" || txtTK.Text == "" || txtMatKhau.Text == "")
            {
                MessageBox.Show("Không được để trống thông tin", "Thông báo");
                return;
            }
            if (NhanVienDAL.Tim(txtMaNV.Text) != null)
            {
                MessageBox.Show("Mã nhân viên không được trùng", "Thông Báo");
                return;
            }

            bool GT, VT;

            if (cboGioiTinh.SelectedIndex == 0)
            {
                GT = true;
            }
            else
            {
                GT = false;
            }

            if (cboVaiTro.SelectedIndex == 0)
            {
                VT = true;
            }
            else
            {
                VT = false;
            }

            if (MessageBox.Show("Bạn có muốn thêm sản phẩm không?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                var NV = new NhanVien
                {
                    MaNhanVien  = txtMaNV.Text,
                    TenNhanVien = txtTenNV.Text,
                    TaiKhoan    = txtTK.Text,
                    MatKhau     = txtMatKhau.Text,
                    ThongTin    = txtThongTin.Text,
                    GioiTinh    = GT,
                    VaiTro      = VT
                };
                NhanVienDAL.Them(NV);

                bsNV.DataSource = NhanVienDAL.LietKe();
                MessageBox.Show("Thao tác thành công", "Thông báo");
            }
            else
            {
                MessageBox.Show("Nhân viên đã tồn tại", "Lỗi");
            }
        }
Ejemplo n.º 10
0
        public static bool Them(List <NhanVienDTO> lstNhanVienDTO)
        {
            List <NHANVIEN> lstNhanVien = new List <NHANVIEN>();

            for (int i = 0; i < lstNhanVienDTO.Count; i++)
            {
                lstNhanVien.Add(MyConvert.Convert_NhanVienDTO_To_NhanVien(lstNhanVienDTO[i]));
            }
            return(NhanVienDAL.Them(lstNhanVien));
        }
Ejemplo n.º 11
0
 public static DTO.NhanVienDTO SelectNhanVienByMaNhanVien(string strMaNhanVien)
 {
     if (!NhanVienDAL.CheckNhanVienByMaNhanVien(strMaNhanVien))
     {
         return(null);
     }
     else
     {
         return(NhanVienDAL.SelectNhanVienByMaNhanVien(strMaNhanVien));
     }
 }
Ejemplo n.º 12
0
 public static void GhiAllFile()
 {
     CTHDBDAL.Ghifile();
     CTHDNDAL.Ghifile();
     GiaBanDAL.Ghifile();
     HoaDonBanDAL.Ghifile();
     HoaDonNhapDAL.Ghifile();
     LoaiQuanAoDAL.Ghifile();
     MauQuanAoDAL.Ghifile();
     NCCDAL.Ghifile();
     NhanVienDAL.Ghifile();
     TinhLuongDAL.Ghifile();
 }
Ejemplo n.º 13
0
        public bool CapNhat(NhanVien item)
        {
            NhanVienDAL dal = new NhanVienDAL(db);

            if (item != null)
            {
                return(dal.CapNhat(item));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 14
0
        public static string AutoMaNV()
        {
            string id = NhanVienDAL.GetLastID().Trim();

            if (id == "")
            {
                return("MANV000001");
            }
            int nextID = int.Parse(id.Remove(0, "MANV".Length)) + 1;

            id = "00000" + nextID.ToString();
            id = id.Substring(id.Length - 6, 6);
            return("MANV" + id);
        }
Ejemplo n.º 15
0
        public static bool ThemNV(NhanVien nhanVien)
        {
            DataTable dt = NhanVienDAL.ThemNV(nhanVien);

            foreach (DataRow row in dt.Rows)
            {
                if (row.ItemArray[0].ToString().Trim() == "0")
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 16
0
        public bool KT_DangNhap(string user, string pass)
        {
            NhanVienDAL nvDAL = new NhanVienDAL();
            bool        kt    = false;

            foreach (NhanVien nhanvien in nvDAL.GetData())
            {
                if (nhanvien.maNV == user && nhanvien.pass == CongCu.GetMD5(pass))
                {
                    kt = true;
                    break;
                }
            }
            return(kt);
        }
Ejemplo n.º 17
0
 public static bool ThemNhanVien(DTO.NhanVienDTO nvDTO)
 {
     if (string.IsNullOrEmpty(nvDTO.MaNhanVien))
     {
         throw new Exception($"Nhân viên {nvDTO.MaNhanVien}: Mã nhân viên rỗng");
     }
     if (string.IsNullOrEmpty(nvDTO.TenNhanVien))
     {
         throw new Exception($"Nhân viên {nvDTO.MaNhanVien}: Tên nhân viên rỗng");
     }
     if (NhanVienDAL.CheckNhanVienByMaNhanVien(nvDTO.MaNhanVien))
     {
         throw new Exception($"Nhân viên {nvDTO.MaNhanVien}: Mã nhân viên đã tồn tại");
     }
     return(NhanVienDAL.ThemNhanVien(nvDTO));
 }
Ejemplo n.º 18
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            NhanVienDAL       nhanVienDAL     = new NhanVienDAL();
            NHAN_VIEN         nv              = nhanVienDAL.GetDVByUsername(this.username);
            nhanVienNhomDAL   nhanVienNhomDAL = new nhanVienNhomDAL();
            NHAN_VIEN_NHOM    nvn             = nhanVienNhomDAL.GetDVByMaNV(nv.MA_NV);
            phanQuyenDAL      phanQuyenDAL    = new phanQuyenDAL();
            List <PHAN_QUYEN> pq              = phanQuyenDAL.GetListBuNhom(nvn.MA_NHOM);

            foreach (NavBarGroup nav in navBarControl.Groups)
            {
                if (nav is NavBarGroup)
                {
                    nav.Visible = find(Int32.Parse(nav.Tag.ToString()), pq);
                }
            }
        }
Ejemplo n.º 19
0
 public IEnumerable <NhanVien> TimKiemTheoLoaiNhanVien(string loaiNhanVien)
 {
     try
     {
         if (!string.IsNullOrEmpty(loaiNhanVien))
         {
             NhanVienDAL dal = new NhanVienDAL(db);
             return(dal.TimKiemTheoLoaiNhanVien(loaiNhanVien));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 20
0
        private void frmBanHang_Load(object sender, EventArgs e)
        {
            // không cho tự sinh cột
            dgvChiTietHD.AutoGenerateColumns = false;

            dgvChiTietHD.DataSource = bsBanHang;
            bsBanHang.DataSource    = Laptop;

            cbolaptop.DataSource    = LaptopDAL.LietKe();
            cbolaptop.ValueMember   = "MaLaptop";
            cbolaptop.DisplayMember = "TenLaptop";

            cboKH.DataSource    = KhachHangDAL.LietKe();
            cboKH.ValueMember   = "MaKhachHang";
            cboKH.DisplayMember = "TenKhachHang";

            cboNV.DataSource    = NhanVienDAL.LietKe();
            cboNV.ValueMember   = "MaNhanVien";
            cboNV.DisplayMember = "TenNhanVien";
        }
Ejemplo n.º 21
0
        public NhanVien TimKiemTheoMa(string id)
        {
            NhanVienDAL dal = new NhanVienDAL(db);

            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    return(dal.TimKiemTheoMa(id));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 22
0
        public IEnumerable <LichLamViecModel> LayTatCaLichLamViec(string maNhanVien)
        {
            NhanVienDAL dal = new NhanVienDAL(db);

            try
            {
                if (dal.TimKiemTheoMa(maNhanVien) != null)
                {
                    return(dal.LayTatCaLichLamViec(maNhanVien).ToList());
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 23
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (txtMaNV.Text == "" || txtTenNV.Text == "" || txtTK.Text == "" || txtMatKhau.Text == "")
            {
                MessageBox.Show("Không được để trống thông tin", "Thông báo");
            }
            var NV1 = new NhanVien
            {
                MaNhanVien  = txtMaNV.Text,
                TenNhanVien = txtTenNV.Text,
                TaiKhoan    = txtTK.Text,
                MatKhau     = txtMatKhau.Text,
                ThongTin    = txtThongTin.Text
            };

            NhanVienDAL.Sua(NV1);

            bsNV.DataSource = NhanVienDAL.LietKe();
            MessageBox.Show("Thao tác thành công", "Thông báo");
        }
Ejemplo n.º 24
0
        private void ProcessLogin()
        {
            byte[]      pass            = UnicodeEncoding.ASCII.GetBytes(txt_pass.TextName);
            NhanVienDAL NhanVienService = new NhanVienDAL();

            if (NhanVienService.Login(txt_username.TextName, pass))
            {
                if (Program.frmMain == null || Program.frmMain.IsDisposed)
                {
                    Program.frmMain = new frmMain();
                }
                this.Hide();
                Program.frmMain.username = txt_username.TextName;
                Program.frmMain.Show();
            }
            else
            {
                MessageBox.Show("Đăng nhập không thành công", "Thông báo");
            }
        }
Ejemplo n.º 25
0
        public bool ThemMoi(NhanVien item)
        {
            NhanVienDAL dal = new NhanVienDAL(db);

            try
            {
                if (item != null)
                {
                    return(dal.ThemMoi(item));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 26
0
        public IEnumerable <LichLamViecModel> TimLichLamViecTheoNgay(string maNhanVien, DateTime ngay)
        {
            NhanVienDAL dal = new NhanVienDAL(db);

            try
            {
                if (dal.TimKiemTheoMa(maNhanVien) != null)
                {
                    return(dal.TimLichLamViecTheoNgay(maNhanVien, ngay));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 27
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     {
         if (MessageBox.Show("Bạn chắc chắn muốn xóa?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             try
             {
                 String MaNhanVien = txtMaNV.Text;
                 NhanVienDAL.Xoa(MaNhanVien);
                 bsNV.DataSource = NhanVienDAL.LietKe();
                 //bsNV.RemoveCurrent();
                 MessageBox.Show("Thao tác thành công", "Thông báo");
             }
             catch
             {
                 MessageBox.Show("Mã nhân viên không tồn tại!!!", "Lỗi");
             }
         }
     }
 }
Ejemplo n.º 28
0
        public NhanVien TimKiemTaiKhoanHoatDong(string username, string password)
        {
            NhanVienDAL dal = new NhanVienDAL(db);

            try
            {
                if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    return(dal.TimKiemTaiKhoanHoatDong(username, password));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 29
0
        private void btn_suaNhanVien_Click(object sender, EventArgs e)
        {
            int         nam = 0, nu = 1;
            NhanVienDAL nhanvien = new NhanVienDAL();

            nhanvien.maNhanVien = textBox_maNhanVien.Text;
            nhanvien.matKhau    = textBox_matKhau.Text;
            nhanvien.diaChi     = textBox_diaChi.Text;
            DateTime ngaysinh = dateTimePicker_ngaySinh.Value.Date;

            nhanvien.ngaySinh    = ngaysinh.ToString("yyyy-MM-dd");
            nhanvien.luongCung   = textBox_Luong.Text;
            nhanvien.hoTen       = textBox_hoVaTen.Text;
            nhanvien.soCMND      = textBox_soCMND.Text;
            nhanvien.soDienThoai = textBox_soDienThoai.Text;
            if (radioButton_nam.Checked)
            {
                nhanvien.gioiTinh = nam.ToString();
            }
            else
            {
                nhanvien.gioiTinh = nu.ToString();
            }

            if (radioButton_Admin.Checked)
            {
                nhanvien.vaiTro = "1";
            }
            else
            {
                nhanvien.vaiTro = "0";
            }

            if (Admin_Controller.Instance.Update_NhanVien(nhanvien) >= 1)
            {
                MessageBox.Show("Cập nhật thành công!");
                var myParent = (fAdmin)this.Owner;
                myParent.RefreshForm();
                this.Close();
            }
        }
Ejemplo n.º 30
0
 private void btnCapNhat_Click(object sender, EventArgs e)
 {
     if (KiemTra())
     {
         NhanVienDAL nv = new NhanVienDAL();
         if (isUpdate)
         {
             nv.Update(txtTenTaiKhoan.Text, txtHoTen.Text, deNgaySinh.DateTime, (int)lueGioiTinh.EditValue, txtSDT.Text, txtEmail.Text, deNgayVaoLam.DateTime, txtMatKhau.Text, (int)lueLoaiTaiKhoan.EditValue);
             MessageBox.Show("Cập nhật thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Dispose();
         }
         else
         {
             nv.Insert(txtTenTaiKhoan.Text, txtHoTen.Text, deNgaySinh.DateTime, (int)lueGioiTinh.EditValue, txtSDT.Text, txtEmail.Text, deNgayVaoLam.DateTime, txtMatKhau.Text, (int)lueLoaiTaiKhoan.EditValue);
             MessageBox.Show("Thêm mới thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
             RefreshText();
         }
     }
     else
     {
         MessageBox.Show("Bạn phải điền đủ thông tin", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }