private void button2_Click(object sender, EventArgs e) { try { HoaDonObject hd = new HoaDonObject(); hd.IDHoaDon = int.Parse(cbb_phong2.SelectedValue.ToString()); //lbl_dongia.Text = cbb_phong2.Text; //tinh thoi gian giữa 2 dtp TimeSpan time = dtp_thoigiantra2.Value - dtp_thoigiandat2.Value; hd.ThanhTien = time.Hours * int.Parse(lbl_dongia.Text); hd.GhiChu = txt_ghichu2.Text; int a = hd_model.TraPhong(hd, cbb_phong2.Text); if (a > 0) { MessageBox.Show("Trả phòng thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); lbl_thanhtien.Text = hd.ThanhTien.ToString() + " vnd"; lbl_thoigian.Text = time.Hours.ToString() + " giờ"; } else { MessageBox.Show("Trả phòng thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("Trả phòng thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }