private void wbntThemphong_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e) { switch (e.Button.Properties.Tag.ToString()) { case "Thêm": if (txtTenLoaiPhong.Text == "") { txtTenLoaiPhong.ErrorText = "Tên loại phòng không được để trống"; return; } DonGiaTheoTuan giaTheoTuan = new DonGiaTheoTuan(); giaTheoTuan.MaLoaiPhong = Convert.ToInt32(textEdit2.Text); for (int i = 0; i < 8; i++) { for (int j = 0; j < 24; j++) { if (spreadsheetControl1.Document.Worksheets[0].Cells[j, i].Value.ToString() == "") { //Thông báo có cell trống XtraMessageBox.Show("Không thể thêm được do có đơn giá trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } for (int i = 0; i < 8; i++) { DonGiaTheoNgay donGiaNgay = new DonGiaTheoNgay(); donGiaNgay.SetNgayTrongTuan(i); DonGiaTheoKhoangThoiGian donGia = new DonGiaTheoKhoangThoiGian(new DTO.ThongTinThanhToanTheoNgay.Gio(0, 0, 0), new DTO.ThongTinThanhToanTheoNgay.Gio(1, 0, 0), Convert.ToInt32(spreadsheetControl1.Document.Worksheets[0].Cells[0, i].Value.ToString())); for (int j = 1; j < 24; j++) { if (donGia.DonGia == Convert.ToInt32(spreadsheetControl1.Document.Worksheets[0].Cells[j, i].Value.ToString())) { donGia.GioKetThuc.AddHour(1); } else { donGiaNgay.listDonGiaTheoKhoangThoiGian.Add(donGia); donGia = new DonGiaTheoKhoangThoiGian(new DTO.ThongTinThanhToanTheoNgay.Gio(j, 0, 0), new DTO.ThongTinThanhToanTheoNgay.Gio(j + 1, 0, 0), Convert.ToInt32(spreadsheetControl1.Document.Worksheets[0].Cells[0, i].Value.ToString())); donGia.DonGia = Convert.ToInt32(spreadsheetControl1.Document.Worksheets[0].Cells[j, i].Value.ToString()); } //spreadsheetControl1.Document.Worksheets[0].Cells[j, i].NumberFormat = "##.000"; } donGiaNgay.listDonGiaTheoKhoangThoiGian.Add(donGia); giaTheoTuan.listDonGiaTheoNgay.Add(donGiaNgay); } BUS.LoaiPhongBUS.ThemLoaiPhong(LoaiPhongBUS.PhatSinhLoaiMaLoaiPhong(), txtTenLoaiPhong.Text); BUS.DonGia_LoaiPhongBUS.ThemDonGiaTheoKhoangThoiGian(giaTheoTuan); //Thông báo thành công XtraMessageBox.Show("Thêm loại phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); goToHomeLoaiPhong(); break; case "Hủy": if (XtraMessageBox.Show("Bạn có muốn thoát khỏi thêm phòng (Mọi thông tin chưa được lưu sẽ mất) ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { goToHomeLoaiPhong(); } break; } }