private void btnDVThanhToan_Click(object sender, EventArgs e)
 {
     if (txtDVTong.Text != "0")
     {
         if (DsDV.Count > 0 && DsDVDaCo.Count == 0)
         {
             BEL_DatPhong     DP = BAL_DatPhong.Instance.LoadDatPhongTheoSoPhong(txtDVSoPhong.Text);
             BEL_HoaDonDichVu hd = new BEL_HoaDonDichVu(0, DP.MaKH, DateTime.Now, txtDVTong.Text, TK1.Manv.ToString());
             BAL_HoaDonDichVu.Instance.AddHoaDonDV(hd);
             BAL_HoaDonDichVu.Instance.AddChiTiet(DsDV, txtDVSoPhong.Text);
             lvDsDichVu.Items.Clear();
             MessageBox.Show("Thêm dịch vụ thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         if (DsDV.Count > 0 && DsDVDaCo.Count > 0)
         {
             BAL_HoaDonDichVu.Instance.AddChiTiet(DsDV, txtDVSoPhong.Text);
             BEL_DatPhong     dp   = BAL_DatPhong.Instance.LoadDatPhongTheoSoPhong(txtDVSoPhong.Text);
             BEL_HoaDonDichVu hddv = BAL_HoaDonDichVu.Instance.LayHoaDonTheoMaKH(dp.MaKH);
             BAL_HoaDonDichVu.Instance.UpTongTien(hddv.Mahd.ToString(), txtDVTong.Text);
             lvDsDichVu.Items.Clear();
             MessageBox.Show("Thêm dịch vụ thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         if (DsDV.Count == 0)
         {
             MessageBox.Show("Chưa có dịch mới được chọn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Hãy chọn chọn dịch vụ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        private void btnPhong_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            txtDVSoPhong.Text = btn.Text;
            lvDsDichVu.Items.Clear();
            BEL_DatPhong     dp   = BAL_DatPhong.Instance.LoadDatPhongTheoSoPhong(txtDVSoPhong.Text);
            BEL_HoaDonDichVu hddv = BAL_HoaDonDichVu.Instance.LayHoaDonTheoMaKH(dp.MaKH);

            if (hddv != null)
            {
                DsDVDaCo = BAL_DichVu.Instance.LoadDichVuTheoMaHD(hddv.Mahd.ToString());
                if (DsDVDaCo.Count > 0)
                {
                    foreach (BEL_DichVu dv in DsDVDaCo)
                    {
                        ListViewItem lvitem = new ListViewItem();
                        lvitem.Text = dv.Tendv;
                        lvitem.SubItems.Add(new ListViewItem.ListViewSubItem()
                        {
                            Text = dv.Gia.ToString()
                        });
                        lvitem.SubItems.Add(new ListViewItem.ListViewSubItem()
                        {
                            Text = dv.Giamgia.ToString()
                        });
                        lvDsDichVu.Items.Add(lvitem);
                    }
                }
                TinhTongTien();
            }
        }
        public int AddHoaDonDV(BEL_HoaDonDichVu dv)
        {
            string sql = " INSERT INTO  HoaDonDichVu ( ThanhTien , MaNV, MaKH ) " +
                         " VALUES( @thanhtien , @manv , @makh )";
            int result = DataProvider.Instance.ExecuteNonQuery(sql, new object[] { dv.Thanhtien, dv.Manv, dv.Makh });

            return(result);
        }
        public BEL_HoaDonDichVu LayHoaDonTheoMaKH(string makh)
        {
            DataTable data = DAL_HoaDonDichVu.Instance.LayHoaDonTheoMakh(makh);

            if (data.Rows.Count > 0)
            {
                BEL_HoaDonDichVu dv = new BEL_HoaDonDichVu(data.Rows[0]);
                return(dv);
            }
            return(null);
        }
        public bool AddHoaDonDV(BEL_HoaDonDichVu dv)
        {
            int result = DAL_HoaDonDichVu.Instance.AddHoaDonDV(dv);

            return(result > 0);
        }
Пример #6
0
 private void btnTPXuat_Click(object sender, EventArgs e)
 {
     if (cbbTPSoPhong.Text != "" && txtTPMaTP.Text != "")
     {
         if (BAL_TraPhong.Instansce.KiemTraTonTai(txtTPMaTP.Text) == false)
         {
             string           sophong = cbbTPSoPhong.Text;
             BEL_DatPhong     dp      = BAL_DatPhong.Instance.LoadDatPhongTheoSoPhong(sophong);
             BEL_KhachHang    kh      = BAL_KhachHang.Instance.LoadKhachHangTheoMa(dp.MaKH);
             BEL_TraPhong     tp      = new BEL_TraPhong(txtTPMaTP.Text, kh.MaKH, dp.SoPhong, DateTime.Now);
             BEL_HoaDonThue   hd      = BAL_HoaDonThue.Instance.LoadHDThueTheoMaDP(dp.MaDatPhong);
             BEL_HoaDonDichVu dv      = BAL_HoaDonDichVu.Instance.LayHoaDonTheoMaKH(kh.MaKH);
             if (dv != null)
             {
                 if (txtTPThanhTien.Text == "0")
                 {
                     hd.Tongtien = (float.Parse(txtTPThanhTien.Text)) + float.Parse(dv.Thanhtien);
                 }
                 else
                 {
                     if (float.Parse(txtTPThanhTien.Text) < hd.Tiencoc)
                     {
                         hd.Tongtien = (hd.Tiencoc - float.Parse(txtTPThanhTien.Text)) + float.Parse(dv.Thanhtien);
                     }
                     else
                     {
                         hd.Tongtien = (float.Parse(txtTPThanhTien.Text) - hd.Tiencoc) + float.Parse(dv.Thanhtien);
                     }
                 }
             }
             else
             {
                 if (txtTPThanhTien.Text == "0")
                 {
                     hd.Tongtien = (float.Parse(txtTPThanhTien.Text));
                 }
                 else
                 {
                     if (float.Parse(txtTPThanhTien.Text) < hd.Tiencoc)
                     {
                         hd.Tongtien = (hd.Tiencoc - float.Parse(txtTPThanhTien.Text));
                     }
                     else
                     {
                         hd.Tongtien = (float.Parse(txtTPThanhTien.Text) - hd.Tiencoc);
                     }
                 }
             }
             hd.Matraphong = txtTPMaTP.Text;
             rpHoaDon rp = new rpHoaDon(dp.MaKH, sophong, dp, kh, tp, hd);
             rp.ShowDialog();
         }
         else
         {
             MessageBox.Show("Trùng mã đặt phòng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }