Пример #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            CKhachHang kh = new CKhachHang();

            kh.Hoten    = txtTenKH.Text;
            kh.CMND     = Convert.ToInt32(txtCM.Text);
            kh.Gioitinh = chkGioitinh.Checked;
            kh.Tuoi     = Convert.ToInt32(txtTuoi.Text);
            kh.Quoctich = txtQuoctich.Text;
            kh.Sdt      = Convert.ToInt32(txtSDT.Text);
            foreach (CKhachHang item  in frmmng.Data.ArrKH)
            {
                if (item.CMND == kh.CMND)
                {
                    MessageBox.Show("Số CMND trùng nhau.");
                    return;
                }
            }
            frmmng.Data.ArrKH.Add(kh);
            i++;
            hienthi();

            CBill ctmbill = new CBill(kh, null, null, DateTime.Now);

            frmmng.Data.ArrBill.Add(ctmbill);
        }
Пример #2
0
 private void btnThanhToan_Click(object sender, EventArgs e)
 {
     try
     {
         layTenKHvaCMND(cbxTTKH.Text);
         CBill    hoadonKH = timHoaDonKH(iCMND);
         CHistory lskh     = new CHistory();
         lskh.Ctmbill = hoadonKH;
         frmmng.Data.ArrLS.Add(lskh);
         frmmng.Data.SaveLSKH("dslskh.txt");
         xoaHoaDonKH(hoadonKH);
         MessageBox.Show("Thanh toán thành công.");
         clearDisplay();
         if (frmmng.Data.ArrBill.Count > 0)
         {
             showDataTenKH();
             cbxTTKH.Text = "";
             cbxTTKH.Select();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Thanh toán không thành công.");
     }
 }
Пример #3
0
        private void cbxTTKH_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbxTTKH.Text == "")
            {
                MessageBox.Show("Chưa chọn khách hàng");
                return;
            }
            layTenKHvaCMND(cbxTTKH.Text);
            CBill hoadonKH = timHoaDonKH(iCMND);

            if (hoadonKH == null)
            {
                return;
            }
            if (hoadonKH.Dp != null)
            {
                dtpNgayDP.Value = hoadonKH.Dp.Ngayden;
                dtpNgayDi.Value = hoadonKH.Dp.Ngaydi;
                hienthiDSPhong(hoadonKH.Dp);
            }
            if (hoadonKH.Ddv != null)
            {
                hienthiDSDDV(hoadonKH.Ddv);
                txtDVTT.Text = hoadonKH.Ddv.tinhTongGiaTien().ToString();
            }
            else
            {
                txtDVTT.Text = "0";
            }
            txtTongTien.Text = hoadonKH.tinhTongThanhTien().ToString();
        }
Пример #4
0
        private void xoaHoaDonKH(CBill hoadonKH)
        {
            int i;
            int j   = 0;
            int dem = 0;

            for (i = 0; i < frmmng.Data.ArrDP.Count; i++)
            {
                if (hoadonKH.Kh.CMND == frmmng.Data.ArrDP[i].Kh.CMND)
                {
                    while (dem <= frmmng.Data.ArrDP[i].Phong.Count - 1)
                    {
                        int sophong = frmmng.Data.ArrDP[i].Phong[j++].Sophong;
                        foreach (CPhong item in frmmng.Data.ArrPKS)
                        {
                            if (sophong == item.Sophong)
                            {
                                item.Trangthai = "Empty";
                                dem++;
                            }
                        }
                    }
                    frmmng.Data.ArrDP.RemoveAt(i);
                    frmmng.Data.SaveP("dsp.txt");
                    frmmng.Data.SaveDP("dsdp.txt");
                    break;
                }
            }
            for (i = 0; i < frmmng.Data.ArrDDV.Count; i++)
            {
                if (frmmng.Data.ArrDDV[i].Kh.CMND == hoadonKH.Kh.CMND)
                {
                    frmmng.Data.ArrDDV.RemoveAt(i);
                    frmmng.Data.SaveDSDDV("dsddv.txt");
                    break;
                }
            }
            for (i = 0; i < frmmng.Data.ArrKH.Count; i++)
            {
                if (frmmng.Data.ArrKH[i].CMND == hoadonKH.Kh.CMND)
                {
                    frmmng.Data.ArrKH.RemoveAt(i);
                    frmmng.Data.SaveKH("dskh.txt");
                    break;
                }
            }
            for (i = 0; i < frmmng.Data.ArrBill.Count; i++)
            {
                if (frmmng.Data.ArrBill[i].Kh.CMND == hoadonKH.Kh.CMND)
                {
                    frmmng.Data.ArrBill.RemoveAt(i);
                    frmmng.Data.SaveDSBill("dsbill.txt");
                    break;
                }
            }
        }
Пример #5
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            CKhachHang kh = (CKhachHang)frmmng.Data.ArrKH[i];
            kh.Hoten = txtTenKH.Text;
            kh.CMND = Convert.ToInt32(txtCM.Text);
            kh.Gioitinh = chkGioitinh.Checked;
            kh.Tuoi = Convert.ToInt32(txtTuoi.Text);
            kh.Quoctich = txtQuoctich.Text;
            kh.Sdt = Convert.ToInt32(txtSDT.Text);
            hienthi();

            CBill ctmbill = (CBill)frmmng.Data.ArrBill[i];
            ctmbill.Kh = kh;
        }
