Ejemplo n.º 1
0
        /// <summary>
        /// 获取propertiesBriefcase,其中包含该 1.该平板中所有的课程 2.班级表
        /// 第一次在哪下载的课程 就得在哪里用.学院之间不能混用.
        /// 若briefcase不存在 则创建一个briefcase
        /// </summary>
        /// <returns></returns>
        public static FileBriefcase InitPropertiesBriefcase(long collageNo)
        {
            if (File.Exists(GlobalParams.BriefcasePath + @"Properties.daBriefcase"))   //does properties briefcase exists?

            {
                var propertiesBriefcase = new  FileBriefcase(GlobalParams.BriefcasePath + @"Properties.daBriefcase", true); //if yes ,return that briefcase(侯晨琛非要让我用英语注释)

                var fDataModule = new DataModule();                                                                         //新建briefcase的时候要下载班级表咯

                var bjTable = from c in fDataModule.GetBjTable()                                                            //获取数据
                              where c.XYID == collageNo
                              select c;

                var bjDataTable = EnumerableExtension.ListToDataTable(bjTable.ToList(), "BJTABLE"); //将班级表转换成datatable

                propertiesBriefcase.AddTable(bjDataTable);                                          //将班级表添加到briefcase中

                propertiesBriefcase.WriteBriefcase();

                return(propertiesBriefcase);//返回该briefcase
            }
            else
            {
                var propertiesBriefcase = new FileBriefcase(GlobalParams.BriefcasePath + @"Properties.daBriefcase"); //如果没有的话 那就新建一个briefcase

                var courseInfoTable = new DataTable("CourseInfo");                                                   //

                courseInfoTable.Columns.Add("课程名称", typeof(string));

                courseInfoTable.Columns.Add("课程编号", typeof(string));

                propertiesBriefcase.AddTable(courseInfoTable);   //新建一张表 表中存的是该平板中所有课程的信息 但表是空的.

                var fDataModule = new DataModule();              //新建briefcase的时候要下载班级表咯

                var bjTable = from c in fDataModule.GetBjTable() //获取班级表数据
                              where c.XYID == collageNo
                              select c;

                var bjDataTable = EnumerableExtension.ListToDataTable(bjTable.ToList(), "BJTABLE"); //将班级表转换成datatable

                propertiesBriefcase.AddTable(bjDataTable);                                          //将班级表添加到briefcase中

                propertiesBriefcase.WriteBriefcase();

                return(propertiesBriefcase);//返回该briefcase
            }
        }