Example #1
0
        /// <summary>
        /// 下载一门课程 包括显示进度条等界面操作
        /// </summary>
        /// <param name="kkno"></param>
        ///
        public static void DownloadOneCourse(long kkno)
        {
            var fDataModule = new DataModule();                        //新建一个datamodule

            var jsandkkview = from c in fDataModule.GetJsandkkviewro() //传进来kkno 将对应课程的信息拉出来
                              where c.KKNO == kkno
                              select c;

            var kkrecord = jsandkkview.First();                               //取第一条记录

            var courseBriefcase = BriefcaseControl.CreateBriefcase(kkrecord); //根据开课表的一行记录建立briefcase

            if (courseBriefcase == null)
            {
                return;
            }

            _waitform = new WaitForm("初始化下载进程");

            new Thread(() => DownloadData(kkno, courseBriefcase)).Start();    //将费时的操作放在一个线程中



            _waitform.ShowDialog();

            MsgBox.ShowMsgBoxDialog("选定的课程下载完毕.");
        }
Example #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public ShowServerClassesForm( )
        {
            InitializeComponent();

            _fDataModule = new DataModule();  // 实例化 datamodule

            var jsandkkviewros = from c in _fDataModule.GetJsandkkviewro()
                                 where c.JSID == Convert.ToInt64(Properties.Settings.Default.UserId)
                                 select c;            // 建立教师ID Linq表达式

            _jsandkkviewro = jsandkkviewros.ToList(); //将拉取到的数据转换成list 里面包含该教师本学期拥有的课程

            var courseListDictionary = _jsandkkviewro.ToDictionary(jsandkkviewro => jsandkkviewro.KKNO, jsandkkviewro => jsandkkviewro.KKNAME);

            curriculumListLbox.DataSource = new BindingSource(courseListDictionary, null); //新建一个数据源 并将其绑定在datasource中

            curriculumListLbox.DisplayMember = "Value";                                    //设置显示字段

            curriculumListLbox.ValueMember = "Key";                                        //设置值字段
        }
        /// <summary>
        /// 上传一节课.
        /// </summary>
        /// <param name="kkno">开课编号</param>
        /// <param name="skno">上课编号</param>
        public static void UploadOneClass(long kkno, long skno)
        {
            //todo:这个东西要重写

            //1.根据KKNo找到本地的Briefcase. 因为之前都查过了 所以这里就不用做Briefcase的检查了.  直接拉Briefcase过来饥渴.
            //2.根据skno在Briefcase中获取点名表和上课表.
            //3.对于上课表的更改, 直接在服务器上找到那节课对应的记录 然后改 然后上传即可.
            //4.todo:如果需要更新指纹信息,则需要再开启一个函数,用来更新指纹信息.

            //下面这个东西直接往数据库里塞就行

            var fDataModule = new DataModule();



            try {
                var verifyList = from c in fDataModule.GetJsandkkviewro() where c.KKNO == kkno select c;

                verifyList.Count(); // 败笔.  数一下就知道登录是否正确了.
            } catch (RemObjects.SDK.Exceptions.SessionNotFoundException) {
                MsgBox.ShowMsgBoxDialog("登录异常");
            }

            var dmList = OfflineDataControl.GetDmtable(kkno, skno); // 这已经是List了... 我干了什么...

            foreach (var dmlistRecord in dmList)
            {
                dmlistRecord.POSTDATE = DateTime.Now;

                dmlistRecord.POSTMANNO = Convert.ToInt64(Properties.Settings.Default.UserId);

                if (dmlistRecord.DKZT == 5)//如果是未签到 将其改成旷课
                {
                    dmlistRecord.DKZT = 3;
                }

                fDataModule.UpdateDmRow(dmlistRecord);
            }

            _waitForm = new WaitForm("准备上传点名信息");

            new Thread(() => {
                Thread.Sleep(1000);

                _waitForm.BeginInvoke(new MethodInvoker(() => {
                    _waitForm.SetInfo("正在上传点名信息");

                    _waitForm.SetValue(30);
                }));

                fDataModule.ApplyChanges();  //需要将该操作放到线程中.

                _waitForm.BeginInvoke(new MethodInvoker(() => {
                    _waitForm.SetInfo("点名信息上传完成");

                    _waitForm.SetValue(45);

                    _waitForm.Close(); // 关闭进度条框
                }));
            }).Start();

            _waitForm.ShowDialog();

            var skrecordList = OfflineDataControl.GetSktable(kkno);                        // 将来需要把这个拿来更新上课表

            var skrecord = (from c in skrecordList where c.SKNO == skno select c).First(); // linq  完了以后把第一条记录取出来(一共就有一条记录.)

            var ztrs = OfflineDataControl.CountLeaveEarlyStudent(dmList);

            var zcrs = OfflineDataControl.CountNormalStudent(dmList);

            var cdrs = OfflineDataControl.CountLateStudent(dmList);

            var kkrs = OfflineDataControl.CountAbsentStudent(dmList);

            skrecord.ZTRS = Convert.ToInt16(ztrs);                                    // 设置早退人数

            skrecord.ZCRS = Convert.ToInt16(zcrs);                                    // 设置正常出勤人数

            skrecord.KKRS = Convert.ToInt16(kkrs);                                    // 设置旷课人数

            skrecord.CDRS = Convert.ToInt16(cdrs);                                    //设置迟到人数

            skrecord.EDITDATE = DateTime.Now;                                         // 设置编辑时间

            skrecord.EDITMANNO = Convert.ToInt64(Properties.Settings.Default.UserId); // 设置编辑人员ID

            skrecord.SKZT = 1;                                                        //已经点名

            skrecord.DMFS = 1;

            fDataModule.UpdateSkTableRow(skrecord); // 上传上课信息.

            fDataModule.ApplyChanges();             //需要将该操作放到线程中.

            //再下载一遍上课表 该操作将会刷新PropertiesBriefcase中的ClassInfo表.

            _waitForm = new WaitForm("正在同步课程信息");

            new Thread(() => {
                Thread.Sleep(1000);

                _waitForm.BeginInvoke(new MethodInvoker(() => _waitForm.SetValue(70)));

                DataDownloadControl.SaveSkTable(kkno, skno, skrecord);

                _waitForm.BeginInvoke(new MethodInvoker(() => _waitForm.Close()));
            }).Start();

            _waitForm.ShowDialog();
        }