public static bool InsertPGDFull_XepLop(PHIEUGHIDANH _phieughidanh, PHIEUTHU _phieuthu, List <HOCPHIHOCVIEN> _lsthphv, BANGDIEM _bangdiem, ref int _PhieuGhiDanhId, ref int _PhieuThuId) { try { // O2S_Common.Logging.LogSystem.Error("Luu log InsertPGDFull"); using (TransactionScope ts = new TransactionScope()) { //Phieu ghi danh _phieughidanh.CoSoId = GlobalSettings.CoSoId; _phieughidanh.CreatedDate = DateTime.Now; _phieughidanh.CreatedBy = GlobalSettings.UserCode; _phieughidanh.CreatedLog = GlobalSettings.SessionMyIP; _phieughidanh.IsRemove = 0; Database.PHIEUGHIDANHs.InsertOnSubmit(_phieughidanh); Database.SubmitChanges(); _PhieuGhiDanhId = _phieughidanh.PhieuGhiDanhId; _phieughidanh.MaPhieuGhiDanh = string.Format("{0}{1:D7}", "PGD", _PhieuGhiDanhId); Database.SubmitChanges(); //insert bang PHIEUTHU if (_phieuthu != null && _phieuthu.HocVienId > 0) { _phieuthu.PhieuGhiDanhId = _PhieuGhiDanhId; _phieuthu.CreatedDate = DateTime.Now; _phieuthu.CreatedBy = GlobalSettings.UserCode; _phieuthu.CreatedLog = GlobalSettings.SessionMyIP; _phieuthu.IsRemove = 0; Database.PHIEUTHUs.InsertOnSubmit(_phieuthu); Database.SubmitChanges(); _PhieuThuId = _phieuthu.PhieuThuId; _phieuthu.MaPhieuThu = string.Format("{0}{1:D7}", "PT", _phieuthu.PhieuThuId); Database.SubmitChanges(); } //Hocphihocvien if (_lsthphv != null && _lsthphv.Count > 0) { foreach (var item in _lsthphv) { item.PhieuGhiDanhId = _PhieuGhiDanhId; item.PhieuThuId = _phieuthu.PhieuThuId; item.CreatedDate = DateTime.Now; item.CreatedBy = GlobalSettings.UserCode; item.CreatedLog = GlobalSettings.SessionMyIP; item.IsRemove = 0; Database.HOCPHIHOCVIENs.InsertOnSubmit(item); Database.SubmitChanges(); } } //insert BANGDIEM if (_bangdiem.LopHocId != 0) { _bangdiem.PhieuGhiDanhId = _PhieuGhiDanhId; _bangdiem.CreatedDate = DateTime.Now; _bangdiem.CreatedBy = GlobalSettings.UserCode; _bangdiem.CreatedLog = GlobalSettings.SessionMyIP; _bangdiem.IsRemove = 0; Database.BANGDIEMs.InsertOnSubmit(_bangdiem); Database.SubmitChanges(); int _id = _bangdiem.BangDiemId; //Insert Bang diem chi tiet List <KHOAHOC_MONHOC> _khmh = KhoaHocMonHocLogic.SelectTheoKhoaHoc(_bangdiem.KhoaHocId); foreach (var item in _khmh) { BANGDIEMCHITIET _chitiet = new BANGDIEMCHITIET(); _chitiet.BangDiemId = _id; _chitiet.MonHocId = item.MonHocId ?? 0; _chitiet.TenMonHoc = item.TenMonHoc; _chitiet.IsRemove = 0; //_chitiet.CreatedDate = DateTime.Now; //_chitiet.CreatedBy = GlobalSettings.UserCode; //_chitiet.CreatedLog = GlobalSettings.SessionMyIP; Database.BANGDIEMCHITIETs.InsertOnSubmit(_chitiet); Database.SubmitChanges(); } //Update SiSo cua LOPHOC LOPHOC _lophoc = LopHocLogic.SelectSingle(_bangdiem.LopHocId); LopHocLogic.Update(new LOPHOC() { //LopHocId = _lophoc.LopHocId, //TenLopHoc = _lophoc.TenLopHoc, //NgayBatDau = _lophoc.NgayBatDau, //NgayKetThuc = _lophoc.NgayKetThuc, //SiSoToiDa = _lophoc.SiSoToiDa, SiSo = _lophoc.SiSo + 1, //KhoaHocId = _lophoc.KhoaHocId, //IsLock = _lophoc.IsLock }); } //Update HOCVIEN = Hoc vien chinh thuc HOCVIEN _hocvien = HocVienLogic.SelectSingle(_phieughidanh.HocVienId ?? 0); _hocvien.LOAIHOCVIEN = LoaiHocVienLogic.Select(KeySetting.LOAIHOCVIEN_CHINHTHUC); //Database.SubmitChanges(); //Update TAIKHOAN = được sử dụng TAIKHOAN _taikhoan = TaiKhoanLogic.SelectTheoTenDangNhap(_hocvien.MaHocVien); _taikhoan.IsRemove = 0; Database.SubmitChanges(); ts.Complete(); return(true); } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); return(false); } }
public static bool XoaPhieuGhiDanh(PHIEUGHIDANH _phieuGD) { try { using (TransactionScope ts = new TransactionScope()) { //xoa HOCPHIHOCVIEN List <HOCPHIHOCVIEN> _lstHPHV = HocPhiHocVienLogic.SelectTheoPhieuGhiDanh(_phieuGD.PhieuGhiDanhId); if (_lstHPHV != null && _lstHPHV.Count > 0) { Database.HOCPHIHOCVIENs.DeleteAllOnSubmit(_lstHPHV); //Database.SubmitChanges(); } //Xoa bang PHIEUTHU; List <PHIEUTHU> _lstPhieuThu = PhieuThuLogic.SelectTheoPhieuGhiDanh(_phieuGD.PhieuGhiDanhId); if (_lstPhieuThu != null && _lstPhieuThu.Count > 0) { Database.PHIEUTHUs.DeleteAllOnSubmit(_lstPhieuThu); // Database.SubmitChanges(); } //update=Xoa bang PHIEUGHIDANH //PHIEUGHIDANH _phieuGDUpdate = SelectSingle(_phieuGD.PhieuGhiDanhId); _phieuGD.IsRemove = _phieuGD.IsRemove; _phieuGD.LyDoXoa = _phieuGD.LyDoXoa; _phieuGD.NguoiXoa = _phieuGD.NguoiXoa; _phieuGD.ModifiedDate = DateTime.Now; _phieuGD.ModifiedBy = GlobalSettings.UserCode; _phieuGD.ModifiedLog = GlobalSettings.SessionMyIP; //Database.SubmitChanges(); //cap nhat bang HOCVIEN va bang tai khoan: kiem tra HV hoc khoa nao ko? neu=1 thi update PhieuGhiDanhFilter _filter = new PhieuGhiDanhFilter(); _filter.HocVienId = _phieuGD.HocVienId; List <PhieuGhiDanh_PlusDTO> _PGD_Kiemtra = PhieuGhiDanhLogic.Select(_filter); if (_PGD_Kiemtra == null || _PGD_Kiemtra.Count <= 1) { HOCVIEN _hocvien = HocVienLogic.SelectSingle(_phieuGD.HocVienId ?? 0); _hocvien.LOAIHOCVIEN = LoaiHocVienLogic.Select(KeySetting.LOAIHOCVIEN_TIEMNANG); Database.SubmitChanges(); TAIKHOAN _taikhoan = TaiKhoanLogic.SelectTheoTenDangNhap(_hocvien.TAIKHOAN.TenDangNhap); _taikhoan.IsRemove = 1; //Database.SubmitChanges(); } //Kiem tra lop hoc va xoa bang diem List <BANGDIEM> _bangdiem = BangDiemLogic.SelectTheoPhieuGhiDanh(_phieuGD.PhieuGhiDanhId); if (_bangdiem != null && _bangdiem.Count > 0) { Database.BANGDIEMs.DeleteAllOnSubmit(_bangdiem); //Update So luong hoc vien trong lop hoc... LOPHOC _lopHoc = LopHocLogic.SelectSingle(_phieuGD.LopHocId ?? 0); if (_lopHoc != null) { _lopHoc.SiSo = (from p in Database.BANGDIEMs where p.LopHocId == (_phieuGD.LopHocId ?? 0) && p.IsRemove != 1 select p).Count(); _lopHoc.ModifiedDate = DateTime.Now; _lopHoc.ModifiedBy = GlobalSettings.UserCode; _lopHoc.ModifiedLog = GlobalSettings.SessionMyIP; Database.SubmitChanges(); } } Database.SubmitChanges(); ts.Complete(); return(true); } } catch (System.Exception ex) { return(false); O2S_Common.Logging.LogSystem.Error(ex); } }
public static bool InsertPGDFull(PHIEUGHIDANH _phieughidanh, PHIEUTHU _phieuthu, List <HOCPHIHOCVIEN> _lsthphv, ref int _PhieuGhiDanhId, ref int _PhieuThuId) { try { // O2S_Common.Logging.LogSystem.Error("Luu log InsertPGDFull"); using (TransactionScope ts = new TransactionScope()) { //Phieu ghi danh _phieughidanh.CoSoId = GlobalSettings.CoSoId; _phieughidanh.CreatedDate = DateTime.Now; _phieughidanh.CreatedBy = GlobalSettings.UserCode; _phieughidanh.CreatedLog = GlobalSettings.SessionMyIP; _phieughidanh.IsRemove = 0; Database.PHIEUGHIDANHs.InsertOnSubmit(_phieughidanh); Database.SubmitChanges(); _PhieuGhiDanhId = _phieughidanh.PhieuGhiDanhId; _phieughidanh.MaPhieuGhiDanh = string.Format("{0}{1:D7}", "PGD", _PhieuGhiDanhId); Database.SubmitChanges(); //insert bang PHIEUTHU if (_phieuthu != null && _phieuthu.HocVienId > 0) { _phieuthu.PhieuGhiDanhId = _PhieuGhiDanhId; _phieuthu.CreatedDate = DateTime.Now; _phieuthu.CreatedBy = GlobalSettings.UserCode; _phieuthu.CreatedLog = GlobalSettings.SessionMyIP; _phieuthu.IsRemove = 0; Database.PHIEUTHUs.InsertOnSubmit(_phieuthu); Database.SubmitChanges(); _PhieuThuId = _phieuthu.PhieuThuId; _phieuthu.MaPhieuThu = string.Format("{0}{1:D7}", "PT", _phieuthu.PhieuThuId); Database.SubmitChanges(); } //Hocphihocvien if (_lsthphv != null && _lsthphv.Count > 0) { foreach (var item in _lsthphv) { item.PhieuGhiDanhId = _PhieuGhiDanhId; item.PhieuThuId = _phieuthu.PhieuThuId; item.CreatedDate = DateTime.Now; item.CreatedBy = GlobalSettings.UserCode; item.CreatedLog = GlobalSettings.SessionMyIP; item.IsRemove = 0; Database.HOCPHIHOCVIENs.InsertOnSubmit(item); Database.SubmitChanges(); } } //Update HOCVIEN = Hoc vien chinh thuc HOCVIEN _hocvien = HocVienLogic.SelectSingle(_phieughidanh.HocVienId ?? 0); _hocvien.LOAIHOCVIEN = LoaiHocVienLogic.Select(KeySetting.LOAIHOCVIEN_CHINHTHUC); //Database.SubmitChanges(); //Update TAIKHOAN = được sử dụng TAIKHOAN _taikhoan = TaiKhoanLogic.SelectTheoTenDangNhap(_hocvien.MaHocVien); _taikhoan.IsRemove = 0; Database.SubmitChanges(); ts.Complete(); return(true); } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); return(false); } }