Ejemplo n.º 1
0
        private void simpleButtonLuu_Click(object sender, EventArgs e)
        {
            _currentRowEdit = gridViewMonHoc.FocusedRowHandle;

            // Sửa
            if (spinEditHeSo.Value < 1 || spinEditHeSo.Value > 3)
            {
                MsgboxUtil.Error("Hệ số của môn học "
                                 + textEditTenMonHoc.Text + " không được quá 3.");
                spinEditHeSo.Focus();
                return;
            }
            if (spinEditSoTiet.Value < 15 || spinEditSoTiet.Value > 120)
            {
                MsgboxUtil.Error("Số tiết của môn học không hợp lệ " +
                                 "(không thể nhỏ hơn 15 và quá 120)!");
                spinEditSoTiet.Focus();
                return;
            }

            var monHocDTO = new MonHocDTO
            {
                MaMonHoc  = textEditMaMonHoc.Text,
                TenMonHoc = textEditTenMonHoc.Text.Replace("'", "''"),
                SoTiet    = Convert.ToInt32(spinEditSoTiet.Value),
                HeSo      = Convert.ToInt32(spinEditHeSo.Value),
                TrangThai = Convert.ToInt32(radioGroupTrangThai.SelectedIndex)
            };

            _monHocBUS.CapNhat_MonHoc(monHocDTO);
            MsgboxUtil.Success("Đã cập nhật môn học: " + monHocDTO.TenMonHoc + " thành công!");
            _Load_GridView();
        }
 private void simpleButtonXoa_Click(object sender, EventArgs e)
 {
     if (_isDeleteButton)
     {
         if (!_nguoiDungBUS.KiemTraTonTai_NguoiDung(CboUtil.GetValueItem(comboBoxEditNguoiDung)))
         {
             _Reset_Control();
             return;
         }
         string tenNguoiDung = CboUtil.GetDisplayItem(comboBoxEditNguoiDung);
         if (MsgboxUtil.YesNo("Bạn có muốn xóa người dùng "
                              + tenNguoiDung + " hay không?") == DialogResult.Yes)
         {
             if (_nguoiDungBUS.Xoa_NguoiDung(CboUtil.GetValueItem(comboBoxEditNguoiDung)))
             {
                 MsgboxUtil.Success("Xóa người dùng "
                                    + tenNguoiDung + " thành công!");
                 gridControlNguoiDung.DataSource = _nguoiDungBUS.LayDT_NguoiDung();
                 return;
             }
         }
     }
     else
     {
         _Reset_Control();
         return;
     }
 }
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         PhongHoc p = new PhongHoc();
         if (!string.IsNullOrEmpty(txtMaPhong.Text))
         {
             p.MaPhong = txtMaPhong.Text;
         }
         else
         {
             MsgboxUtil.Exclamation("Mã phòng không được rỗng");
             return;
         }
         if (!string.IsNullOrEmpty(txtChucNang.Text))
         {
             p.ChucNang = txtChucNang.Text;
         }
         if (!string.IsNullOrEmpty(txtDiaChi.Text))
         {
             p.DiaChi = txtDiaChi.Text;
         }
         p.SucChua = (int)numSucChua.Value;
         PhongHocBUS.Them(p);
         StaticClass.LuuThayDoi();
         StaticClass.Log.GhiFile("Thêm mới phòng học: " + p.MaPhong);
         MsgboxUtil.Success("Thành công!");
         ClearText();
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 4
0
        private void simpleButtonXoa_Click(object sender, EventArgs e)
        {
            string maNamHoc  = CboUtil.GetValueItem(comboBoxEdit1);
            string tenNamHoc = CboUtil.GetDisplayItem(comboBoxEdit1);

            if (_isDeleteButton)
            {
                if (_namHocBUS.KiemTraTonTai_NamHoc(maNamHoc))
                {
                    // xóa
                    if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn xóa năm học"
                                         + tenNamHoc +
                                         " và tất cả hồ sơ: Lớp học, phân lớp, bảng điểm,... liên quan đến năm học này?")
                        == DialogResult.Yes)
                    {
                        _namHocBUS.Xoa_NamHoc(maNamHoc);
                        MsgboxUtil.Success("Đã xóa năm học " + tenNamHoc + " thành công!");
                        _Load_Lai_GridView();
                    }
                }
                else
                {
                    MsgboxUtil.Error("Không tồn tại năm học " + tenNamHoc);
                }
            }
            else // Không thêm
            {
                _Disable_Control(editing: false);
            }
        }
 private void btnPhucHoi_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         string         path = "";
         DataProvider   dp   = new DataProvider();
         OpenFileDialog open = new OpenFileDialog();
         open.Filter      = "Backup file (*.bak)|*.bak";
         open.Multiselect = false;
         if (open.ShowDialog() == DialogResult.OK)
         {
             this.Cursor = Cursors.WaitCursor;
             path        = open.FileName;
             if (dp.RestoreDatabase(path))
             {
                 this.Cursor = Cursors.Default;
                 StaticClass.Log.GhiFile("Phục hồi CSDL từ: " + path);
                 MsgboxUtil.Success("Phục hồi CSDL thành công!");
             }
         }
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Ejemplo n.º 6
0
        private void simpleButtonLuuGiaoVien_Click(object sender, EventArgs e)
        {
            _currentRowEdit = _isAddButton ? gridViewGiaoVien.FocusedRowHandle : 0;

            if (textEditTenGiaoVien.Text.Length <= 3 || !textEditTenGiaoVien.Text.Contains(" "))
            {
                MsgboxUtil.Error("Tên giáo viên không hợp lệ hoặc nhỏ hơn 3 ký tự!");
                textEditTenGiaoVien.Focus();
                return;
            }

            var giaoVienDTO = new GiaoVienDTO
            {
                MaGiaoVien  = textEditMaGiaoVien.Text,
                TenGiaoVien = textEditTenGiaoVien.Text.Replace("'", "''")
            };

            // Sửa
            if (_giaoVienBUS.KiemTonTai_HoSo_GiaoVien(giaoVienDTO.MaGiaoVien))
            {
                _giaoVienBUS.CapNhat_HoSo_GiaoVien(giaoVienDTO);
                MsgboxUtil.Success("Đã cập nhật hồ sơ giáo viên: " + giaoVienDTO.TenGiaoVien + " thành công!");
            }
            else // thêm
            {
                if (_giaoVienBUS.Them_HoSo_GiaoVien(giaoVienDTO))
                {
                    MsgboxUtil.Success("Đã tạo hồ sơ giáo viên: " + giaoVienDTO.TenGiaoVien + " thành công!");
                }
            }
            _Load_GridView();
            _Diable_Control(isAdding: false);
        }
