private void btnThem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dateNgaySinh.SelectedDate.Value != null &&
                    dateNgayVaoLam.SelectedDate.Value != null &&
                    cmbLoaiNhanVien.SelectedItem.ToString() != null)
                {
                    NhanVien nhanVien = new NhanVien();
                    nhanVien.maNhanVien     = txtMaNhanVien.Text;
                    nhanVien.hoNhanVien     = txtHoNhanVien.Text;
                    nhanVien.tenNhanVien    = txtTenNhanVien.Text;
                    nhanVien.soDienThoai    = txtSoDienThoai.Text;
                    nhanVien.ngaySinh       = dateNgaySinh.SelectedDate.Value.Date;
                    nhanVien.phai           = cmbPhai.SelectedIndex == 0 ? true : false;
                    nhanVien.cMND           = txtCMND.Text;
                    nhanVien.thuongTru      = txtThuongTru.Text;
                    nhanVien.tamTru         = txtTamTru.Text;
                    nhanVien.ngayVaoLam     = dateNgayVaoLam.SelectedDate.Value.Date;
                    nhanVien.maLoaiNhanVien = CLoaiNhanVien_BUS.findMaLoaiByTenLoai(cmbLoaiNhanVien.SelectedItem.ToString());
                    nhanVien.urlAnh         = urlAnh;
                    nhanVien.trangThai      = cmbTrangThai.SelectedIndex;

                    if (CNhanVien_BUS.add(nhanVien))
                    {
                        MessageBox.Show("Thêm thành công!");
                        this.Close();
                    }
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Lỗi! Không được để dữ liệu nhập vào là rỗng");
            }
        }
Ejemplo n.º 2
0
        private void showBangXepHang(int month)
        {
            List <NhanVien>     nhanViens    = CNhanVien_BUS.toList();
            List <CBangXepHang> bangXepHangs = new List <CBangXepHang>();

            if (nhanViens.Count() > 0)
            {
                int stt = 0;
                foreach (var nhanVien in nhanViens)
                {
                    int    soLuongHoaDon = CHoaDon_BUS.demSoLuongHoaDon(nhanVien.maNhanVien, month);
                    double tongThanhTien = CHoaDon_BUS.tongTienBan(nhanVien.maNhanVien, month);
                    stt++;
                    bangXepHangs.Add(new CBangXepHang(
                                         nhanVien.maNhanVien,
                                         nhanVien.hoNhanVien + " " + nhanVien.tenNhanVien,
                                         soLuongHoaDon,
                                         tongThanhTien));
                }

                dgBangThongKeNhanVien.ItemsSource = bangXepHangs.Select(x => new
                {
                    maNhanVien    = x.MaNhanVien,
                    tenNhanVien   = x.HoTen,
                    soLuongHoaDon = x.SoLuongHoaDon,
                    tongTienBan   = String.Format("{0:#,###,0 VND;(#,###,0 VND);0 VND}", x.TongTien)
                });
            }
        }
 public frmThongTinNhanVien(NhanVien nhanVien = null, int flag = 1)
 {
     InitializeComponent();
     cmbLoaiNhanVien.ItemsSource = CLoaiNhanVien_BUS.toListTenLoai();
     dateNgayVaoLam.SelectedDate = DateTime.Now;
     // khi người dùng nhấn thêm thì ấn nút sửa
     if (flag == 1)
     {
         txtMaNhanVien.Text = CServices.taoMa <NhanVien>(CNhanVien_BUS.toListAll());
         btnSua.IsEnabled   = false;
         btnLuu.IsEnabled   = false;
     }
     // khi người dùng nhấn nút sửa
     else if (flag == 2)
     {
         btnThem.IsEnabled = false;
         btnSua.IsEnabled  = false;
     }
     // là khi người dùng bấm nút xem chi tiết
     else
     {
         btnThem.IsEnabled   = false;
         btnLuu.IsEnabled    = false;
         btnChosse.IsEnabled = false;
         isEnabledThongTin(false);
     }
     if (nhanVien != null)
     {
         nhanVienSelect = nhanVien;
         hienThiThongTin(nhanVienSelect);
     }
 }
 private void dateNgaySinh_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key.ToString() == "Tab" || e.Key == Key.Enter)
     {
         try
         {
             int tuoi = CNhanVien_BUS.tinhTuoi(dateNgaySinh.SelectedDate.Value);
             if (tuoi == -1)
             {
                 MessageBox.Show("Tuổi được đi làm là từ 18 đến 65 tuổi");
             }
             else
             {
                 txtTuoi.Text = tuoi.ToString();
                 string ngaySinh = dateNgaySinh.Text;
                 dateNgaySinh.SelectedDate = DateTime.Parse(ngaySinh);
             }
         }
         catch (ArgumentNullException)
         {
             MessageBox.Show("Ngày sinh rỗng, không thể tính được tuổi nhân viên");
         }
         catch (FormatException)
         {
             MessageBox.Show("Lỗi Định dạng! Ngày sinh phải là: MM/dd/yyyy");
         }
     }
 }
