private void btn_suaKhoaHoc_Click(object sender, EventArgs e) { if (txt_tenkh.Text == "" || dt_ngayBatDau.EditValue == null || dt_ngayKetThuc.EditValue == null || txt_hocPhi.Text == "") { XtraMessageBox.Show("Chưa điền đầy đủ thông tin!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (khDTO != null) { GetDetail(); int kq = khBUS.UpdateKH(khDTO); if (kq == 1) { XtraMessageBox.Show(string.Format("Sửa khóa học mã {0} thành công!", khDTO.MaKH), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDSKhoaHoc(); RefreshTextBox(); } else { XtraMessageBox.Show("Sửa không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void btn_suaKhoaHoc_Click(object sender, EventArgs e) { TimeSpan date = ((DateTime)dt_ngayKetThuc.EditValue).Subtract((DateTime)dt_ngayBatDau.EditValue); if (txt_tenkh.Text == "" || dt_ngayBatDau.EditValue == null || dt_ngayKetThuc.EditValue == null || txt_hocPhi.Text == "") { XtraMessageBox.Show("Chưa điền đầy đủ thông tin!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if ((DateTime)dt_ngayBatDau.EditValue < DateTime.Now) { XtraMessageBox.Show("Ngày bắt đầu phải lớn hơn ngày hiện tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if ((DateTime)dt_ngayKetThuc.EditValue < (DateTime)dt_ngayBatDau.EditValue) { XtraMessageBox.Show("Ngày kết thúc phải lớn hơn ngày bắt đầu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (date >= ts3 && date <= ts4 || date >= ts1 && date <= ts2) { if (khDTO != null) { GetDetail(); int kq = khBUS.UpdateKH(khDTO); if (kq == 1) { XtraMessageBox.Show(string.Format("Sửa khóa học mã {0} thành công!", khDTO.MaKH), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDSKhoaHoc(); RefreshTextBox(); } else { XtraMessageBox.Show("Sửa không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } else { XtraMessageBox.Show("Khóa học không dưới 3 tháng và không quá 6 tháng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }