private void simpleButtonXoaPLMoi_Click(object sender, EventArgs e)
        {
            if (!_KiemTra_LopMoi_DaChon())
            {
                return;
            }

            string maLopMoi     = CboUtil.GetValueItem(comboBoxEditLopMoi),
                   tenLopMoi    = CboUtil.GetDisplayItem(comboBoxEditLopMoi),
                   tenNamHocMoi = CboUtil.GetDisplayItem(comboBoxEditNamHocMoi);

            var dsHocSinhChon = new Dictionary <string, string>();

            for (int i = 0; i < gridViewDSHocSinhMoi.RowCount; i++)
            {
                if (Convert.ToBoolean(gridViewDSHocSinhMoi.GetRowCellValue(i, "Check")))
                {
                    dsHocSinhChon.Add(gridViewDSHocSinhMoi.GetRowCellValue(i, "MaHocSinh").ToString(),
                                      gridViewDSHocSinhMoi.GetRowCellValue(i, "TenHocSinh").ToString());
                }
            }
            if (dsHocSinhChon.Count == 0)
            {
                MsgboxUtil.Error("Bạn chưa chọn học sinh để xóa!");
                return;
            }

            if (radioButtonPhanLopHoSo_ChuaPhanLop.Checked || radioButtonPhanLopHocSinh_NamTruoc.Checked)
            {
                if (MsgboxUtil.YesNo("Bạn có muốn xóa các hồ sơ học sinh đã chọn thuộc lớp " + maLopMoi
                                     + " năm học " + tenNamHocMoi + " hay không?")
                    == DialogResult.No)
                {
                    return;
                }

                if (_phanLopBUS.Xoa_DSHocSinh_Lop(dsHocSinhChon, maLopMoi))
                {
                    MsgboxUtil.Success("Đã xóa các hồ sơ trong lớp: " + tenLopMoi + " thành công!");
                }
                else
                {
                    MsgboxUtil.Info("Không có hồ sơ học sinh nào được xóa!");
                }

                _LoadGridcontrolDSHocSinhMoi();

                if (radioButtonPhanLopHoSo_ChuaPhanLop.Checked)
                {
                    _LoadGridcontrolDSHocSinh();
                }
            }
            _HienThi_Button();
        }
