Beispiel #1
0
 private void dateTimKiem_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
 {
     if (dateTimKiem.SelectedDate == null)
     {
         hienthiHoaDon(CHoaDon_BUS.toList());
     }
     else
     {
         hienthiHoaDon(CHoaDon_BUS.toListNgayLap(dateTimKiem.SelectedDate.Value));
     }
 }
Beispiel #2
0
        public XemHoaDonTrongNgay()
        {
            InitializeComponent();
            CCa_DTO caLam = CCa_BUS.CaLamViec;

            if (caLam != null)
            {
                hoaDons = CHoaDon_BUS.toList(caLam); // chi lấy danh sách hóa đơn trong ca thực hiện
            }

            if (hoaDons == null || hoaDons.Count == 0)
            {
                hoaDons = new List <HoaDon>();
            }

            hienThi();
        }
Beispiel #3
0
        private void txtTK_KeyUp(object sender, KeyEventArgs e)
        {
            if (txtTK.Text == "")
            {
                hienthiHoaDon(CHoaDon_BUS.toList());
                return;
            }

            switch (chosse)
            {
            case 0:
                hienthiHoaDon(CHoaDon_BUS.toListMaNhanVien(txtTK.Text));
                break;

            case 2:
                hienthiHoaDon(CHoaDon_BUS.toListMaHoaDon(txtTK.Text));
                break;

            case 3:
                try
                {
                    double tongThanhTien = double.Parse(txtTK.Text);
                    hienthiHoaDon(CHoaDon_BUS.toListTongThanhTien(tongThanhTien));
                }
                catch (ArgumentNullException)
                {
                    MessageBox.Show("Số tiền nhập tìm kiếm rỗng");
                }
                catch (FormatException)
                {
                    MessageBox.Show("Số tiền nhập tìm kiếm phải là số");
                }
                catch (OverflowException)
                {
                    MessageBox.Show("Số tiền nhập tìm kiếm có dộ dài vượt mức");
                }
                break;

            default:
                break;
            }
        }
        public frmKetCa(NhanVien nv = null)
        {
            InitializeComponent();

            nhanVien = nv;
            if (nhanVien == null)
            {
                nhanVien = new NhanVien();
            }

            ketCa = new KetCa();
            DateTime gioKetThuc = DateTime.Now;

            ketCa.maKetCa                = CServices.taoMa <KetCa>(CCa_BUS.toList());
            ketCa.maNhanVien             = nhanVien.maNhanVien;
            ketCa.gioBatDau              = CCa_BUS.CaLamViec.GioBatDau;
            ketCa.gioKetThuc             = gioKetThuc;
            ketCa.ngayLap                = gioKetThuc;
            CCa_BUS.CaLamViec.GioKetThuc = DateTime.Now;

            List <HoaDon> hoaDons = new List <HoaDon>();

            hoaDons = CHoaDon_BUS.toList(CCa_BUS.CaLamViec);
            foreach (HoaDon hoaDon in hoaDons)
            {
                hoaDon.maKetCa = ketCa.maKetCa;
            }

            ketCa.soLuong = hoaDons.Count();
            double tongTienBan = CHoaDon_BUS.tongTienBan(hoaDons);

            ketCa.tongTienBan  = tongTienBan;
            ketCa.tienDauCa    = 0;
            ketCa.tongDoanhThu = tongTienBan;
            ketCa.HoaDons      = hoaDons;

            hienThiThongTin(ketCa);
        }
Beispiel #5
0
        private void btnTinhtien_Click(object sender, RoutedEventArgs e)
        {
            if (chiTietHoaDons.Count() == 0)
            {
                MessageBox.Show("Hóa Đơn chưa có chi tiết hóa đơn");
                return;
            }

            string maHoaDon = CServices.taoMa <HoaDon>(CHoaDon_BUS.toList());

            if (CHoaDon_BUS.find(maHoaDon) == null)
            {
                try
                {
                    HoaDon hoaDon = new HoaDon();
                    hoaDon.maHoaDon      = maHoaDon;
                    hoaDon.maNhanVien    = nhanVienSelect.maNhanVien;
                    hoaDon.ngayLap       = DateTime.Now;
                    hoaDon.tongThanhTien = tongThanhTien;

                    if (txtTienKhachDua.Text == "" || txtTienKhachDua.Text == null)
                    {
                        MessageBox.Show("Vui lòng nhập tiền khách đưa");
                        return;
                    }
                    else
                    {
                        hoaDon.tienKhachDua = double.Parse(txtTienKhachDua.Text);
                    }

                    if (txtTienThoiLai.Text == "" || txtTienThoiLai.Text == null)
                    {
                        MessageBox.Show("Vui lòng nhập tiền khách đưa để tính tiền thối lại");
                        return;
                    }
                    else
                    {
                        double tienThua = hoaDon.tienKhachDua.Value - hoaDon.tongThanhTien;
                        if (tienThua < 0)
                        {
                            MessageBox.Show("Tiền khách đưa không thể nhỏ hơn tổng thành tiền");
                            return;
                        }
                        else if (tienThua >= 500000)
                        {
                            txtTienThoiLai.Text = "";
                            MessageBox.Show("Xem lại tiền khách đưa");
                            return;
                        }

                        else
                        {
                            hoaDon.tienThua = tienThua;
                        }
                    }

                    hoaDon.trangThai = 0;

                    foreach (var item in chiTietHoaDons)
                    {
                        ChiTietHoaDon a = new ChiTietHoaDon();
                        a.maHoaDon  = hoaDon.maHoaDon;
                        a.maSanPham = item.maSanPham;
                        a.soLuong   = item.soLuong;
                        a.thanhTien = CChiTietHoaDon_BUS.tinhThanhTien(item);
                        hoaDon.ChiTietHoaDons.Add(a);
                    }

                    if (CHoaDon_BUS.add(hoaDon))
                    {
                        MessageBox.Show("Xuất hóa đơn thành công");
                    }
                    else
                    {
                        return;
                    }

                    chiTietHoaDons.Clear();
                    hienThiDSChiTietHD(chiTietHoaDons);

                    tongThanhTien        = 0;
                    txtTongTien.Text     = "";
                    txtTienKhachDua.Text = "";
                    txtTienThoiLai.Text  = "";
                }
                catch (ArgumentNullException)
                {
                    MessageBox.Show("Không được để rỗng đơn giá, tiền khách đưa, tiền thừa");
                }
                catch (FormatException)
                {
                    MessageBox.Show("Đơn giá, tiền khách đưa, tiền thừa, phải là số");
                }
                catch (OverflowException)
                {
                    MessageBox.Show("Đơn giá, tiền khách đưa, tiền thừa, vượt quá giới hạn lưu trữ");
                }
            }
            else
            {
                MessageBox.Show("Mã hóa đơn đã tồn tại");
            }
        }
Beispiel #6
0
 public frmQuanLyHoaDon()
 {
     InitializeComponent();
     hienthiHoaDon(CHoaDon_BUS.toList());
 }
        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");
            }
        }