Beispiel #1
0
        public static bool Delete(int _khoahocId)
        {
            try
            {
                //Xoa Khoa học_mon hoc truoc
                var _khoahocMonHoc = KhoaHocMonHocLogic.SelectTheoKhoaHoc(_khoahocId);
                if (_khoahocMonHoc != null && _khoahocMonHoc.Count > 0)
                {
                    Database.KHOAHOC_MONHOCs.DeleteAllOnSubmit(_khoahocMonHoc);
                }
                //xoa lop hoc
                var _lophoc = LopHocLogic.SelectTheoKhoaHoc(_khoahocId);
                if (_lophoc != null && _lophoc.Count > 0)
                {
                    Database.LOPHOCs.DeleteAllOnSubmit(_lophoc);
                }
                //xoa khoa hoc
                var temp = SelectSingle(_khoahocId);
                Database.KHOAHOCs.DeleteOnSubmit(temp);
                Database.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        public static void Insert(BANGDIEM _bangdiem)
        {
            try
            {
                _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();
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        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);
            }
        }