private DataTable backupDisplayTable; //显示表用于显示的datatable的备份

        public ManualRollCall(Briefcase _classBriefcase, long _jieci, DataTable dmTable, DateTime RollcallTime)
        {
            InitializeComponent();
            ///////////////////////////////////////
            this.classBriefcase = _classBriefcase; //本门课的briefcase(通过该窗口的构造函数传进来)

            this.jieci = _jieci;                   //节次编号

            _dmTable = dmTable;

            _rollCallTime = RollcallTime;
            //以上语句在为成员赋值 不要管啦////////////////////
            Briefcase propertieBriefcase =
                new FileBriefcase
                    (Properties.Settings.Default.PropertiesBriefcaseFolder, true); //打开propertiesBriefcase,用于获取班级表

            bjTable = propertieBriefcase.FindTable("ClassNameTable");              //班级表

            xkTable = classBriefcase.FindTable("XKTABLE_VIEW1");                   //拉出选课表 获取学生信息
        }
示例#2
0
        /// <summary>
        /// 下载课程的过程中比较费时的操作都在这个函数里面
        /// </summary>
        /// <param name="kkno">开课编号</param>
        /// <param name="courseBriefcase">该堂课要存的briefcase</param>
        private static void DownloadData(long kkno, Briefcase courseBriefcase)
        {
            Thread.Sleep(1000);//等待进度条窗口建立完毕

            _waitform.Invoke(new MethodInvoker(() => _waitform.SetInfo("下载学生信息 \n 该过程可能会比较耗时")));

            var fDataModule = new DataModule();                     // 再新建一个datamodule..  好浪费资源的说 反正C#会自己做内存回收...

            var xktable = from c in fDataModule.GetxktableViewros() // 将选课表(学生信息)拿出来
                          where c.KKNO == kkno
                          select c;

            _waitform.Invoke(new MethodInvoker(() => _waitform.SetInfo("下载学生信息 \n 该过程会耗时30秒左右")));  // 更改等待窗口的文字

            var xkDatatable = EnumerableExtension.ListToDataTable(xktable.ToList(), "XKTABLE");     // 下载选课表

            _waitform.Invoke(new MethodInvoker(() => _waitform.SetValue(20)));                      // 设置进度条 20

            courseBriefcase.AddTable(xkDatatable);                                                  // 将选课表加到briefcase中

            courseBriefcase.WriteBriefcase();                                                       // 写入硬盘

            var sktable = from c in fDataModule.GetSktable07Viewro() where c.KKNO == kkno select c; // 拉取上课表

            var dmtable = from c in fDataModule.GetdmTable() where c.KKNO == kkno select c;         //拉取选课表

            _waitform.Invoke(new MethodInvoker(() => _waitform.SetInfo("下载课程信息 \n 该过程不会消耗太长时间")));

            _waitform.Invoke(new MethodInvoker(() => _waitform.SetValue(50)));

            var sktableList = sktable.ToList();                                            // 下载上课表

            var skdatatable = EnumerableExtension.ListToDataTable(sktableList, "SKTABLE"); //将上课表转换成datatable

            courseBriefcase.AddTable(skdatatable);                                         // 将datatable写入briefcase中

            courseBriefcase.WriteBriefcase();                                              // 写入硬盘

            _waitform.Invoke(new MethodInvoker(() => _waitform.SetInfo("下载考勤信息 \n 该过程不会消耗太长时间")));

            var dmtableList = dmtable.ToList(); // 下载点名表

            foreach (var sktable07Viewro in sktable)
            {
                var viewro = sktable07Viewro; // resharper说一定要这么写

                var dmtablesinglelist = from c in dmtableList where c.SKNO == viewro.SKNO select c;

                var dmtableSingleDatatable = EnumerableExtension.ListToDataTable(dmtablesinglelist.ToList(),
                                                                                 sktable07Viewro.SKNO.ToString(CultureInfo.InvariantCulture)); // 将list转换成datatable

                courseBriefcase.AddTable(dmtableSingleDatatable);

                _waitform.Invoke(new MethodInvoker(() => _waitform.Increase(1)));    // 每次下载都在进度条上加1
            }

            courseBriefcase.WriteBriefcase(); // 保存将对briefcase的更改写入硬盘

            var classInfoTable = courseBriefcase.FindTable("ClassInfo");

            //以下注释的代码作为参考用.
            //courseInfoTable.Columns.Add ("上课编号", typeof (string));

            //courseInfoTable.Columns.Add ("上课日期", typeof (string));

            //courseInfoTable.Columns.Add ("上课状态", typeof (string));

            foreach (var sktable07Viewro in sktableList)
            {
                var viewro = sktable07Viewro;                                              //resharper说要这么写

                var classInfoRow = classInfoTable.NewRow();                                //新建一行

                classInfoRow["上课编号"] = viewro.SKNO.ToString(CultureInfo.InvariantCulture); //指定这一行的上课编号

                classInfoRow["上课日期"] = viewro.YDSKDATE.ToString();                         //指定这一行的上课日期

                if (viewro.SKZT == 0)                                                      //将上课状态转换成文字

                {
                    classInfoRow["上课状态"] = "未签到";
                }
                else
                {
                    classInfoRow["上课状态"] = "已签到";
                }

                classInfoTable.Rows.Add(classInfoRow);//将这一行加到datatable里
            }

            courseBriefcase.AddTable(classInfoTable);//将datatable加到briefcase里

            courseBriefcase.WriteBriefcase();

            _waitform.Invoke(new MethodInvoker(() => _waitform.Close()));   //关闭进度窗口
        }