예제 #1
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.");
     }
 }
예제 #2
0
        public void hienthiLS(int j)
        {
            CHistory ls = (CHistory)arrLS[j];

            txtTenKH.Text     = ls.Kh.Hoten;
            cbxLoaiphong.Text = ls.Dp.Phong.Loaiphong;
            txtQuoctich.Text  = ls.Kh.Quoctich;
        }
예제 #3
0
 private void lvwInfoKH_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (int j in lvwInfoKH.SelectedIndices)
     {
         icmnd           = Convert.ToInt32(lvwInfoKH.Items[j].SubItems[1].Text);
         shoten          = lvwInfoKH.Items[j].Text;
         dtngaythanhtoan = Convert.ToDateTime(lvwInfoKH.Items[j].SubItems[8].Text);
         CHistory cus = timKH(icmnd, shoten, dtngaythanhtoan);
         hienThiTextBox(cus);
         hienThiChiTietDPCuaKH(icmnd, shoten, dtngaythanhtoan);
         hienThiChiTietDDVCuaKH(icmnd, shoten, dtngaythanhtoan);
         break;
     }
 }
예제 #4
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);
        }
예제 #5
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (arrDP.Count <= 0)
            {
                MessageBox.Show("Không có dữ liệu!", "Error");
                return;
            }
            CHistory ls = new CHistory();

            ls.Dp.Kh.Hoten        = arrDP[i].Kh.Hoten;
            ls.Dp.Kh.CMND         = arrDP[i].Kh.CMND;
            ls.Dp.Ngayden         = arrDP[i].Ngayden;
            ls.Dp.Ngaydi          = arrDP[i].Ngaydi;
            ls.Dp.Phong.Sophong   = arrDP[i].Phong.Sophong;
            ls.Dp.Phong.Loaiphong = arrDP[i].Phong.Loaiphong;
            ls.Dp.Phong.Gia       = arrDP[i].Phong.Gia;
            CKhachHang timkh = timInfoKH(ls.Dp.Kh.Hoten, ls.Dp.Kh.CMND);

            if (timkh == null)
            {
                MessageBox.Show("Không tìm thấy khách hàng trong danh sách khách hàng");
                return;
            }
            ls.Kh.Hoten    = ls.Dp.Kh.Hoten;
            ls.Kh.CMND     = ls.Dp.Kh.CMND;
            ls.Kh.Gioitinh = timkh.Gioitinh;
            ls.Kh.Tuoi     = timkh.Tuoi;
            ls.Kh.Quoctich = timkh.Quoctich;
            ls.Kh.Sdt      = timkh.Sdt;
            arrLS.Add(ls);

            CDatPhong dp = arrDP[i];

            foreach (CPhong p in arrPKS)
            {
                if (p.Sophong == dp.Phong.Sophong && string.Compare(p.Loaiphong, dp.Phong.Loaiphong) == 0)
                {
                    p.Trangthai = "Empty";
                    SaveP("dsp.txt");
                    break;
                }
            }
            foreach (CKhachHang kh in arrKH)
            {
                if (kh.CMND == dp.Kh.CMND)
                {
                    arrKH.Remove(kh);
                    SaveKH("dskh.txt");
                    break;
                }
            }
            ShowDataTenKH();
            arrDP.RemoveAt(i);
            i--;
            if (i < 0 && arrDP.Count > 0)
            {
                i = 0;
            }
            if (i >= 0)
            {
                hienthiDP(i);
            }
            hienthi();
        }
예제 #6
0
 private void hienThiTextBox(CHistory cus)
 {
     txtTenKH.Text     = cus.Ctmbill.Kh.Hoten;
     txtQuoctich.Text  = cus.Ctmbill.Kh.Quoctich;
     cbxLoaiphong.Text = (cus.Ctmbill.Dp == null) ? "Không Đặt Phòng" : ((cus.Ctmbill.Dp.Phong.Count == 1) ? cus.Ctmbill.Dp.Phong[0].Loaiphong : "Khách đặt nhiều Phòng");
 }