Ejemplo n.º 1
0
        private void LoadLesson()
        {
            foreach (OleDbDataReader reader in ThisModule.OleDB.EachRows(
                         "select Id, FSquadGroup, FCourse, FIsSelfStudy, FSharedTime "
                         + " from TLesson"))
            {
                EnLesson Lsn = new EnLesson();
                Lsn.Id          = Convert.ToInt64(reader[0]);
                Lsn.SquadGroup  = ThisModule.Sqd.GrpDAC.Get(Convert.ToInt64(reader[1]));
                Lsn.Course      = ThisModule.Crs.MbrDAC.Get(Convert.ToInt64(reader[2]));
                Lsn.IsSelfStudy = Convert.ToBoolean(reader[3]);
                Lsn.SharedTime  = Convert.ToInt32(reader[4]);

                if (Lsn.SquadGroup == null)
                {
                    ThisModule.ErrorLog.Error("VcLesson恢复错误:ID对应的实体不存在  "
                                              + "  SquadGroup: " + reader[1]);
                    continue;
                }

                if (Lsn.Course == null)
                {
                    ThisModule.ErrorLog.Error("VcLesson恢复错误:ID对应的实体不存在  "
                                              + "  Course: " + reader[2]);
                    continue;
                }

                LsnContainer LsnCnt = new LsnContainer();
                LsnCnt.Lsn = Lsn;
                Lsns.Add(LsnCnt.Lsn.Id, LsnCnt);
            }
        }
Ejemplo n.º 2
0
        public EnLesson SaveLesson(EnLesson Value)
        {
            foreach (LsnContainer LsnCnt in Lsns.Values)
            {
                if (LsnCnt.Lsn.SquadGroup == Value.SquadGroup &&
                    LsnCnt.Lsn.Course == Value.Course)
                {
                    LsnCnt.Lsn.SharedTime  = Value.SharedTime;
                    LsnCnt.Lsn.IsSelfStudy = Value.IsSelfStudy;

                    ThisModule.OleDB.ExecuteNonQuery("update TLesson set "
                                                     + " FSharedTime = " + Value.SharedTime
                                                     + ", FIsSelfStudy = " + (Value.IsSelfStudy ? "True" : "False")
                                                     + " where Id = " + LsnCnt.Lsn.Id);

                    return(LsnCnt.Lsn);
                }
            }

            LsnContainer lc = new LsnContainer();

            lc.Lsn             = new EnLesson();
            lc.Lsn.SharedTime  = Value.SharedTime;
            lc.Lsn.IsSelfStudy = Value.IsSelfStudy;
            lc.Lsn.SquadGroup  = Value.SquadGroup;
            lc.Lsn.Course      = Value.Course;
            lc.Lsn.Id          = Convert.ToInt64(ThisModule.OleDB.InsertAndReturnId_MS("insert into TLesson"
                                                                                       + " (FSquadGroup, FCourse, FIsSelfStudy, FSharedTime) values ("
                                                                                       + Value.SquadGroup.Id
                                                                                       + ", " + Value.Course.Id
                                                                                       + ", " + (Value.IsSelfStudy ? "True" : "False")
                                                                                       + ", " + Value.SharedTime
                                                                                       + ")"));
            Lsns.Add(lc.Lsn.Id, lc);

            return(lc.Lsn);
        }
Ejemplo n.º 3
0
        public void DeleteLesson(EnLesson Lesson)
        {
            LsnContainer LsnCnt = Lsns[Lesson.Id];
            String       SWhere = "";

            foreach (EnClsLesson ClsLsn in LsnCnt.ClsLessons)
            {
                if (!String.IsNullOrEmpty(SWhere))
                {
                    SWhere = SWhere + " or ";
                }
                SWhere = SWhere + "FClsLesson = " + ClsLsn.Id;

                ClsLsns.Remove(ClsLsn.Id);
            }

            Lsns.Remove(Lesson.Id);
            if (!String.IsNullOrEmpty(SWhere))
            {
                ThisModule.OleDB.ExecuteNonQuery("delete from TLsnAct where " + SWhere);
            }
            ThisModule.OleDB.ExecuteNonQuery("delete from TClsLesson where FLesson = " + Lesson.Id);
            ThisModule.OleDB.ExecuteNonQuery("delete from TLesson where Id = " + Lesson.Id);
        }