예제 #2
0
        private void simpleButtonThemMoi_Click(object sender, EventArgs e)
        {
            // Không thêm
            if (!_isAddButton)
            {
                _Diable_Control(isAdding: false);
                return;
            }
            // Thêm

            // Neu co phan lop
            if (!checkEditChuaPhanLop.Checked)
            {
                string maNamHocHT = _quyDinhBUS.LayMaNamHoc_HienTai();
                string maNamHoc   = CboUtil.GetValueItem(comboBoxEditNamHoc);
                string tenNamHT   = _namHocBUS.LayTenNamHoc_MaNamHoc(maNamHocHT);

                if (maNamHoc != maNamHocHT)
                {
                    if (MsgboxUtil.YesNo("Chương trình chỉ được phép tiếp nhận học sinh trong năm " + tenNamHT
                                         + "\nĐể thực hiện chức năng này, bạn có muốn di chuyển đến năm " +
                                         tenNamHT + " hay không?")
                        == DialogResult.Yes)
                    {
                        string maKhoiHT = CboUtil.GetValueItem(comboBoxEditKhoi);
                        CboUtil.SelectedItem(comboBoxEditNamHoc, maNamHocHT);
                        CboUtil.SelectedItem(comboBoxEditKhoi, maKhoiHT);
                        MsgboxUtil.Info("Đã chuyển đến năm " + tenNamHT
                                        + ", bạn hãy chọn lớp để thực hiện tiếp nhận hồ sơ mới!");
                    }

                    return;
                }

                string maLop       = (CboUtil.GetValueItem(comboBoxEditLop));
                int    siSoCanTren = _quyDinhBUS.LaySiSo_CanTren();
                if (_phanLopBUS.Dem_SiSo_Lop(maLop) >= siSoCanTren)
                {
                    MsgboxUtil.Error("Lớp " + CboUtil.GetDisplayItem(comboBoxEditLop)
                                     + " đã đủ học sinh theo quy định "
                                     + " (" + siSoCanTren + " học sinh / 1 lớp)!");
                    return;
                }
                spinEditSTTSoDiem.Value = _phanLopBUS.LaySTT_TiepTheo(maLop);
            }
            _Diable_Control(isAdding: true);
            _Reset_Control();
        }
 private void btnDangXuat_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         StaticClass.Log.GhiFile("Đăng xuất");
         StaticClass.DangNhap = false;
         StaticClass.User     = null;
         PhanQuyen();
         xtraTabControl1.TabPages.Clear();
         lblQuyen.Caption = "Bạn chưa đăng nhập.";
         lblTen.Caption   = "Vui lòng đăng nhập để sử dụng hệ thống.";
         MsgboxUtil.Info("Bạn đã đăng xuất.\nVui lòng đăng nhập để sử dụng hệ thống.");
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
         return;
     }
 }
 private void btnCauHinhCSDL_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         frmAddConnection frm = new frmAddConnection();
         if (frm.ShowDialog() == DialogResult.OK)
         {
             StaticClass.Log.GhiFile("Cấu hình kết nối CSDL");
             if (xtraTabControl1.TabPages.Count > 0)
             {
                 MsgboxUtil.Info("Chương trình sẽ đóng tất cả trang hiện tại để cấu hình CSDL");
                 xtraTabControl1.TabPages.Clear();
             }
         }
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
         return;
     }
 }
        private void simpleButtonChuyenLop_Click(object sender, EventArgs e)
        {
            if (!_KiemTra_LopMoi_DaChon())
            {
                return;
            }

            var dsHocSinhChon = new Dictionary <string, string>();

            for (int i = 0; i < gridViewDSHocSinh.RowCount; i++)
            {
                if (Convert.ToBoolean(gridViewDSHocSinh.GetRowCellValue(i, "Check")))
                {
                    dsHocSinhChon.Add(gridViewDSHocSinh.GetRowCellValue(i, "MaHocSinh").ToString(),
                                      gridViewDSHocSinh.GetRowCellValue(i, "TenHocSinh").ToString());
                }
            }
            if (dsHocSinhChon.Count == 0)
            {
                MsgboxUtil.Error("Bạn chưa chọn học sinh để chuyển!");
                return;
            }

            int siSoToiDa = _quyDinhBUS.LaySiSo_CanTren();


            // Chuyển cùng khối, chuyển và xóa hồ sơ cũ
            int siSoLopMoi;

            if (radioButtonChuyenLopCungKhoi.Checked)
            {
                string maLop     = CboUtil.GetValueItem(comboBoxEditLop),
                       tenLop    = CboUtil.GetDisplayItem(comboBoxEditLop),
                       maLopMoi  = CboUtil.GetValueItem(comboBoxEditLopMoi),
                       tenLopMoi = CboUtil.GetDisplayItem(comboBoxEditLopMoi);

                siSoLopMoi = _phanLopBUS.Dem_SiSo_Lop(maLopMoi);
                if (siSoLopMoi >= siSoToiDa)
                {
                    MsgboxUtil.Error("Không thể thực hiện vì lớp " +
                                     tenLopMoi + " (" + siSoLopMoi + " hs) đã đủ sỉ số học sinh quy định (" + siSoToiDa +
                                     " hs/Lớp)!");
                    return;
                }

                var chuyenLopDTO = new ChuyenLopDTO();
                chuyenLopDTO.TuLop          = maLop;
                chuyenLopDTO.DenLop         = maLopMoi;
                chuyenLopDTO.NgayChuyen     = DateTime.Now;
                chuyenLopDTO.LyDoChuyen     = textEditLyDoChuyen.Text.Replace("'", "''");
                chuyenLopDTO.GiuLaiBangDiem = checkEditChuyenBangDiem.Checked;


                if (_chuyenLopBUS.ChuyenLop_HocSinh_Lop(dsHocSinhChon, chuyenLopDTO))
                {
                    MsgboxUtil.Success("Đã chuyển toàn bộ hồ sơ học sinh từ lớp "
                                       + tenLop + " sang lớp " + tenLopMoi + " thành công!");
                }
                else
                {
                    MsgboxUtil.Info("Có lỗi trong quá trình chuyển!");
                }
            }
            else // phân lớp
            {
                string maLopMoi     = CboUtil.GetValueItem(comboBoxEditLopMoi),
                       tenLopMoi    = CboUtil.GetDisplayItem(comboBoxEditLopMoi),
                       tenNamHocMoi = CboUtil.GetDisplayItem(comboBoxEditNamHocMoi),
                       tenKhoiMoi   = CboUtil.GetDisplayItem(comboBoxEditKhoiMoi);


                siSoLopMoi = _phanLopBUS.Dem_SiSo_Lop(maLopMoi);
                int siSoDSChuyen = dsHocSinhChon.Count;
                if ((siSoDSChuyen + siSoLopMoi) >= siSoToiDa)
                {
                    MsgboxUtil.Error("Không thể thực hiện vì sau khi chuyển học sinh đến lớp " +
                                     tenLopMoi + " (" + siSoLopMoi + " hs) sẽ vượt quá quy định (" + siSoToiDa + ")!");
                    return;
                }

                if (MsgboxUtil.YesNo(
                        "Lưu ý: Các học sinh đã chọn nếu đã được phân lớp vào " + tenKhoiMoi
                        + " trong năm học " + tenNamHocMoi
                        + " sẽ được giữ nguyên hồ sơ.\nChương trình chỉ chuyển những học sinh chưa được phân lớp vào " +
                        tenKhoiMoi + " năm này."
                        + "\n\nBạn có muốn chuyển các học sinh đã chọn"
                        + " sang lớp: " + tenLopMoi + " năm học: " + tenNamHocMoi + " hay không?") == DialogResult.No)
                {
                    return;
                }
                List <PhanLopDTO> dsHsTonTai;
                if (_phanLopBUS.PhanLop_DSHocSinh_Lop(dsHocSinhChon, maLopMoi, out dsHsTonTai) &&
                    dsHsTonTai.Count == 0)
                {
                    MsgboxUtil.Success("Đã phân lớp danh sách học sinh đến lớp mới: " + tenLopMoi + ".");
                }
                else
                {
                    string dsHocsinhTonTai = "";
                    foreach (PhanLopDTO item in dsHsTonTai)
                    {
                        dsHocsinhTonTai = "\n" + item.STT + ". "
                                          + item.TenHocSinh + " (" + item.MaHocSinh + ") lớp: " + item.TenLop
                                          + dsHocsinhTonTai;
                    }
                    MsgboxUtil.Info("Các học sinh sau đã tồn tại trong năm " + tenNamHocMoi + ":"
                                    + dsHocsinhTonTai);
                }
            }
            // Cập nhật lại danh sách lớp mới
            comboBoxEditLopMoi_SelectedIndexChanged(sender, e);
            _LoadGridcontrolDSHocSinh();
            _LoadGridcontrolDSHocSinhMoi();
            // Cập nhật lại danh sách lớp cũ
            if (radioButtonPhanLopHoSo_ChuaPhanLop.Checked || radioButtonChuyenLopCungKhoi.Checked)
            {
                _LoadGridcontrolDSHocSinh();
            }

            _HienThi_Button();
        }