Пример #6
0
        private void cbxTTKH_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbxTTKH.Text == "")
            {
                MessageBox.Show("Chưa chọn khách hàng");
                return;
            }
            layTenKHvaCMND(cbxTTKH.Text);
            CBill hoadonKH = timHoaDonKH(iCMND);

            if (hoadonKH.Dp != null)
            {
            }
        }
Пример #7
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            CKhachHang kh = new CKhachHang();
            kh.Hoten = txtTenKH.Text;
            kh.CMND = Convert.ToInt32(txtCM.Text);
            kh.Gioitinh = chkGioitinh.Checked;
            kh.Tuoi = Convert.ToInt32(txtTuoi.Text);
            kh.Quoctich = txtQuoctich.Text;
            kh.Sdt = Convert.ToInt32(txtSDT.Text);
            frmmng.Data.ArrKH.Add(kh);
            i++;
            hienthi();

            CBill ctmbill = new CBill(kh, null, null, DateTime.Now);
            frmmng.Data.ArrBill.Add(ctmbill);
        }
Пример #8
0
        private CHistory timKH(int cmnd, string hoten, DateTime ngaythanhtoan)
        {
            CHistory cus = null;

            if (frmmng.Data.ArrLS.Count > 0)
            {
                foreach (CHistory itemls in frmmng.Data.ArrLS)
                {
                    CBill a = itemls.Ctmbill;
                    if (a.Kh.CMND == cmnd && string.Equals(a.Kh.Hoten, hoten) && sosanhTime(ngaythanhtoan, a.Ngaythanhtoan))
                    {
                        cus = itemls;
                        break;
                    }
                }
            }
            return(cus);
        }
Пример #9
0
 public void hienThiDSKH()
 {
     lvwInfoKH.Items.Clear();
     if (frmmng.Data.ArrLS.Count > 0)
     {
         foreach (CHistory itemls in frmmng.Data.ArrLS)
         {
             CBill        a  = itemls.Ctmbill;
             ListViewItem li = lvwInfoKH.Items.Add(a.Kh.Hoten);
             li.SubItems.Add(a.Kh.CMND.ToString());
             li.SubItems.Add(a.Dp != null ? a.Dp.Ngayden.ToString() : a.Ngaythanhtoan.ToString());
             li.SubItems.Add(a.Dp != null ? a.Dp.Ngaydi.ToString() : a.Ngaythanhtoan.ToString());
             li.SubItems.Add(a.Dp != null ? a.Dp.SoNgayO().ToString() : "Không Đặt Phòng");
             li.SubItems.Add(a.Dp != null ? a.Dp.TongThanhTien().ToString() : "Không Đặt Phòng");
             li.SubItems.Add(a.Ddv != null ? a.Ddv.tinhTongGiaTien().ToString() : "Không Đặt DV");
             li.SubItems.Add(a.tinhTongThanhTien().ToString());
             li.SubItems.Add(a.Ngaythanhtoan.ToString());
             li.SubItems.Add(a.Kh.Quoctich);
         }
     }
 }
Пример #10
0
 public void hienThiChiTietDDVCuaKH(int cmnd, string hoten, DateTime ngaythanhtoan)
 {
     lvwChooseDSDV.Items.Clear();
     if (frmmng.Data.ArrLS.Count > 0)
     {
         foreach (CHistory itemls in frmmng.Data.ArrLS)
         {
             CBill a = itemls.Ctmbill;
             if (a.Kh.CMND == cmnd && string.Equals(a.Kh.Hoten, hoten) && sosanhTime(ngaythanhtoan, a.Ngaythanhtoan))
             {
                 if (a.Ddv != null)
                 {
                     foreach (CDichVu itemdv in a.Ddv.Arrdv)
                     {
                         ListViewItem li = lvwChooseDSDV.Items.Add(itemdv.Smadv);
                         li.SubItems.Add(itemdv.Stendv);
                         li.SubItems.Add(a.Ddv.tinhTongGiaTien().ToString());
                     }
                 }
                 break;
             }
         }
     }
 }
Пример #11
0
 public void hienThiChiTietDPCuaKH(int cmnd, string hoten, DateTime ngaythanhtoan)
 {
     lvwChooseP.Items.Clear();
     if (frmmng.Data.ArrLS.Count > 0)
     {
         foreach (CHistory itemls in frmmng.Data.ArrLS)
         {
             CBill a = itemls.Ctmbill;
             if (a.Kh.CMND == cmnd && string.Equals(a.Kh.Hoten, hoten) && sosanhTime(ngaythanhtoan, a.Ngaythanhtoan))
             {
                 if (a.Dp != null)
                 {
                     foreach (CPhong itemp in a.Dp.Phong)
                     {
                         ListViewItem li = lvwChooseP.Items.Add(itemp.Sophong.ToString());
                         li.SubItems.Add(itemp.Loaiphong);
                         li.SubItems.Add(a.Dp.ThanhTien(itemp.Loaiphong).ToString());
                     }
                 }
                 break;
             }
         }
     }
 }