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 simpleButtonLuu_Click(object sender, EventArgs e) { if (cmbNamHocCu.SelectedValue != null && cmbKhoiLopCu.SelectedValue != null && cmbLopCu.SelectedValue != null && cmbNamHocMoi.SelectedValue != null && cmbKhoiLopMoi.SelectedValue != null && cmbLopMoi.SelectedValue != null) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn lưu không?") == DialogResult.Yes) { m_HocSinhCtrl.LuuHSVaoBangQuaTrinhHoc( cmbHocKyMoi.SelectedValue.ToString(), cmbLopMoi.SelectedValue.ToString(), lVLopMoi); MessageBoxEx.Show("Đã lưu học sinh vào lớp " + cmbLopMoi.Text + " thành công !", "COMPLETED", MessageBoxButtons.OK, MessageBoxIcon.Information); lVLopMoi.Items.Clear(); return; } else { return; } } else { MessageBoxEx.Show("Giá trị của các ô không được rỗng!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void simpleButtonLuu_Click(object sender, EventArgs e) { if (_isAddButton) { _Disable_Control(editing: false); } else { var namHocDTO = new NamHocDTO { MaNamHoc = CboUtil.GetValueItem(comboBoxEdit1), TenNamHoc = CboUtil.GetDisplayItem(comboBoxEdit1) }; // check & save if (m_NamHocData.kiemtratontai(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; } m_NamHocCtrl.LuuNamHocMoi(namHocDTO.MaNamHoc, namHocDTO.TenNamHoc); 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 simpleButtonLuu_Click(object sender, EventArgs e) { if (simpleButtonLuu.Text == "Cập nhật (Alt+&U)") { if (KiemTraTruocKhiLuu("colMaND") == true && KiemTraTruocKhiLuu("colMaLoai") == true && KiemTraTruocKhiLuu("colMaGiaoVien") == true && KiemTraTruocKhiLuu("colTenDNhap") == true && KiemTraTruocKhiLuu("colMatKhau") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn cập nhật không?") == DialogResult.Yes) { m_NguoiDungCtrl.LuuNguoiDung(); MsgboxUtil.Success("Đã cập nhật thành công!"); m_LoaiNguoiDungCtrl.HienThiDataGridViewComboBoxColumn(colMaLoai); m_GiaoVienCtrl.HienThiDataGridViewComboBoxColumn(colMaGiaoVien); m_NguoiDungCtrl.HienThi(dGVNguoiDung, bindingNavigatorNguoiDung); return; } else { m_LoaiNguoiDungCtrl.HienThiDataGridViewComboBoxColumn(colMaLoai); m_GiaoVienCtrl.HienThiDataGridViewComboBoxColumn(colMaGiaoVien); m_NguoiDungCtrl.HienThi(dGVNguoiDung, bindingNavigatorNguoiDung); return; } } else { return; } } if (KiemTraTruocKhiLuu("colMaND") == true && KiemTraTruocKhiLuu("colMaLoai") == true && KiemTraTruocKhiLuu("colMaGiaoVien") == true && KiemTraTruocKhiLuu("colTenDNhap") == true && KiemTraTruocKhiLuu("colMatKhau") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn thêm người dùng này không?") == DialogResult.Yes) { bindingNavigatorPositionItem.Focus(); m_NguoiDungCtrl.LuuNguoiDung(); MsgboxUtil.Success("Bạn đã lưu thành công"); _Disable_Control(editing: false); } else { return; } } }
private void btnSaoLuu_Click(object sender, EventArgs e) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn sao lưu dữ liệu không?") == DialogResult.Yes) { bool bBackUpStatus = true; Cursor.Current = Cursors.WaitCursor; if (Directory.Exists(@"c:\SQLBackup")) { if (File.Exists(@"c:\SQLBackup\wcBackUp1.bak")) { if (MessageBox.Show(@"Do you want to replace it?", "Back", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { File.Delete(@"c:\SQLBackup\wcBackUp1.bak"); } else { bBackUpStatus = false; } } } else { Directory.CreateDirectory(@"c:\SQLBackup"); } Directory.CreateDirectory(@"c:\SQLBackup"); if (bBackUpStatus) { //Connect to DB SqlConnection connect; string con = "Data Source = SONSE\\SQLEXPRESS; Initial Catalog=QLHS_THPT ;Integrated Security = True;"; connect = new SqlConnection(con); connect.Open(); //---------------------------------------------------------------------------------------------------- //Execute SQL--------------- SqlCommand command; command = new SqlCommand(@"backup database QLHS_THPT to disk ='c:\SQLBackup\wcBackUp1.bak' with init,stats=10", connect); command.ExecuteNonQuery(); //------------------------------------------------------------------------------------------------------------------------------- connect.Close(); MessageBox.Show("Sao lưu dữ liệu thành công", "THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { return; } }
private void textEditTenLop_InvalidValue(object sender, InvalidValueExceptionEventArgs e) { if (cmbKhoi.SelectedValue == null) { MsgboxUtil.Error("Bạn chưa chọn khối lớp!"); return; } string maKhoi = cmbKhoi.SelectedValue.ToString(); e.ErrorText = "Tên lớp không hợp lệ. Tên lớp có dạng " + maKhoi + "[A-Z][0-9][0-9]. VD: " + maKhoi + "B02"; }
private void btnTimKiem_Click(object sender, EventArgs e) { if (txtTimKiem.Text == "") { MsgboxUtil.Error("Bạn chưa nhập thông tin vào ô tìm kiếm."); return; } else { simpleButtonThem.Enabled = false; TimKiemHocSinh(); } }
public Boolean KiemTraSiSoTruocKhiLuu(String siSoColumn) { var lopDTO = new LopDTO(); lopDTO.SiSo = iniSiSo.Value; if (quyDinh.KiemTraSiSo(lopDTO.SiSo) == false) { MsgboxUtil.Error("Sĩ số không đúng quy định!"); return(false); } return(true); }
private void simpleButtonLuu_Click(object sender, EventArgs e) { if (simpleButtonLuu.Text == "Cập nhật (Alt+&U)") { if (KiemTraTruocKhiLuu("colMaGiaoVien") == true && KiemTraTruocKhiLuu("colTenGiaoVien") == true && KiemTraTruocKhiLuu("colMaMonHoc") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn cập nhật không?") == DialogResult.Yes) { m_GiaoVienCtrl.LuuGiaoVien(); MsgboxUtil.Success("Đã cập nhật thành công!"); m_MonHocCtrl.HienThiDataGridViewComboBoxColumnGiaoVien(colMaMonHoc); m_GiaoVienCtrl.HienThi(dGVGiaoVien, bindingNavigatorGiaoVien); return; } else { m_MonHocCtrl.HienThiDataGridViewComboBoxColumnGiaoVien(colMaMonHoc); m_GiaoVienCtrl.HienThi(dGVGiaoVien, bindingNavigatorGiaoVien); return; } } else { return; } } if (KiemTraTruocKhiLuu("colMaGiaoVien") == true && KiemTraTruocKhiLuu("colTenGiaoVien") == true && KiemTraTruocKhiLuu("colMaMonHoc") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn thêm giáo viên này không?") == DialogResult.Yes) { bindingNavigatorPositionItem.Focus(); m_GiaoVienCtrl.LuuGiaoVien(); MsgboxUtil.Success("Bạn đã lưu thành công"); _Disable_Control(editing: false); } else { return; } } }
private void btnHienThiDanhSach_Click(object sender, EventArgs e) { if (cmbKhoi.SelectedValue == null) { MsgboxUtil.Error("Bạn chưa chọn khối lớp!"); return; } if (cmbNamHoc.SelectedValue != null && cmbKhoi.SelectedValue != null) { HienThi_DSLop(); simpleButtonThemMoi.Enabled = true; simpleButtonGhiDuLieu.Enabled = true; simpleButtonXoa.Enabled = true; textEditTenLop.Enabled = true; } }
private void btnCapNhatMonHoc_Click(object sender, EventArgs e) { if (cmbNamHoc.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn năm học!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbKhoiLop.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn khối lớp!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbLop.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn lớp!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbMonHoc.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn môn học!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (textBoxHeSo.Text == "") { MessageBoxEx.Show("Giá trị của ô hệ số không được rỗng, hệ số phải lớn hơn 0!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (iniSoTiet.Value == null) { MessageBoxEx.Show("Giá trị của ô số tiết không được rỗng, số tiết phải lớn hơn 0!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MsgboxUtil.YesNo("Bạn có muốn cập nhật môn " + cmbMonHoc.Text + " với số tiết bằng " + iniSoTiet.Text + " và hệ số bằng " + textBoxHeSo.Text + " hay không?") == DialogResult.No) { return; } m_ChuongTrinhHocCtrl.CapNhatChuongTrinhHoc(cmbLop.SelectedValue.ToString(), cmbMonHoc.SelectedValue.ToString(), Convert.ToInt32(textBoxHeSo.Text), iniSoTiet.Value); m_MonHocCtrl.HienThiDataGridViewComboBoxColumn(colMaMonHoc, cmbNamHoc.SelectedValue.ToString(), cmbLop.SelectedValue.ToString()); m_ChuongTrinhHocCtrl.HienThi(dGVMonHoc, bindingNavigatorMonHoc, cmbNamHoc.SelectedValue.ToString(), cmbLop.SelectedValue.ToString()); iniSoTiet.Text = ""; textBoxHeSo.Text = ""; MsgboxUtil.Success("Đã cập nhật môn " + cmbMonHoc.Text + " của lớp " + cmbLop.Text + " thành công!"); }
private void simpleButtonLuu_Click(object sender, EventArgs e) { if (simpleButtonLuu.Text == "Cập nhật (Alt+&U)") { if (KiemTraTruocKhiLuu("colMaHocSinh") == true && KiemTraTruocKhiLuu("colHoTen") == true && KiemTraTruocKhiLuu("colEmail") == true && KiemTraTruocKhiLuu("colDiaChi") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn cập nhật không?") == DialogResult.Yes) { m_HocSinhCtrl.LuuHocSinh(); MsgboxUtil.Success("Đã cập nhật thành công!"); m_HocSinhCtrl.HienThi(dGVHocSinh, bindingNavigatorHocSinh); return; } else { m_HocSinhCtrl.HienThi(dGVHocSinh, bindingNavigatorHocSinh); return; } } else { return; } } if (KiemTraTruocKhiLuu("colMaHocSinh") == true && KiemTraTruocKhiLuu("colHoTen") == true && KiemTraTruocKhiLuu("colEmail") == true && KiemTraTruocKhiLuu("colDiaChi") == true) { if (KiemTraDoTuoiTruocKhiLuu("colNgaySinh") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn thêm học sinh này không?") == DialogResult.Yes) { bindingNavigatorPositionItem.Focus(); m_HocSinhCtrl.LuuHocSinh(); MsgboxUtil.Success("Bạn đã lưu học sinh này thành công."); _Disable_Control(editing: false); } } } }
private void simpleButtonLuu_Click(object sender, EventArgs e) { if (simpleButtonLuu.Text == "Cập nhật (Alt+&U)") { if (KiemTraTruocKhiLuu("colMaKhoiLop") == true && KiemTraTruocKhiLuu("colTenkhoiLop") == true && KiemTraTruocKhiLuu("colKyHieu") == true && KiemTraTruocKhiLuu("colSoLop") == true && KiemTraTruocKhiLuu("colMaNamHoc") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn cập nhật không?") == DialogResult.Yes) { m_KhoiLopCtrl.LuuKhoiLop(); MsgboxUtil.Success("Đã cập nhật thành công!"); m_KhoiLopCtrl.HienThi(dGVKhoiLop, bindingNavigatorKhoiLop); return; } else { m_KhoiLopCtrl.HienThi(dGVKhoiLop, bindingNavigatorKhoiLop); return; } } else { return; } } if (KiemTraTruocKhiLuu("colMaKhoiLop") == true && KiemTraTruocKhiLuu("colTenkhoiLop") == true && KiemTraTruocKhiLuu("colKyHieu") == true && KiemTraTruocKhiLuu("colSoLop") == true && KiemTraTruocKhiLuu("colMaNamHoc") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn thêm khối lớp không?") == DialogResult.Yes) { bindingNavigatorPositionItem.Focus(); m_KhoiLopCtrl.LuuKhoiLop(); MsgboxUtil.Success("Bạn đã lưu khối lớp thành công."); _Disable_Control(editing: false); } } }
private void simpleButtonLuu_Click(object sender, EventArgs e) { if (simpleButtonLuu.Text == "Cập nhật (Alt+&U)") { if (KiemTraTruocKhiLuu("colMaLoai") == true && KiemTraTruocKhiLuu("colTenLoai") == true && KiemTraTruocKhiLuu("colHeSo") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn cập nhật không?") == DialogResult.Yes) { m_LoaiDiemCtrl.LuuLoaiDiem(); MsgboxUtil.Success("Đã cập nhật thành công!"); m_LoaiDiemCtrl.HienThi(dGVLoaiDiem, bindingNavigatorLoaiDiem); return; } else { m_LoaiDiemCtrl.HienThi(dGVLoaiDiem, bindingNavigatorLoaiDiem); return; } } else { return; } } if (KiemTraTruocKhiLuu("colMaLoai") == true && KiemTraTruocKhiLuu("colTenLoai") == true && KiemTraTruocKhiLuu("colHeSo") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn thêm loại kiểm tra này không?") == DialogResult.Yes) { bindingNavigatorPositionItem.Focus(); m_LoaiDiemCtrl.LuuLoaiDiem(); MsgboxUtil.Success("Bạn đã lưu thành công."); _Disable_Control(editing: false); } } }
private void btnXoa_Click(object sender, EventArgs e) { if (lVLopMoi.SelectedItems.Count == 0) { MsgboxUtil.Error("Danh sách chưa có học sinh"); return; } else { if (MessageBoxEx.Show("Bạn có muốn xóa học sinh này khỏi lớp mới không?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { IEnumerator ie = lVLopMoi.SelectedItems.GetEnumerator(); while (ie.MoveNext()) { ListViewItem item = (ListViewItem)ie.Current; lVLopMoi.Items.Remove(item); lVLopCu.Items.Add(item); } } } }
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(); } }
private void btnPhucHoi_Click(object sender, EventArgs e) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn phục hồi dữ liệu không?") == DialogResult.Yes) { if (restoreDialog.ShowDialog() == DialogResult.OK) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("USE master RESTORE DATABASE " + Utilities.DatabaseName + " FROM DISK = '" + restoreDialog.FileName.ToString() + "'"); DataService data = new DataService(); data.Load(cmd); MessageBoxEx.Show("Phục hồi dữ liệu thành công!", "RESTORE COMPLETED", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { return; } } else { return; } }
private void btnHienThiDSHSMoi_Click(object sender, EventArgs e) { if (cmbHocKyMoi.SelectedValue == null) { MsgboxUtil.Error("Bạn chưa chọn học kỳ mới"); return; } if (cmbKhoiLopMoi.SelectedValue == null) { MsgboxUtil.Error("Bạn chưa chọn khối lớp mới"); return; } if (cmbLopMoi.SelectedValue == null) { MsgboxUtil.Error("Bạn chưa chọn lớp mói"); return; } if (cmbLopMoi.SelectedValue != null && cmbNamHocMoi.SelectedValue != null && cmbKhoiLopMoi.SelectedValue != null) { m_HocSinhCtrl.HienThiDsHocSinhTheoLop1(cmbNamHocMoi.SelectedValue.ToString(), cmbLopMoi.SelectedValue.ToString(), cmbHocKyMoi.SelectedValue.ToString(), lVLopMoi); } }
private void simpleButtonGhiDuLieu_Click(object sender, EventArgs e) { if (cmbKhoi.Text == "") { MsgboxUtil.Error("Bạn chưa chọn khối lớp!"); return; } 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; } if (iniSiSo.Value <= 0) { MsgboxUtil.Error("Bạn chưa nhập sĩ số!"); return; } var lopDTO = new LopDTO(); lopDTO.GiaoVien.MaGiaoVien = CboUtil.GetValueItem(comboBoxEditGVCN); int soLopToiDa = _lopBUS.Lay_SoLop_KhoiLop(cmbKhoi.SelectedValue.ToString()); if (gridViewLop.DataRowCount >= soLopToiDa) { MsgboxUtil.Error("Không thể thực hiện vì " + cmbKhoi.Text + " năm học " + cmbNamHoc.Text + " đã đủ " + soLopToiDa + " lớp"); return; } string tenLop = textEditTenLop.Text; string tenkyhieu = txtkyhieu.Text; string tTenLop = tenLop.Substring(0, 3); // 10A if (cmbKhoi.Text == "Khối 10") { if (tenLop.Substring(0, 2) != "10") { MsgboxUtil.Error("Năm học " + cmbNamHoc.Text + " , " + cmbKhoi.Text + " có ký hiệu tên lớp học là 10"); return; } } if (cmbKhoi.Text == "Khối 11") { if (tenLop.Substring(0, 2) != "11") { MsgboxUtil.Error("Năm học " + cmbNamHoc.Text + " , " + cmbKhoi.Text + " có ký hiệu tên lớp học là 11"); return; } } if (cmbKhoi.Text == "Khối 12") { if (tenLop.Substring(0, 2) != "12") { MsgboxUtil.Error("Năm học " + cmbNamHoc.Text + " , " + cmbKhoi.Text + " có ký hiệu tên lớp học là 12"); return; } } if (tenkyhieu != tenLop.Substring(2, 1)) { MsgboxUtil.Error("Năm học " + cmbNamHoc.Text + " , " + cmbKhoi.Text + " có ký hiệu lớp học là " + txtkyhieu.Text); return; } int hTenLop = Convert.ToInt32(tenLop.Substring(3, tenLop.Length - 3)); // 1 tenLop = tTenLop + ((hTenLop < 10) ? "0" + hTenLop.ToString() : hTenLop.ToString()); // 10A01 lopDTO.MaNamHoc = cmbNamHoc.SelectedValue.ToString(); lopDTO.MaLop = tenLop + lopDTO.MaNamHoc; lopDTO.MaKhoiLop = cmbKhoi.SelectedValue.ToString(); lopDTO.SiSo = iniSiSo.Value; if (simpleButtonGhiDuLieu.Text == "Cập nhật (Alt+&U)") { if (KiemTraSiSoTruocKhiLuu(iniSiSo.Value.ToString()) == false) { HienThi_DSLop(); return; } else { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn cập nhật không?") == DialogResult.Yes) { _lopBUS.CapNhat_GiaoVienCN_Lop(lopDTO); MsgboxUtil.Success("Đã cập nhật lớp " + textEditTenLop.Text + " thành công!"); HienThi_DSLop(); return; } else { HienThi_DSLop(); return; } } } if (_lopBUS.KiemTraTonTai_MaLop(lopDTO.MaLop)) { if (KiemTraSiSoTruocKhiLuu(iniSiSo.Value.ToString()) == true) { MsgboxUtil.Success("Tên lớp " + tenLop + " đã tồn tại!"); return; } } else { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn thêm lớp " + textEditTenLop.Text + " vào năm học " + cmbNamHoc.Text + " không?") == DialogResult.Yes) { if (KiemTraSiSoTruocKhiLuu(iniSiSo.Value.ToString()) == true) { m_LopCtrl.LuuLop(lopDTO.MaLop, textEditTenLop.Text, lopDTO.MaKhoiLop, lopDTO.MaNamHoc, lopDTO.SiSo, lopDTO.GiaoVien.MaGiaoVien); MsgboxUtil.Success("Đã tạo lớp " + lopDTO.TenLop + " thành công!"); HienThi_DSLop(); } return; } else { return; } } HienThi_DSLop(); }
public static void ThrowMsgBox(string msg) { MsgboxUtil.Error(msg); }
private void simpleButtonLuu_Click(object sender, EventArgs e) { if (dGVDiem.RowCount == 0) { MessageBoxEx.Show("Chưa có học sinh!", "CHÚ Ý", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (KiemTraDiemTruocKhiLuu("colDiem") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn cập nhật không ?") == DialogResult.Yes) { if (STT != null) { int rowcount = 0; foreach (DataGridViewRow row in dGVDiem.Rows) { rowcount++; #region Kiểm tra miệng if (row.Cells["colDiem"].Value != null) { String chuoiDiemChuaXuLy = row.Cells["colDiem"].Value.ToString(); String diemDaXuLy = null; int count = 0; for (int i = 0; i < chuoiDiemChuaXuLy.Length; i++) { if (chuoiDiemChuaXuLy[i] != ';' && i != chuoiDiemChuaXuLy.Length - 1) { count++; } else { if (i == chuoiDiemChuaXuLy.Length - 1) { i++; count++; } diemDaXuLy = chuoiDiemChuaXuLy.Substring(i - count, count); if (diemDaXuLy != null && diemDaXuLy != " " && quyDinh.KiemTraDiem(diemDaXuLy)) { m_DiemCtrl.LuuDiem(row.Cells["colMaQuaTrinhHoc"].Value.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbLoaiDiem.SelectedValue.ToString(), float.Parse(diemDaXuLy.ToString())); } diemDaXuLy = null; count = 0; } } } #endregion #region Lưu vào bảng kết quả if (rowcount <= dGVDiem.Rows.Count) { m_BaoCaoTongKetMonCtrl.LuuKetQuaSD(row.Cells["colMaQuaTrinhHoc"].Value.ToString(), cmbMonHoc.SelectedValue.ToString()); m_BaoCaoTongKetMonCtrl.LuuKetQua1(cmbHocKy.SelectedValue.ToString(), cmbLop.SelectedValue.ToString(), cmbMonHoc.SelectedValue.ToString()); m_BaoCaoTongKetHocKyCtrl.LuuKetQua1(cmbHocKy.SelectedValue.ToString(), cmbLop.SelectedValue.ToString()); } #endregion #region Xóa các kết quả cũ if (STT != null) { for (int i = 1; i < 60; i++) { for (int j = 1; j < 20; j++) { int id = STT[i, j]; if (id > 0) { m_DiemCtrl.XoaBangDiem(id); // m_DiemCtrl.XoaDiem(id); } else { break; } } } } #endregion } MessageBoxEx.Show("Cập nhật thành công!", "COMPLETED", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void simpleButtonLuu_Click(object sender, EventArgs e) { string msg = ""; if (txtTenTruong.Text.Length < 3) { msg = "\nTên trường không hợp lệ! (lớn hơn 3 ký tự)"; } if (txtDiaChiTruong.Text.Length < 3) { msg = "\nĐịa chỉ không hợp lệ! (lớn hơn 3 ký tự)"; } if (integerInputSiSoToiDaMoi.Value <= 0) { msg = "\nSỉ số lớp tối đa không hợp lệ! (lớn hơn 0)"; } else if (integerInputTuoiToiThieuMoi.Value >= integerInputTuoiToiDaMoi.Value) { msg = "\nTuổi tối thiểu phải nhỏ hơn tuổi tối đa!"; } if (msg != "") { MsgboxUtil.Error(msg); return; } var quyDinh = new QuyDinhDTO { TenTruong = txtTenTruong.Text.Replace("'", "''"), DiaChiTruong = txtDiaChiTruong.Text.Replace("'", "''"), SiSoToiDa = Convert.ToInt32(integerInputSiSoToiDaMoi.Value), TuoiToiDa = Convert.ToInt32(integerInputTuoiToiDaMoi.Value), TuoiToiThieu = Convert.ToInt32(integerInputTuoiToiThieuMoi.Value), DiemToiThieu = Convert.ToDouble(spinEditDiemToiThieuMoi.Value), DiemToiDa = Convert.ToDouble(spinEditDiemToiDaMoi.Value), DiemDat = Convert.ToDouble(spinEditDiemDatMoi.Value), DiemDatMon = Convert.ToDouble(spinEditDiemDatMonMoi.Value), NgayApDungDiemDat = dateTimePickerDiemDat.Value, NgayApDungDiemDatMon = dateTimePickerDiemDatMon.Value, NgayApDungDiemToiThieu = dateTimePickerDiemToiThieu.Value, NgayApDungDiemToiDa = dateTimePickerDiemToiDa.Value, NgayApDungSiSoToiDa = dateTimePickerSiSoToiDa.Value, NgayApDungTuoiToiThieu = dateTimePickerTuoiToiThieu.Value, NgayApDungTuoiToiDa = dateTimePickerTuoiToiDa.Value, }; if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn cập nhật không?") == DialogResult.Yes) { 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!"); } return; } else { return; } }
private void simpleButtonLuu_Click(object sender, EventArgs e) { if (dGVDiem.RowCount == 0) { MessageBoxEx.Show("Chưa có học sinh!", "CHÚ Ý", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (cmbHocKy.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn học kỳ!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbLop.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn lớp!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbMonHoc.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn môn học!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (KiemTraDiemTruocKhiLuu("colDiem") == true) { if (MsgboxUtil.YesNo("Bạn có chắc chắn muốn lưu không ?") == DialogResult.Yes) { if (STT == null) { int rowcount = 0; foreach (DataGridViewRow row in dGVDiem.Rows) { rowcount++; if (row.Cells["colDiem"].Value != null) { String chuoiDiemChuaXuLy = row.Cells["colDiem"].Value.ToString(); String diemDaXuLy = null; int count = 0; for (int i = 0; i < chuoiDiemChuaXuLy.Length; i++) { if (chuoiDiemChuaXuLy[i] != ';' && i != chuoiDiemChuaXuLy.Length - 1) { count++; } else { if (i == chuoiDiemChuaXuLy.Length - 1) { i++; count++; } diemDaXuLy = chuoiDiemChuaXuLy.Substring(i - count, count); if (diemDaXuLy != null && diemDaXuLy != " " && quyDinh.KiemTraDiem(diemDaXuLy)) { m_DiemCtrl.LuuDiem(row.Cells["colMaQuaTrinhHoc"].Value.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbLoaiDiem.SelectedValue.ToString(), float.Parse(diemDaXuLy.ToString())); } diemDaXuLy = null; count = 0; } } } if (rowcount <= dGVDiem.Rows.Count) { m_BaoCaoTongKetMonCtrl.LuuKetQua(row.Cells["colMaQuaTrinhHoc"].Value.ToString(), cmbMonHoc.SelectedValue.ToString()); m_BaoCaoTongKetHocKyCtrl.LuuKetQua(row.Cells["colMaQuaTrinhHoc"].Value.ToString()); } } m_BaoCaoTongKetMonCtrl.LuuKetQua1(cmbHocKy.SelectedValue.ToString(), cmbLop.SelectedValue.ToString(), cmbMonHoc.SelectedValue.ToString()); m_BaoCaoTongKetHocKyCtrl.LuuKetQua1(cmbHocKy.SelectedValue.ToString(), cmbLop.SelectedValue.ToString()); } MessageBoxEx.Show("Đã lưu thành công!", "Thành Công", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { return; } } }
private void btnChuyen_Click(object sender, EventArgs e) { if (cmbNamHocCu.Text != cmbNamHocMoi.Text) { MsgboxUtil.Error("Bạn phải chọn năm học mới giống năm học cũ"); return; } if (cmbKhoiLopCu.Text != cmbKhoiLopMoi.Text) { MsgboxUtil.Error("Bạn phải chọn khối lớp học mới giống khối lớp học cũ"); return; } if (cmbHocKyCu.Text == cmbHocKyMoi.Text) { MsgboxUtil.Error("Bạn phải chọn học kỳ mới khác học kỳ cũ"); return; } int siSoToiDa = _lopBUS.Lay_SiSo_Lop(cmbLopMoi.SelectedValue.ToString(), cmbNamHocMoi.SelectedValue.ToString()); int siSoLopMoi; siSoLopMoi = _quyDinhBUS.Dem_SiSo_Lop(cmbLopMoi.SelectedValue.ToString(), cmbHocKyMoi.SelectedValue.ToString()); if (siSoLopMoi >= siSoToiDa) { MsgboxUtil.Error("Không thể thực hiện vì lớp " + cmbLopMoi.Text + " (" + siSoLopMoi + " học sinh) đã đủ sĩ số học sinh quy định (" + siSoToiDa + " học sinh/Lớp)!"); return; } if ((siSoLopMoi) >= siSoToiDa) { MsgboxUtil.Error("Không thể thực hiện vì lớp " + cmbLopMoi.Text + " (" + (siSoLopMoi + lVLopMoi.Items.Count) + " học sinh) đã đủ sĩ số học sinh quy định (" + siSoToiDa + " học sinh/Lớp)!"); return; } IEnumerator ie = lVLopCu.SelectedItems.GetEnumerator(); while (ie.MoveNext()) { ListViewItem olditem = (ListViewItem)ie.Current; ListViewItem newitem = new ListViewItem(); //Trạng thái học sinh đã được chuyển lớp hay chưa? bool state = false; foreach (ListViewItem item in lVLopMoi.Items) { if (item.SubItems[0].Text == olditem.SubItems[0].Text) { MessageBoxEx.Show("Học sinh " + item.SubItems[1].Text + " hiện đang học trong lớp " + cmbLopMoi.Text, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); state = true; goto Cont; } } DataTable dT = new DataTable(); if (cmbNamHocMoi.SelectedValue != null) { //dT = m_HocSinhCtrl.HienThiDsHocSinhTheoNamHoc(cmbNamHocMoi.SelectedValue.ToString()); dT = m_HocSinhCtrl.HienThiDsHocSinhTheoHocKy_Lop(cmbHocKyMoi.SelectedValue.ToString(), cmbLopMoi.SelectedValue.ToString()); } foreach (DataRow row in dT.Rows) { if (olditem.SubItems[1].Text.ToString() == row["MaHocSinh"].ToString()) { MessageBoxEx.Show("Học sinh " + row["HoTen"].ToString() + " hiện đang học trong lớp " + row["TenLop"].ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); state = true; goto Cont; } } newitem.SubItems.Add(olditem.SubItems[1].Text); newitem.Tag = olditem.Tag; if (lVLopMoi.Items.Count >= siSoToiDa) { MsgboxUtil.Error("Không thể thực hiện vì lớp " + cmbLopMoi.Text + " (" + lVLopMoi.Items.Count + " hs) đã đủ sỉ số học sinh quy định (" + siSoToiDa + " hs/Lớp)!"); return; } else { lVLopMoi.Items.Add(newitem); } lVLopMoi.Items[lVLopMoi.Items.IndexOf(newitem)].Text = olditem.SubItems[0].Text; lVLopCu.Items.Remove(olditem); Cont: if (state == true) { break; } } }