private void btnLuu_Click(object sender, EventArgs e) { //luu hoat dong if (txtTenHoatDong.Text != "" && txtChiPhi.Text != "") { HoatDongNgoaiKhoa hoatDong = new HoatDongNgoaiKhoa(); hoatDong.MaHoatDong = txtMaHoatDong.Text; hoatDong.TenHoatDong = txtTenHoatDong.Text; hoatDong.NgayBatDau = dtNgayBatDau.Value; hoatDong.NgayKetThuc = dtNgayKetThuc.Value; hoatDong.KeHoach = txtKeHoach.Text; hoatDong.ChiPhi = decimal.Parse(txtChiPhi.Text); if (HoatDongNgoaiKhoaBLL.LuuHoatDong(hoatDong)) { MessageBox.Show("Đã lưu hoạt động thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDataGridView(); txtMaHoatDong.Clear(); txtTenHoatDong.Clear(); txtChiPhi.Clear(); txtKeHoach.Clear(); dtNgayBatDau.Value = DateTime.Today; dtNgayKetThuc.Value = DateTime.Today; } } else { MessageBox.Show("Phải điền đầy đủ tất cả các trường thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnXoa_Click(object sender, EventArgs e) { if (dgvListHoatDong.SelectedRows.Count > 0) { HoatDongNgoaiKhoa hoatDong = new HoatDongNgoaiKhoa(); hoatDong.MaHoatDong = dgvListHoatDong.SelectedRows[0].Cells["MaHoatDong"].Value.ToString(); hoatDong.TenHoatDong = dgvListHoatDong.SelectedRows[0].Cells["TenHoatDong"].Value.ToString(); hoatDong.NgayBatDau = DateTime.Parse(dgvListHoatDong.SelectedRows[0].Cells["NgayBatDau"].Value.ToString()); hoatDong.NgayKetThuc = DateTime.Parse(dgvListHoatDong.SelectedRows[0].Cells["NgayKetThuc"].Value.ToString()); hoatDong.KeHoach = dgvListHoatDong.SelectedRows[0].Cells["KeHoach"].Value.ToString(); hoatDong.ChiPhi = decimal.Parse(dgvListHoatDong.SelectedRows[0].Cells["ChiPhi"].Value.ToString()); DialogResult result = MessageBox.Show("Bạn có muốn xóa hoat động " + hoatDong.TenHoatDong + " với mã là: " + hoatDong.MaHoatDong + " không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (HoatDongNgoaiKhoaBLL.XoaHoatDong(hoatDong)) { MessageBox.Show("Đã xóa hoạt động thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDataGridView(); txtMaHoatDong.Clear(); txtTenHoatDong.Clear(); txtChiPhi.Clear(); txtKeHoach.Clear(); dtNgayBatDau.Value = DateTime.Today; dtNgayKetThuc.Value = DateTime.Today; } } } else { MessageBox.Show("Bạn phải chọn một hoạt động để xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static bool CapNhatLopThamGia(Dictionary <string, bool> listLop, string maHD) { HoatDongNgoaiKhoa hoatDong = HoatDongNgoaiKhoaDAL.GetHoatDong(maHD); if (DateTime.Today > hoatDong.NgayBatDau) { MessageBox.Show("Hoạt động này đã diễn ra, không được thay đổi thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { foreach (string key in listLop.Keys) { if (listLop[key]) { if (!HoatDongNgoaiKhoaDAL.CheckExistsLopThamGia(maHD, key)) { //lop nay chua tham gia => tao moi ThemLopThamGia(maHD, key); } } else { if (HoatDongNgoaiKhoaDAL.CheckExistsLopThamGia(maHD, key)) { //lop nay da tham gia, xoa lop nay trong danh sach lop tham gia hoat dong XoaLopThamGia(maHD, key); } } } return(true); } }
public HoatDongNgoaiKhoa GetHoatDongNgoaiKhoaById(int id) { using (var _db = new HoatDongTraiNghiemDB()) { HoatDongNgoaiKhoa hoatDongNgoaiKhoa = _db.HoatDongNgoaiKhoas.Include("JobTitle").Include("Province").Where(s => s.Id == id).SingleOrDefault(); return(hoatDongNgoaiKhoa); } }
public HoatDongNgoaiKhoa CreateHoatDongNgoaiKhoa(HoatDongNgoaiKhoa hoatDongNgoaiKhoa) { using (var _db = new HoatDongTraiNghiemDB()) { _db.HoatDongNgoaiKhoas.Add(hoatDongNgoaiKhoa); _db.SaveChanges(); return(hoatDongNgoaiKhoa); } }
public HoatDongNgoaiKhoa UpdateHoatDongNgoaiKhoa(HoatDongNgoaiKhoa hoatDongNgoaiKhoa) { using (var _db = new HoatDongTraiNghiemDB()) { _db.Entry(hoatDongNgoaiKhoa).State = EntityState.Modified; _db.SaveChanges(); return(hoatDongNgoaiKhoa); } }
public bool CheckExistedFileDanhSachPhanXeVaGV(string fileName) { using (var _db = new HoatDongTraiNghiemDB()) { HoatDongNgoaiKhoa hoatDongNgoaiKhoa = _db.HoatDongNgoaiKhoas.Where(s => s.FileDanhSachPhanXeVaGV == fileName).SingleOrDefault(); if (hoatDongNgoaiKhoa == null) { return(false); } return(true); } }
public bool CheckExistedFileHDKKPhoiHopToChuc(string fileName) { using (var _db = new HoatDongTraiNghiemDB()) { HoatDongNgoaiKhoa hoatDongNgoaiKhoa = _db.HoatDongNgoaiKhoas.Where(s => s.FileHDKKPhoiHopToChuc == fileName).SingleOrDefault(); if (hoatDongNgoaiKhoa == null) { return(false); } return(true); } }
public bool CheckExistedFilePhuongAnChiTietAnToan(string fileName) { using (var _db = new HoatDongTraiNghiemDB()) { HoatDongNgoaiKhoa hoatDongNgoaiKhoa = _db.HoatDongNgoaiKhoas.Where(s => s.FilePhuongAnChiTietAnToan == fileName).SingleOrDefault(); if (hoatDongNgoaiKhoa == null) { return(false); } return(true); } }
public static void XoaHoatDong(HoatDongNgoaiKhoa hoatDong) { DataAccessHelper db = new DataAccessHelper(); SqlCommand cmd = db.Command("XoaHoatDong"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MaHoatDong", hoatDong.MaHoatDong); SqlDataAdapter da = new SqlDataAdapter(cmd); db.dt = new DataTable(); da.Fill(db.dt); }
public static bool CapNhatDiemHoatDong(string maHD, string maTre, float diem, string nhanXet) { HoatDongNgoaiKhoa hoatDong = HoatDongNgoaiKhoaDAL.GetHoatDong(maHD); if (DateTime.Today < hoatDong.NgayKetThuc) { MessageBox.Show("Chỉ được nhập điểm sau khi kết thúc hoạt động ngoại khóa này", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { HoatDongNgoaiKhoaDAL.CapNhatDiemHoatDong(maHD, maTre, diem, nhanXet); return(true); } }
public static bool XoaHoatDong(HoatDongNgoaiKhoa hoatDong) { if (DateTime.Today > hoatDong.NgayBatDau) { MessageBox.Show("Chỉ được xóa hoạt động chưa diễn ra.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { string[] listLop = GetListLopThamGia(hoatDong.MaHoatDong); foreach (string maLop in listLop) { XoaLopThamGia(hoatDong.MaHoatDong, maLop); } HoatDongNgoaiKhoaDAL.XoaHoatDong(hoatDong); return(true); } }
public static bool CapNhatTreThamGiaHoatDong(Dictionary <string, bool> listTre, string maHD) { HoatDongNgoaiKhoa hoatDong = HoatDongNgoaiKhoaDAL.GetHoatDong(maHD); if (DateTime.Today > hoatDong.NgayBatDau) { MessageBox.Show("Hoạt động này đã diễn ra, không được thay đổi thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { foreach (string key in listTre.Keys) { HoatDongNgoaiKhoaDAL.CapNhatTreThamGiaHoatDong(maHD, key, listTre[key] ? 1 : 0); } return(true); } }
public static void CapNhatHoatDong(HoatDongNgoaiKhoa hoatDong) { DataAccessHelper db = new DataAccessHelper(); SqlCommand cmd = db.Command("CapNhatHoatDong"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MaHoatDong", hoatDong.MaHoatDong); cmd.Parameters.AddWithValue("@TenHoatDong", hoatDong.TenHoatDong); cmd.Parameters.AddWithValue("@KeHoach", hoatDong.KeHoach); cmd.Parameters.AddWithValue("@ChiPhi", hoatDong.ChiPhi); cmd.Parameters.AddWithValue("@NgayBatDau", hoatDong.NgayBatDau); cmd.Parameters.AddWithValue("@NgayKetThuc", hoatDong.NgayKetThuc); SqlDataAdapter da = new SqlDataAdapter(cmd); db.dt = new DataTable(); da.Fill(db.dt); }
public static bool LuuHoatDong(HoatDongNgoaiKhoa hoatDong) { if (hoatDong.NgayKetThuc < hoatDong.NgayBatDau) { MessageBox.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.Error); return(false); } else { if (HoatDongNgoaiKhoaDAL.CheckExistsHoatDong(hoatDong.MaHoatDong)) { //da ton tai //update cho hoat dong if (DateTime.Today > hoatDong.NgayBatDau) { MessageBox.Show("Hoạt động này đã diễn ra, không được thay đổi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { HoatDongNgoaiKhoaDAL.CapNhatHoatDong(hoatDong); return(true); } } else { //chua ton tai //tao moi hoat dong if (DateTime.Today > hoatDong.NgayBatDau) { MessageBox.Show("Ngày bắt đầu phải lớn hơn ngày hôm nay", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { HoatDongNgoaiKhoaDAL.ThemHoatDong(hoatDong); return(true); } } } }
public ActionResult Create(HoatDongNgoaiKhoaDTO hoatDongNgoaiKhoaDTO) { if (!ModelState.IsValid) { return(Json(new ReturnFormat(400, "failed", null), JsonRequestBehavior.AllowGet)); } var school = (T_DM_Truong)Session[Constant.SCHOOL_SESSION]; if (school == null) { return(Json(new ReturnFormat(400, "failed", null), JsonRequestBehavior.AllowGet)); } using (var ngoaiKhoa = new HoatDongNgoaiKhoaService()) { HoatDongNgoaiKhoa registration = ngoaiKhoa.GetHoatDongNgoaiKhoaById(hoatDongNgoaiKhoaDTO.Id); Mapper.Map(hoatDongNgoaiKhoaDTO, registration); registration.SchoolName = school.TenTruong; registration.CreatedAt = DateTime.Now; registration.SchoolId = school.SchoolID; var inserted = ngoaiKhoa.UpdateHoatDongNgoaiKhoa(registration); return(Json(new ReturnFormat(200, "success", null), JsonRequestBehavior.AllowGet)); } }
public ActionResult PostFile(HttpPostedFileBase FileKeHoachToChuc, HttpPostedFileBase FilePhuongAnChiTietAnToan, HttpPostedFileBase FileQDThanhLapBanToChuc, HttpPostedFileBase FileHDKKPhoiHopToChuc, HttpPostedFileBase FileLichTrinhHoatDong, HttpPostedFileBase FileBaoHiemChuyenDi, HttpPostedFileBase FileNoiQuyChuyenDi, HttpPostedFileBase FileThuBaoChoChaMe, HttpPostedFileBase FileDanhSachPhanXeVaGV ) { var school = (T_DM_Truong)Session[Constant.SCHOOL_SESSION]; if (school == null) { return(Json(new ReturnFormat(400, "failed", null), JsonRequestBehavior.AllowGet)); } try { if (FileKeHoachToChuc.ContentLength > 0) { using (var social = new HoatDongNgoaiKhoaService()) { string _FileKeHoachToChuc = Path.GetFileName(FileKeHoachToChuc.FileName); string _FilePhuongAnChiTietAnToan = Path.GetFileName(FilePhuongAnChiTietAnToan.FileName); string _FileQDThanhLapBanToChuc = Path.GetFileName(FileQDThanhLapBanToChuc.FileName); string _FileHDKKPhoiHopToChuc = Path.GetFileName(FileHDKKPhoiHopToChuc.FileName); string _FileLichTrinhHoatDong = Path.GetFileName(FileLichTrinhHoatDong.FileName); string _FileBaoHiemChuyenDi = Path.GetFileName(FileBaoHiemChuyenDi.FileName); string _FileNoiQuyChuyenDi = Path.GetFileName(FileNoiQuyChuyenDi.FileName); string _FileThuBaoChoChaMe = Path.GetFileName(FileThuBaoChoChaMe.FileName); string _FileDanhSachPhanXeVaGV = Path.GetFileName(FileDanhSachPhanXeVaGV.FileName); bool CheckExistedFileBaoHiemChuyenDi = social.CheckExistedFileBaoHiemChuyenDi(_FileBaoHiemChuyenDi); bool CheckExistedFileDanhSachPhanXeVaGV = social.CheckExistedFileDanhSachPhanXeVaGV(_FileDanhSachPhanXeVaGV); bool CheckExistedFileHDKKPhoiHopToChuc = social.CheckExistedFileHDKKPhoiHopToChuc(_FileHDKKPhoiHopToChuc); bool CheckExistedFileKeHoachToChuc = social.CheckExistedFileKeHoachToChuc(_FileKeHoachToChuc); bool CheckExistedFileLichTrinhHoatDong = social.CheckExistedFileLichTrinhHoatDong(_FileLichTrinhHoatDong); bool CheckExistedFileNoiQuyChuyenDi = social.CheckExistedFileNoiQuyChuyenDi(_FileNoiQuyChuyenDi); bool CheckExistedFilePhuongAnChiTietAnToan = social.CheckExistedFilePhuongAnChiTietAnToan(_FilePhuongAnChiTietAnToan); bool CheckExistedFileQDThanhLapBanToChuc = social.CheckExistedFileQDThanhLapBanToChuc(_FileQDThanhLapBanToChuc); bool CheckExistedFileThuBaoChoChaMe = social.CheckExistedFileThuBaoChoChaMe(_FileThuBaoChoChaMe); bool existed = false; string errorText = "Tên file: "; if (CheckExistedFileBaoHiemChuyenDi == true) { existed = true; errorText += "Bảo hiểm chuyến đi cho ban tổ chức và học sinh,"; } if (CheckExistedFileDanhSachPhanXeVaGV == true) { existed = true; errorText += "Danh sách phân xe và giáo viên phụ trách,"; } if (CheckExistedFileHDKKPhoiHopToChuc == true) { existed = true; errorText += "Hợp đồng ký kết với đơn vị phối hợp tổ chức,"; } if (CheckExistedFileKeHoachToChuc == true) { existed = true; errorText += "Kế hoạch tổ chức hoạt động"; } if (CheckExistedFileLichTrinhHoatDong == true) { existed = true; errorText += "Lịch trình hoạt động ngoài giờ chính khóa,"; } if (CheckExistedFileNoiQuyChuyenDi == true) { existed = true; errorText += "Nội quy chuyến đi,"; } if (CheckExistedFilePhuongAnChiTietAnToan == true) { existed = true; errorText += "tài liệu cho học sinh,"; } if (CheckExistedFileQDThanhLapBanToChuc == true) { existed = true; errorText += "Quyết định thành lập Ban tổ chức,"; } if (CheckExistedFileThuBaoChoChaMe == true) { existed = true; errorText += "Mẫu thư báo cho cha mẹ học sinh,"; } if (existed == true) { errorText.Remove(errorText.Length - 1); errorText += " đã tồn tại. Vui lòng đặt tên khác"; return(Json(new ReturnFormat(409, errorText, null), JsonRequestBehavior.AllowGet)); } string _path2 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FileBaoHiemChuyenDi"), _FileBaoHiemChuyenDi); string _path3 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FileDanhSachPhanXeVaGV"), _FileDanhSachPhanXeVaGV); string _path4 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FileHDKKPhoiHopToChuc"), _FileHDKKPhoiHopToChuc); string _path5 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FileKeHoachToChuc"), _FileKeHoachToChuc); string _path6 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FileLichTrinhHoatDong"), _FileLichTrinhHoatDong); string _path7 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FileNoiQuyChuyenDi"), _FileNoiQuyChuyenDi); string _path8 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FilePhuongAnChiTietAnToan"), _FilePhuongAnChiTietAnToan); string _path9 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FileQDThanhLapBanToChuc"), _FileQDThanhLapBanToChuc); string _path10 = Path.Combine(Server.MapPath("~/UploadedFiles/HoatDongNgoaiKhoa/FileThuBaoChoChaMe"), _FileThuBaoChoChaMe); FileBaoHiemChuyenDi.SaveAs(_path2); FileDanhSachPhanXeVaGV.SaveAs(_path3); FileHDKKPhoiHopToChuc.SaveAs(_path4); FileKeHoachToChuc.SaveAs(_path5); FileLichTrinhHoatDong.SaveAs(_path6); FileNoiQuyChuyenDi.SaveAs(_path7); FilePhuongAnChiTietAnToan.SaveAs(_path8); FileQDThanhLapBanToChuc.SaveAs(_path9); FileThuBaoChoChaMe.SaveAs(_path10); HoatDongNgoaiKhoa registration = new HoatDongNgoaiKhoa(); registration.FileBaoHiemChuyenDi = _FileBaoHiemChuyenDi; registration.FileDanhSachPhanXeVaGV = _FileDanhSachPhanXeVaGV; registration.FileHDKKPhoiHopToChuc = _FileHDKKPhoiHopToChuc; registration.FileKeHoachToChuc = _FileKeHoachToChuc; registration.FileLichTrinhHoatDong = _FileLichTrinhHoatDong; registration.FileNoiQuyChuyenDi = _FileNoiQuyChuyenDi; registration.FilePhuongAnChiTietAnToan = _FilePhuongAnChiTietAnToan; registration.FileQDThanhLapBanToChuc = _FileQDThanhLapBanToChuc; registration.FileThuBaoChoChaMe = _FileThuBaoChoChaMe; var inserted = social.CreateHoatDongNgoaiKhoa(registration); return(Json(new ReturnFormat(200, "success", inserted.Id), JsonRequestBehavior.AllowGet)); } } else { return(Json(new ReturnFormat(400, "failed", null), JsonRequestBehavior.AllowGet)); } } catch { return(Json(new ReturnFormat(400, "failed", null), JsonRequestBehavior.AllowGet)); } }
public static string GetTenHoatDong(string maHD) { HoatDongNgoaiKhoa hoatDong = HoatDongNgoaiKhoaDAL.GetHoatDong(maHD); return(hoatDong.TenHoatDong); }