Ejemplo n.º 5
0
 public static bool kiemTraThongTin(NhanVien nhanVien)
 {
     if (kiemTraTonTaiSo(nhanVien.hoNhanVien) == true ||
         kiemTraTonTaiSo(nhanVien.tenNhanVien) == true)
     {
         MessageBox.Show("Họ Tên không được có ký tự số");
         return(false);
     }
     if (kiemTraTonTaiChu(nhanVien.soDienThoai.Trim()) == true ||
         kiemTraTonTaiChu(nhanVien.cMND.Trim()) == true)
     {
         MessageBox.Show("số điện thoại và CMND chỉ có ký tự số");
         return(false);
     }
     if (nhanVien.cMND.Trim().Count() != 9 && nhanVien.cMND.Trim().Count() != 12)
     {
         MessageBox.Show("CMND chỉ có 9 ký tự số hoặc 12 ký tự số");
         return(false);
     }
     if (nhanVien.soDienThoai.Trim().Count() != 10)
     {
         MessageBox.Show("Số điện thoại chỉ có 10 số");
         return(false);
     }
     if (CNhanVien_BUS.tinhTuoi(nhanVien) == -1)
     {
         MessageBox.Show("Tuổi đi làm là 18 đến 65");
         return(false);
     }
     return(true);
 }
        private void btnLuu_Click(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                NhanVien nhanVien = new NhanVien();
                nhanVien.maNhanVien     = txtMaNhanVien.Text;
                nhanVien.hoNhanVien     = txtHoNhanVien.Text;
                nhanVien.tenNhanVien    = txtTenNhanVien.Text;
                nhanVien.soDienThoai    = txtSoDienThoai.Text;
                nhanVien.ngaySinh       = dateNgaySinh.SelectedDate.Value.Date;
                nhanVien.phai           = cmbPhai.SelectedIndex == 0 ? true : false;
                nhanVien.cMND           = txtCMND.Text;
                nhanVien.thuongTru      = txtThuongTru.Text;
                nhanVien.tamTru         = txtTamTru.Text;
                nhanVien.ngayVaoLam     = dateNgayVaoLam.SelectedDate.Value.Date;
                nhanVien.maLoaiNhanVien = CLoaiNhanVien_BUS.findMaLoaiByTenLoai(cmbLoaiNhanVien.SelectedItem.ToString());
                nhanVien.urlAnh         = urlAnh;
                nhanVien.trangThai      = cmbTrangThai.SelectedIndex;
                if (nhanVien.trangThai == 2 || nhanVien.trangThai == 1)
                {
                    if (CTaiKhoan_BUS.khoaTaiKhoanNV(nhanVien.maNhanVien) == false)
                    {
                        return;
                    }
                }

                if (CNhanVien_BUS.edit(nhanVien))
                {
                    this.Close();
                }
            }
        }
        private void dgDSNhanVien_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (dgDSNhanVien.SelectedItem == null)
            {
                return;
            }
            var maNhanVien = dgDSNhanVien.SelectedValue.ToString();

            nhanVienSelect = CNhanVien_BUS.find(maNhanVien);
        }
        // sự kiện tính tuổi sau khi người dùng chọn ngày sinh của minh
        private void dateNgaySinh_CalendarClosed(object sender, RoutedEventArgs e)
        {
            int tuoi = CNhanVien_BUS.tinhTuoi(dateNgaySinh.SelectedDate.Value);

            if (tuoi == -1)
            {
                MessageBox.Show("Tuổi được đi làm là từ 18 đến 65 tuổi");
            }
            else
            {
                txtTuoi.Text = tuoi.ToString();
            }
        }
 private void hienThiThongTin(NhanVien nhanVien)
 {
     txtMaNhanVien.Text           = nhanVien.maNhanVien;
     txtHoNhanVien.Text           = nhanVien.hoNhanVien;
     txtTenNhanVien.Text          = nhanVien.tenNhanVien;
     dateNgayVaoLam.SelectedDate  = nhanVien.ngayVaoLam;
     cmbLoaiNhanVien.SelectedItem = nhanVien.LoaiNhanVien.tenLoai;
     cmbPhai.SelectedIndex        = nhanVien.phai == true ? 0 : 1;
     txtSoDienThoai.Text          = nhanVien.soDienThoai;
     dateNgaySinh.SelectedDate    = nhanVien.ngaySinh;
     txtThuongTru.Text            = nhanVien.thuongTru;
     txtTamTru.Text             = nhanVien.tamTru;
     txtCMND.Text               = nhanVien.cMND;
     txtTuoi.Text               = CNhanVien_BUS.tinhTuoi(nhanVien).ToString();
     cmbTrangThai.SelectedIndex = nhanVien.trangThai.Value;
     urlAnh = nhanVien.urlAnh;
     hienThiHinh(nhanVien.urlAnh);
 }