Ejemplo n.º 7
0
        private void simpleButtonXoaGiaovien_Click(object sender, EventArgs e)
        {
            if (_isDeleteButton)
            {
                if (_giaoVienBUS.KiemTonTai_HoSo_GiaoVien(textEditMaGiaoVien.Text))
                {
                    if (MsgboxUtil.YesNo("Bạn có muốn xóa hồ sơ giáo viên: "
                                         + textEditTenGiaoVien.Text + " hay không?")
                        == DialogResult.No)
                    {
                        return;
                    }

                    _giaoVienBUS.Xoa_HoSo_GiaoVien(textEditMaGiaoVien.Text);
                    MsgboxUtil.Success("Đã xóa hồ sơ giáo viên: "
                                       + textEditTenGiaoVien.Text + " thành công!");
                    _Load_GridView();
                }
            }
            else // reset button
            {
                _Reset_Control();
                return;
            }
        }
 private void btnSaoLuu_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         string         path     = "";
         string         fileName = "";
         DataProvider   dp       = new DataProvider();
         SaveFileDialog save     = new SaveFileDialog();
         save.Filter = "Backup file (*.bak)|*.bak";
         if (save.ShowDialog() == DialogResult.OK)
         {
             this.Cursor = Cursors.WaitCursor;
             path        = save.FileName;
             fileName    = Path.GetFileName(path);
             path        = path.Substring(0, path.Length - (fileName.Length + 1));
             if (dp.BackupDatabase(fileName, path))
             {
                 this.Cursor = Cursors.Default;
                 StaticClass.Log.GhiFile("Sao lưu CSDL vào: " + path);
                 MsgboxUtil.Success("Sao lưu CSDL thành công!");
             }
         }
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Ejemplo n.º 9
0
 private void simpleButtonThem_Click(object sender, EventArgs e)
 {
     if (_isAddButton)
     {
         _Disable_Control(editing: true);
     }
     else
     {
         var namHocDTO = new NamHocDTO
         {
             MaNamHoc  = CboUtil.GetValueItem(comboBoxEdit1),
             TenNamHoc = CboUtil.GetDisplayItem(comboBoxEdit1)
         };
         // check & save
         if (_namHocBUS.KiemTraTonTai_NamHoc(namHocDTO.MaNamHoc))
         {
             MsgboxUtil.Error("Năm học " + namHocDTO.TenNamHoc
                              + " đã tồn tại. Hãy chọn 1 năm học khác!");
             return;
         }
         _namHocBUS.Them_NamHoc(namHocDTO);
         MsgboxUtil.Success("Đã tạo năm học mới thành công."
                            + "\nTiếp theo bạn hãy tạo danh sách lớp cho năm học này!");
         _Load_Lai_GridView();
     }
 }
        private void simpleButtonApDung_Click(object sender, EventArgs e)
        {
            string msg = "";

            if (textEdittenTruong.Text.Length < 3)
            {
                msg = "\nTên trường không hợp lệ! (lớn hơn 3 ký tự)";
            }
            if (textEditDiaChi.Text.Length < 3)
            {
                msg = "\nĐịa chỉ không hợp lệ! (lớn hơn 3 ký tự)";
            }
            if (spinEditSoLuongLop.Value <= 0)
            {
                msg = "\nSố lượng lớp tối đa không hợp lệ! (lớn hơn 0)";
            }
            if (spinEditSiSoToiDa.Value <= 0)
            {
                msg = "\nSỉ số lớp tối đa không hợp lệ! (lớn hơn 0)";
            }
            if (spinEditDoTuoiTu.Value <= 13 || spinEditDoTuoiDen.Value < 13)
            {
                msg = "\nTuổi cận trên hoặc tuổi cận dưới không hợp lệ! (lớn hơn 13)";
            }
            else if (spinEditDoTuoiTu.Value >= spinEditDoTuoiDen.Value)
            {
                msg = "\nTuổi cận dưới phải nhỏ hơn tuổi cận trên!";
            }
            if (spinEditDiemDat.Value < 5 || spinEditDiemDat.Value > 10)
            {
                msg = "\nĐiểm đạt môn không hợp lệ (trong khoảng 5 đến 10)!";
            }
            if (msg != "")
            {
                MsgboxUtil.Error(msg);
                return;
            }
            var quyDinh = new QuyDinhDTO
            {
                TenTruong    = textEdittenTruong.Text.Replace("'", "''"),
                DiaChiTruong = textEditDiaChi.Text.Replace("'", "''"),
                SoLuongLop   = Convert.ToInt32(spinEditSoLuongLop.Value),
                SiSoCanTren  = Convert.ToInt32(spinEditSiSoToiDa.Value),
                TuoiCanTren  = Convert.ToInt32(spinEditDoTuoiDen.Value),
                TuoiCanDuoi  = Convert.ToInt32(spinEditDoTuoiTu.Value),
                DiemChuan    = Convert.ToDouble(spinEditDiemDat.Value),
                NgayApDung   = Convert.ToDateTime(dateEditNgayAD.EditValue),
                MaNamHoc     = CboUtil.GetValueItem(comboBoxEditNamHoc)
            };

            if (_quyDinhBUS.CapNhat_QuyDinh(quyDinh))
            {
                MsgboxUtil.Success("Cập nhật quy định năm học thành công!");
            }
            else
            {
                MsgboxUtil.Error("Có lỗi trong quá trình cập nhật!");
            }
        }
        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();
        }
