Example #1
0
        private List <ChiTietGiaoDich> GetChiTietGiaoDich()
        {
            List <ChiTietGiaoDich>        listChiTietGiaoDich = new List <ChiTietGiaoDich>();
            List <int>                    roomGuestList;
            UserControlRoom               roomUserControl;
            sp_SearchAvailableRoom_Result room;
            ChiTietGiaoDich               ct;

            foreach (var c in flowLayoutPanelRoomList.Controls)
            {
                roomUserControl = (c as UserControlRoom);
                room            = roomUserControl.getRoom();
                roomGuestList   = roomUserControl.getGuestList();
                foreach (var guestId in roomGuestList)
                {
                    ct              = new ChiTietGiaoDich();
                    ct.ID_GiaoDich  = idDoan;
                    ct.ID_MaPhong   = room.ID;
                    ct.ID_KhachHang = guestId;
                    ct.NgayBatDau   = DateTime.Parse(room.ngayBatDau);
                    ct.NgayKetThuc  = DateTime.Parse(room.ngayKetThuc);
                    listChiTietGiaoDich.Add(ct);
                }
            }
            return(listChiTietGiaoDich);
        }
Example #2
0
 private void btn_hoa_don_Click(object sender, EventArgs e)
 {
     if (GridThanhToan.RowCount == 1)
     {
         MessageBox.Show("Chọn đoàn muốn thanh toán");
     }
     else
     {
         var HE1 = new HOLYBIRDRESORTEntities();
         if (HE1.sp_LayGiaoDichTheoMaDoan(tbTimKiemGiaoDichThanhToan.Text).Single().TinhTrang == 3)
         {
             int tongTien = 0;
             for (int i = 0; i < GridThanhToan.RowCount - 1; i++)
             {
                 int             thanhTien = 0;
                 int             soNgay    = 1;
                 string          maPhong   = GridThanhToan.Rows[i].Cells[1].Value.ToString();
                 Phong           phong     = HE1.sp_LayPhongTheoMaPhong(maPhong).Single();
                 ChiTietGiaoDich ctgd      = HE1.sp_LayChiTietGiaoDichTheoIdPhong(phong.ID, idGiaoDichThanhToan).Single();
                 if (ctgd.NgayBatDau != null && ctgd.NgayKetThuc != null)
                 {
                     TimeSpan time = (TimeSpan)(ctgd.NgayKetThuc - ctgd.NgayBatDau);
                     soNgay = time.Days;
                 }
                 if (GridThanhToan.Rows[i].Cells[3].Value != null && !GridThanhToan.Rows[i].Cells[3].Value.ToString().Equals(""))
                 {
                     thanhTien = (int)phong.DonGia * soNgay + Convert.ToInt32(GridThanhToan.Rows[i].Cells[3].Value);
                 }
                 else
                 {
                     thanhTien = (int)phong.DonGia * soNgay;
                 }
                 HE1.sp_CapNhatTinhTrangGiaoDich(idGiaoDichThanhToan, 4);
                 HE1.sp_CapNhatChiTietGiaoDichKhiThanhToan(idGiaoDichThanhToan, phong.ID, thanhTien);
                 HE1.sp_CapNhatTrangThaiPhong(phong.ID, 1);
                 tongTien += thanhTien;
             }
             HE1.sp_CapNhatTongTienGiaoDich(idGiaoDichThanhToan, tongTien);
             ThanhToan formThanhToan = new ThanhToan(idGiaoDichThanhToan);
             formThanhToan.ShowDialog();
         }
         else
         {
             MessageBox.Show("Giao dịch không thể thanh toán");
         }
     }
 }