Ejemplo n.º 10
0
        public void hienThi()
        {
            foreach (HoaDon hoaDon in hoaDons)
            {
                hoaDon.NhanVien = CNhanVien_BUS.find(hoaDon.maNhanVien);
            }

            dgHoaDonTrongNgay.ItemsSource = hoaDons.Select(x => new
            {
                maHoaDon      = x.maHoaDon,
                tenNhanVien   = x.NhanVien.hoNhanVien + " " + x.NhanVien.tenNhanVien,
                ngayLap       = x.ngayLap.ToString("dd/MM/yyyy"),
                thoiGian      = x.ngayLap.ToString("hh:mm:ss"),
                tienKhachDua  = String.Format("{0:#,###,0 VND;(#,###,0 VND);0 VND}", x.tienKhachDua),
                tienThua      = String.Format("{0:#,###,0 VND;(#,###,0 VND);0 VND}", x.tienThua),
                tongThanhTien = String.Format("{0:#,###,0 VND;(#,###,0 VND);0 VND}", x.tongThanhTien)
            });
        }
        private void btnXoa_Click(object sender, RoutedEventArgs e)
        {
            if (nhanVienSelect != null)
            {
                var result = MessageBox.Show("Do you want to delete changes?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    if (CNhanVien_BUS.remove(nhanVienSelect))
                    {
                        hienThiDSNhanVien(CNhanVien_BUS.toList());
                    }
                }
            }
            else
            {
                MessageBox.Show("Vui lòng chọn nhân viên");
            }
        }
        private void txtTimKiem_KeyUp(object sender, KeyEventArgs e)
        {
            if (txtTimKiem.Text == "")
            {
                hienThiDSNhanVien(CNhanVien_BUS.toList());
                return;
            }

            // nếu combox tìm kiếm là 0 tức là tìm theo tên nhân viên
            if (cmbTimKiem.SelectedIndex == 0)
            {
                hienThiDSNhanVien(CNhanVien_BUS.findTen(txtTimKiem.Text));
            }
            //nếu combox tìm kiếm là 1 tức là tìm theo mã nhân viên
            else if (cmbTimKiem.SelectedIndex == 1)
            {
                hienThiDSNhanVien(CNhanVien_BUS.findListMa(txtTimKiem.Text));
            }
            else
            {
                hienThiDSNhanVien(CNhanVien_BUS.findTenLoai(txtTimKiem.Text));;
            }
        }