예제 #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                QuanLyDaoTao.Properties.Settings.Default.Server = cmbServerName.SelectedValue.ToString();
                QuanLyDaoTao.Properties.Settings.Default.SQLAuthenticationMode = rdbServerAuthentication.Checked;
                if (!string.IsNullOrEmpty(cmbDbName.Text))
                {
                    QuanLyDaoTao.Properties.Settings.Default.DatabaseName = cmbDbName.SelectedItem.ToString();
                }
                else
                {
                    QuanLyDaoTao.Properties.Settings.Default.DatabaseName = string.Empty;
                }

                //nếu chọn check box nhớ mật khẩu
                if (ckbRemeberPass.Checked)
                {
                    QuanLyDaoTao.Properties.Settings.Default.UserName     = txtUserName.Text;
                    QuanLyDaoTao.Properties.Settings.Default.Password     = txtPassword.Text;
                    QuanLyDaoTao.Properties.Settings.Default.SavePassword = true;
                }
                else
                {
                    QuanLyDaoTao.Properties.Settings.Default.UserName     = txtUserName.Text;
                    QuanLyDaoTao.Properties.Settings.Default.Password     = txtPassword.Text;
                    QuanLyDaoTao.Properties.Settings.Default.SavePassword = false;
                }
                //tạo kết nối đến server
                string message = ConnectDatabase();
                //nếu kết nối ko thành công
                if (!string.IsNullOrEmpty(message))
                {
                    MsgboxUtil.Exclamation(message);
                }
                //kết nối thành công
                else
                {
                    //chưa chọn database
                    if (QuanLyDaoTao.Properties.Settings.Default.DatabaseName == "")
                    {
                        MsgboxUtil.Exclamation("Chưa chọn database!");
                        return;
                    }
                    if (!this.CheckExists_Tables(QuanLyDaoTao.Properties.Settings.Default.DatabaseName))
                    {
                        this.InitStruct_DB(QuanLyDaoTao.Properties.Settings.Default.DatabaseName);
                    }

                    QuanLyDaoTao.Properties.Settings.Default.ConnectString = frmAddConnection.BuildConnectionString();
                    QuanLyDaoTao.Properties.Settings.Default.Save();
                    this.DialogResult = DialogResult.OK;
                    if (StaticClass.DangNhap)
                    {
                        StaticClass.Log.GhiFile("Kết nối với CSDL: " + QuanLyDaoTao.Properties.Settings.Default.DatabaseName);
                    }
                    MsgboxUtil.Info("Ứng dụng sẽ tự khởi động lại để cấu hình kết nối!");
                    DialogResult = DialogResult.OK;
                    Application.Restart();
                }
            }
            catch (Exception ex)
            {
                ExceptionUtil.ThrowMsgBox(ex.Message);
            }
        }