Esempio n. 1
0
        private void btn_themKhoaHoc_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.AddKH(khDTO);
                    if (kq == 1)
                    {
                        XtraMessageBox.Show(string.Format("Thêm khóa học {0} thành công!", khDTO.TenKH), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadDSKhoaHoc();
                        btn_themKhoaHoc.Enabled   = false;
                        btn_suaKhoaHoc.Enabled    = true;
                        dgcontrol_khoaHoc.Enabled = true;
                    }
                    else
                    {
                        XtraMessageBox.Show("Thêm không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
Esempio n. 2
0
        private void btn_themKhoaHoc_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.AddKH(khDTO);
                                if (kq == 1)
                                {
                                    XtraMessageBox.Show(string.Format("Thêm khóa học {0} thành công!", khDTO.TenKH), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    LoadDSKhoaHoc();
                                    btn_themKhoaHoc.Enabled              = false;
                                    btn_suaKhoaHoc.Enabled               = true;
                                    btn_capNhatTGKH.Enabled              = true;
                                    btn_xoaKhoaHoc.Enabled               = true;
                                    dgcontrol_khoaHoc.Enabled            = true;
                                    btn_lamMoiKhoaHoc.Text               = "Làm mới";
                                    btn_lamMoiKhoaHoc.ImageOptions.Image = EnglishCenterManagement.Properties.Resources.refresh;
                                }
                                else
                                {
                                    XtraMessageBox.Show("Thêm 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);
                        }
                    }
                }
            }
        }