Ejemplo n.º 13
0
        private void cmbTenNhanVien_Loaded(object sender, RoutedEventArgs e)
        {
            List <NhanVien> nhanViens = CNhanVien_BUS.toListNotAccount();

            cmbTenNhanVien.ItemsSource = nhanViens.Select(x => x.hoNhanVien + " " + x.tenNhanVien).ToList();
        }
Ejemplo n.º 14
0
        private void btnThemTK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtTaiKhoan.Text == "" || txtTaiKhoan.Text == null ||
                    txtMatKhau.Text == "" || txtMatKhau.Text == null)
                {
                    MessageBox.Show("Yêu cầu điền thông tin tài khoản");
                    return;
                }

                TaiKhoan taiKhoan   = new TaiKhoan();
                string   maNhanVien = CNhanVien_BUS.findTenbyMa(cmbTenNhanVien.SelectedItem.ToString());
                if (maNhanVien == "")
                {
                    MessageBox.Show("Vui lòng chọn nhân viên");
                    return;
                }
                taiKhoan.maNhanVien = maNhanVien;

                if (taiKhoan.maNhanVien == null || taiKhoan.maNhanVien == "")
                {
                    MessageBox.Show("Không lấy được mã nhân viên");
                    return;
                }
                if ((txtTaiKhoan.Text == null || txtTaiKhoan.Text == "") &&
                    (txtMatKhau.Text == null || txtMatKhau.Text == ""))
                {
                    MessageBox.Show("Điền đầy đủ thông tin tài khoản");
                    return;
                }
                if (CTaiKhoan_BUS.findTK(txtTaiKhoan.Text))
                {
                    MessageBox.Show("Tên tài khoản đã tồn tại");
                    return;
                }

                foreach (char item in txtTaiKhoan.Text)
                {
                    if ((item < 65 || item > 90) && (item < 97 || item > 122) && (item < 0 || item > 57))
                    {
                        MessageBox.Show("Tên tài khoản chỉ có các chữ cái in hoa hoặc thường và số");
                        return;
                    }
                }

                taiKhoan.tenTaiKhoan = txtTaiKhoan.Text;
                taiKhoan.matKhau     = CTaiKhoan_BUS.Encrypt(txtMatKhau.Text);
                taiKhoan.maTaiKhoan  = CServices.taoMa <TaiKhoan>(CTaiKhoan_BUS.toList());

                taiKhoan.trangThai = 0;

                if (CServices.kiemTraThongTin(taiKhoan)) //Kiểm tra thông tin tài khoản hợp lệ
                {
                    CTaiKhoan_BUS.add(taiKhoan);         //Thêm tài khoản
                    MessageBox.Show("Thêm thành công");
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Bạn chưa chọn mã nhân viên cần cấp tài khoản");
            }

            hienthiDStaikhoan();
            load();
            cmbTenNhanVien_Loaded(sender, e);
        }