Ejemplo n.º 12
0
        private void simpleButtonGhiDuLieu_Click(object sender, EventArgs e)
        {
            _currentRowEdit = _isAddButton ? gridViewDSHocSinh.FocusedRowHandle : 0;

            var hocSinhDTO = new HocSinhDTO
            {
                NgaySinh   = Convert.ToDateTime(dateEditNgaySinh.EditValue),
                MaHocSinh  = textEditmaHocSinh.Text,
                TenHocSinh = textEditTenHocSinh.Text.Replace("'", "''"),
                GioiTinh   = radioGroupGioiTinh.SelectedIndex,
                NoiSinh    = textEditNoiSinh.Text.Replace("'", "''"),
                DiaChi     = textEditDiaChi.Text.Replace("'", "''"),
                Email      = textEditEmail.Text
            };

            string maLop = null;

            // neu co phan lop
            if (!checkEditChuaPhanLop.Checked)
            {
                hocSinhDTO.STT = Convert.ToInt32(spinEditSTTSoDiem.Value);
                maLop          = CboUtil.GetValueItem(comboBoxEditLop);
            }
            if (hocSinhDTO.TenHocSinh.Length < 3 || !hocSinhDTO.TenHocSinh.Contains(" "))
            {
                MsgboxUtil.Error("Họ tên học sinh không hợp lệ (không chứa khoảng trắng) hoặc nhỏ hơn 3 ký tự!");
                textEditTenHocSinh.Focus();
                return;
            }
            if (hocSinhDTO.NoiSinh.Length < 3)
            {
                MsgboxUtil.Error("Nơi sinh không hợp lệ (nhỏ hơn 3 ký tự)!");
                textEditNoiSinh.Focus();
                return;
            }
            if (hocSinhDTO.DiaChi.Length < 3)
            {
                MsgboxUtil.Error("Địa chỉ không hợp lệ (nhỏ hơn 3 ký tự)!");
                textEditDiaChi.Focus();
                return;
            }
            try
            {
                _hocSinhBUS.LuuHoSo_HocSinh(hocSinhDTO, maLop);
                MsgboxUtil.Success("Lưu hồ sơ học sinh " + hocSinhDTO.TenHocSinh + " thành công!");
            }
            catch (Exception ex)
            {
                MsgboxUtil.Error(ex);
                return;
            }
            LoadLai_GridControl_HocSinh(checkEditChuaPhanLop.Checked);
            _Diable_Control(isAdding: false);
        }