Ejemplo n.º 15
0
        private void kiemTraTaiKhoan()
        {
            string matKhau = CTaiKhoan_BUS.Encrypt(txtMatkhau.Password);

            foreach (TaiKhoan taiKhoan in dc.TaiKhoans.ToList())
            {
                if (taiKhoan.tenTaiKhoan.Trim() == txtTaikhoan.Text.Trim() &&
                    taiKhoan.matKhau.Trim() == matKhau.Trim())
                {
                    taiKhoanSelect = taiKhoan;
                    break;
                }
            }

            if (taiKhoanSelect != null)
            {
                if (taiKhoanSelect.maTaiKhoan == "0000000001")
                {
                    new frmAdmin(taiKhoanSelect).Show();
                    this.Close();
                }
                else
                {
                    if (taiKhoanSelect.matKhau == "IZC83pakndc=" && taiKhoanSelect.trangThai == 0)   // mật khẩu mặc định là 1
                    {
                        NhanVien nhanVien = CNhanVien_BUS.find(taiKhoanSelect.maNhanVien);
                        if (nhanVien != null)
                        {
                            new frmNhanVien(nhanVien, taiKhoanSelect).Show();

                            MessageBox.Show("Vui lòng đổi mật khẩu");
                            frmDoiTaiKhoan frmDoiTaiKhoan = new frmDoiTaiKhoan(taiKhoanSelect);
                            frmDoiTaiKhoan.Show();

                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Không tìm thấy nhân viên sở hữu tài khoản này");
                        }
                    }
                    else if (taiKhoanSelect.trangThai == 0)
                    {
                        NhanVien nhanVien = CNhanVien_BUS.find(taiKhoanSelect.maNhanVien);
                        if (nhanVien != null)
                        {
                            new frmNhanVien(nhanVien, taiKhoanSelect).Show();
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Không tìm thấy nhân viên sở hữu tài khoản này");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Tài khoản này đã bị khóa");
                    }
                }
            }
            else
            {
                MessageBox.Show("Sai tài khoản hoặc mật khẩu");
            }
        }
        private void hienThi()
        {
            if (dateNgayBatDau.SelectedDate > DateTime.Now || dateNgayKetThuc.SelectedDate > DateTime.Now)
            {
                MessageBox.Show("Ngày bắt đầu và ngày kết thúc không được lớn hơn ngày hiện tại");
                return;
            }
            List <HoaDon>   hoaDons   = new List <HoaDon>();
            List <NhanVien> nhanViens = new List <NhanVien>();

            hoaDons   = CHoaDon_BUS.toList(dateNgayBatDau.SelectedDate.Value, dateNgayKetThuc.SelectedDate.Value);
            nhanViens = CNhanVien_BUS.toList();
            if (hoaDons.Count() > 0)
            {
                txtMaThongKe.Text      = CServices.taoMa <ThongKe>(CThongKe.toList());
                txtNgayLapThongKe.Text = DateTime.Now.ToString("dd/MM/yyyy");
                double tongThanhTien = 0;
                hoaDons.ForEach(x => tongThanhTien += x.tongThanhTien);
                txtTongThanhTien.Text = String.Format("{0:#,###,0 VND;(#,###,0 VND);0 VND}", tongThanhTien);

                chiTietThongKes = new List <Tuple <string, string, string, int, int, double> >();
                //bool flag = false;
                foreach (var nhanVien in nhanViens)
                {
                    int    soLuongHoaDon = 0;
                    int    soLuongBan    = 0;
                    double thanhTien     = 0;
                    foreach (var hoaDon in hoaDons)
                    {
                        if (nhanVien.maNhanVien == hoaDon.maNhanVien)
                        {
                            soLuongBan += hoaDon.ChiTietHoaDons.Count();
                            thanhTien  += hoaDon.tongThanhTien;
                            soLuongHoaDon++;
                            //flag = true;
                        }
                    }
                    //if (flag)
                    //{
                    var chiTietThongKe = new Tuple <string, string, string, int, int, double>(
                        nhanVien.maNhanVien,
                        nhanVien.hoNhanVien,
                        nhanVien.tenNhanVien,
                        soLuongHoaDon,
                        soLuongBan,
                        thanhTien);
                    chiTietThongKes.Add(chiTietThongKe);
                    //}
                    //flag = false;
                }

                dgChiTietThongKe.ItemsSource = chiTietThongKes.Select(x => new
                {
                    maNhanVien    = x.Item1,
                    hoNhanVien    = x.Item2,
                    tenNhanVien   = x.Item3,
                    soLuongHoaDon = x.Item4,
                    soLuongBan    = x.Item5,
                    thanhTien     = x.Item6
                });
            }
            else
            {
                MessageBox.Show("Không có hóa đơn nào được bán");
            }
        }
Ejemplo n.º 17
0
        private void gd_QuanLyXuatNguyenLieu_Click(object sender, RoutedEventArgs e)
        {
            NhanVien nhanVien = CNhanVien_BUS.find(taiKhoanSelect.maNhanVien);

            Main.Content = new frmQuanLyPhieuXuatNguyenLieu();
        }
 private void btnRefesh_Click(object sender, RoutedEventArgs e)
 {
     hienThiDSNhanVien(CNhanVien_BUS.toList());
 }
        public frmQuanLyNhanVien()
        {
            InitializeComponent();

            hienThiDSNhanVien(CNhanVien_BUS.toList());
        }