Ejemplo n.º 13
0
        private void barButtonItemCauHinhKetNoi_ItemClick(object sender, ItemClickEventArgs e)
        {
            CloseAll_TabPages();
            var frm = new FrmAddConnection();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                MsgboxUtil.Success("Đã lưu cấu hình của chương trình!");
                //  + "\nChương trình sẽ khởi động lại để cập nhật dữ liệu!");
                // Application.Restart();
            }
        }
Ejemplo n.º 14
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         StaticClass.LuuThayDoi();
         StaticClass.Log.GhiFile("Cập nhật thông tin một hoặc nhiều sinh viên");
         MsgboxUtil.Success("Đã cập nhật thay đổi vào CSDL");
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 15
0
        private void btnReload_Click(object sender, EventArgs e)
        {
            frmMatKhau frm = new frmMatKhau();

            frm.truyen += new frmMatKhau.TruyenMatKhau(GetMatKhau);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                NguoiDungBUS.ThietLapLaiMatKhau(txtTenDangNhap.Text, matKhau);
                NguoiDungBUS.LuuThayDoi();
                log.GhiFile("Thiết lập lại mật khẩu của người dùng " + txtTenDangNhap.Text);
                MsgboxUtil.Success("Đã thiết lập lại mật khẩu cho \"" + txtTenDangNhap.Text + "\"");
            }
        }
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         StaticClass.LuuThayDoi();
         string tam = nhapPhieuGiangDay1.MaLop;
         nhapPhieuGiangDay1.MaLop = tam;
         StaticClass.Log.GhiFile("Nhập phiếu giảng dạy cho lớp " + tam + " tuần " + cmbTuan.Text);
         MsgboxUtil.Success("Thành công");
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 17
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         BuoiHocBUS.Them(deNgiGiangDay1.buoiHocs);
         DeNghiBUS.Them(deNgiGiangDay1.deNghis);
         StaticClass.LuuThayDoi();
         StaticClass.Log.GhiFile("Thêm đề nghị giảng dạy cho tuần " + cmbTuan.Text);
         MsgboxUtil.Success("Thành công");
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 18
0
 private void simpleButtonSXLaiSTT_Click(object sender, EventArgs e)
 {
     if (checkEditChuaPhanLop.Checked)
     {
         MsgboxUtil.Error("Danh sách hiện tại chưa được phân lớp nên không thể sắp xếp STT!");
         return;
     }
     if (CboUtil.CheckSelectedNull(comboBoxEditLop))
     {
         MsgboxUtil.Error("Bạn chưa chọn lớp để thực hiện");
         return;
     }
     _phanLopBUS.CapNhapSTT_HocSinh_Lop(CboUtil.GetValueItem(comboBoxEditLop));
     MsgboxUtil.Success("Cập nhật số thự tự cho lớp thành công!");
     // Load lại gridcontrol học sinh
     LoadLai_GridControl_HocSinh();
 }
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         TrinhDo td = new TrinhDo();
         if (!string.IsNullOrEmpty(txtMaTrinhDo.Text))
         {
             td.MaTrinhDo = txtMaTrinhDo.Text.Trim();
         }
         else
         {
             MsgboxUtil.Exclamation("Mã trình độ không được để trống");
             txtMaTrinhDo.Focus();
             return;
         }
         if (!string.IsNullOrEmpty(txtTenTrinhDo.Text))
         {
             td.TenTrinhDo = txtTenTrinhDo.Text.Trim();
         }
         else
         {
             MsgboxUtil.Exclamation("Tên trình độ không được để trống");
             txtTenTrinhDo.Focus();
             return;
         }
         if (numLuong.Value > 0)
         {
             td.HeSoLuong = (int)numLuong.Value;
         }
         else
         {
             MsgboxUtil.Exclamation("Tên trình độ không được để trống");
             txtTenTrinhDo.Focus();
             return;
         }
         TrinhDoBUS.Them(td);
         StaticClass.LuuThayDoi();
         log.GhiFile("Thêm mới trình độ: " + td.MaTrinhDo);
         MsgboxUtil.Success("Thành công");
         btnHuy_Click(null, null);
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 20
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         ThoiKhoaBieuBUS.Them(thoiKhoaBieu1.TKBDangXep);
         StaticClass.LuuThayDoi();
         string tam = thoiKhoaBieu1.MaPhong;
         thoiKhoaBieu1.MaPhong = tam;
         MsgboxUtil.Success("Thành công");
         StaticClass.Log.GhiFile("Xếp TKB cho phòng " + tam + " " + cmbTuan.Text);
         thoiKhoaBieu1.TKBDangXep.Clear();
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 21
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         Lop lop = new Lop()
         {
             MaLop = txtMaLop.Text, MaNganh = cmbNganh.EditValue.ToString()
         };
         LopBUS.Them(lop);
         StaticClass.LuuThayDoi();
         log.GhiFile("Thêm mới lớp học: " + lop.MaLop);
         MsgboxUtil.Success("Thành công");
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 22
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         NganhHoc nh = new NganhHoc();
         if (TaoMoi(nh))
         {
             NganhHocBUS.Them(nh);
             StaticClass.LuuThayDoi();
             log.GhiFile("Thêm mới ngành học: " + nh.MaNganh);
             MsgboxUtil.Success("Thành công");
             ClearText();
         }
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
 private void btnThanhToan_Click(object sender, EventArgs e)
 {
     try
     {
         string maGV = gridViewGV.GetRowCellValue(rowHandle, "MaGV").ToString();
         foreach (var i in ThoiKhoaBieuBUS.ThongTinThanhToan(maGV, dateNgayBD.DateTime, dateNgayKT.DateTime))
         {
             ThoiKhoaBieuBUS.ThanhToan(i.MaPC, i.BuoiHoc);
         }
         StaticClass.LuuThayDoi();
         XuLyRowClick();
         StaticClass.Log.GhiFile("Thanh toán tiền lương cho giảng viên " + maGV + " từ " + dateNgayBD.DateTime.ToString("dd/MM/yyyy") + " đến " + dateNgayKT.DateTime.ToString("dd/MM/yyyy"));
         MsgboxUtil.Success("Đã thanh toán!");
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
        private void simpleButtonGhiDuLieu_Click(object sender, EventArgs e)
        {
            if (textEditTenLop.Text == "")
            {
                MsgboxUtil.Error("Bạn chưa nhập tên lớp!");
                return;
            }
            if (CboUtil.CheckSelectedNull(comboBoxEditGVCN))
            {
                MsgboxUtil.Error("Bạn chưa chọn GVCN!");
                return;
            }
            var lopDTO = new LopDTO();

            lopDTO.GiaoVien.MaGiaoVien = CboUtil.GetValueItem(comboBoxEditGVCN);

            string tenLop  = textEditTenLop.Text;
            string tTenLop = tenLop.Substring(0, 3);                                             // 10A
            int    hTenLop = Convert.ToInt32(tenLop.Substring(3, tenLop.Length - 3));            // 1

            tenLop = tTenLop + ((hTenLop < 10) ? "0" + hTenLop.ToString() : hTenLop.ToString()); // 10A01

            lopDTO.MaNamHoc  = CboUtil.GetValueItem(comboBoxEditNamHoc);
            lopDTO.MaLop     = tenLop + lopDTO.MaNamHoc;
            lopDTO.TenLop    = textEditTenLop.Text;
            lopDTO.MaKhoiLop = Convert.ToInt16(CboUtil.GetValueItem(comboBoxEditKhoi));


            if (_lopBUS.KiemTraTonTai_MaLop(lopDTO.MaLop))
            {
                _lopBUS.CapNhat_GiaoVienCN_Lop(lopDTO);
                MsgboxUtil.Success("Đã cập nhật lớp " + lopDTO.TenLop + " thành công!");
            }
            else
            {
                if (_lopBUS.Them_Lop(lopDTO))
                {
                    MsgboxUtil.Success("Đã tạo lớp " + lopDTO.TenLop + " thành công!");
                }
            }
            HienThi_DSLop();
        }
Ejemplo n.º 25
0
 private void btnDoiMK_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtMKCu.Text.Trim().Length == 0)
         {
             MsgboxUtil.Exclamation("Vui lòng nhập mật khẩu cũ của bạn!");
             txtMKCu.Focus();
             return;
         }
         if (txtMKMoi.Text.Trim().Length == 0)
         {
             MsgboxUtil.Exclamation("Vui lòng nhập mật khẩu mới của bạn!");
             txtMKMoi.Focus();
             return;
         }
         if (txtNhapLai.Text.Trim().Length == 0)
         {
             MsgboxUtil.Exclamation("Vui lòng xác minh mật khẩu mới!");
             txtNhapLai.Focus();
             return;
         }
         if (txtMKMoi.Text.Trim() != txtNhapLai.Text.Trim())
         {
             MsgboxUtil.Exclamation("Xác minh mật khẩu không đúng. Vui lòng xác minh lại!");
             txtMKMoi.ResetText();
             txtNhapLai.ResetText();
             txtMKMoi.Focus();
             return;
         }
         if (NguoiDungBUS.DoiMatKhau(StaticClass.User.TenDangNhap, txtMKCu.Text, txtMKMoi.Text))
         {
             StaticClass.Log.GhiFile("Đổi mật khẩu");
             MsgboxUtil.Success("Mật khẩu của bạn đã được thay đổi");
             this.Close();
         }
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 26
0
 private void btnTaoMoiDuLieuMau_Click(object sender, EventArgs e)
 {
     try
     {
         var dbName = cmbDbName.SelectedItem.ToString();
         if (!CheckExists_Tables(dbName))
         {
             InitStruct_DB(dbName);
         }
         InitData_DB(dbName);
         MsgboxUtil.Success("Đã tạo dữ liệu mẫu thành công!");
         if (StaticClass.DangNhap)
         {
             StaticClass.Log.GhiFile("Tạo dữ liệu mẫu cho ứng dụng");
         }
     }
     catch (SqlException ex)
     {
         MsgboxUtil.Error(ex.Message);
     }
 }
        private void simpleButtonXoa_Click(object sender, EventArgs e)
        {
            if (!_isDeleteButton) // button nhap lai
            {
                ResetControl();
                return;
            }
            if (_lopBUS.KiemTraTonTai_MaLop(textEditMaLop.Text))
            {
                if (MsgboxUtil.YesNo("Bạn có muốn xóa toàn bộ danh sách học sinh, "
                                     + "bảng điểm học sinh và toàn bộ thông tin liên quan đến lớp " +
                                     textEditTenLop.Text + " hay không?")
                    == DialogResult.No)
                {
                    return;
                }

                _lopBUS.Xoa_Lop(textEditMaLop.Text);
                MsgboxUtil.Success("Đã xóa lớp " + textEditTenLop.Text + " thành công!");
                HienThi_DSLop();
            }
        }
Ejemplo n.º 28
0
        private void btnTaoMoi_Click(object sender, EventArgs e)
        {
            if (txtNewDB.Text.Equals(""))
            {
                MsgboxUtil.Error("Hãy gõ tên database cần thêm!");
                return;
            }
            string   dbName = txtNewDB.Text;
            Database newDB  = new Database(_server, dbName);

            string msg = "";

            try
            {
                newDB.Create();
                ListDatabasesInServer(dbName);
            }
            catch (Exception ex)
            {
                msg = ex.Message;

                if (ex.InnerException != null)
                {
                    msg = ex.InnerException.Message;
                }
            }
            if (msg.Equals(""))
            {
                if (StaticClass.DangNhap)
                {
                    StaticClass.Log.GhiFile("Tạo mới CSDL: " + dbName);
                }
                MsgboxUtil.Success("Tạo database \"" + dbName + "\" thành công!");
            }
            else
            {
                MsgboxUtil.Error(msg);
            }
        }
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     try
     {
         SinhVien sv = new SinhVien();
         if (TaoMoi(sv))
         {
             frmMatKhau frm = new frmMatKhau();
             frm.truyen += new frmMatKhau.TruyenMatKhau(GetMatKhau);
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 NguoiDung user = new NguoiDung()
                 {
                     TenDangNhap  = sv.MSSV.ToLower(),
                     MatKhau      = UtilitiesClass.MaHoaMD5(_matKhau),
                     TenNguoiDung = sv.HoTen,
                     Quyen        = (int)QuyenNguoiDung.SinhVien,
                     MoTaQuyen    = "Sinh viên"
                 };
                 NguoiDungBUS.Them(user);
                 SinhVienBUS.Them(sv);
                 StaticClass.LuuThayDoi();
                 log.GhiFile("Thêm mới sinh viên: " + sv.MSSV);
                 MsgboxUtil.Success("Thành công");
                 ClearText();
                 TaoMa();
             }
             else
             {
                 MsgboxUtil.Exclamation("Không thể thêm sinh viên khi chưa thiết lập mật khẩu");
             }
         }
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Ejemplo n.º 30
0
        private void simpleButtonXoa_Click(object sender, EventArgs e)
        {
            if (!_isDeleteButton)
            {
                _Reset_Control();
                return;
            }

            if (textEditmaHocSinh.Text == "")
            {
                MsgboxUtil.Error("Bạn chưa chọn học sinh để thực hiện xóa!");
                return;
            }
            if (
                MsgboxUtil.YesNo("Bạn có chắc chắn muốn xóa toàn bộ hồ sơ học sinh \"" + textEditTenHocSinh.Text +
                                 "\" hay không?") == DialogResult.No)
            {
                return;
            }
            _hocSinhBUS.Xoa_HoSo_HocSinh(textEditmaHocSinh.Text);
            MsgboxUtil.Success("Xóa hồ sơ học sinh thành công!");
            LoadLai_GridControl_HocSinh(checkEditChuaPhanLop.Checked);
        }