Example #1
0
        private async void btnCopySchedule_Click(object sender, RoutedEventArgs e)
        {
            if (classSchedule.SelectedAppointment != null)
            {
                ScheduleAppointment appointment       = classSchedule.SelectedAppointment as ScheduleAppointment;
                EditScheduleWindow  newScheduleWindow = new EditScheduleWindow();
                newScheduleWindow.Om       = OperationMode.CopyMode;
                newScheduleWindow.Schedule = appointment;

                if (newScheduleWindow.ShowDialog() == true)
                {
                    ScheduleAppointment sa         = new ScheduleAppointment();
                    ScheduleEditModel   affterEdit = newScheduleWindow.AffterEditSchedule;
                    RadScheduleViewCommands.BeginEditAppointment.Execute(sa, null);
                    sa.ScheduleId = affterEdit.ScheduleId;
                    sa.Start      = affterEdit.StartTime;
                    sa.End        = affterEdit.EndTime;
                    if (affterEdit.StatusDes == "Normal")
                    {
                        sa.Category = new Category("Green Category", new SolidColorBrush(Colors.Green));
                    }
                    else
                    {
                        sa.Category = new Category("Red Category", new SolidColorBrush(Colors.Red));
                    }

                    RadScheduleViewCommands.CommitEditAppointment.Execute(sa, null);
                }

                await bindSchedule();
            }
        }
Example #2
0
 /// <summary>
 /// 根据排课计划id获取编辑对象
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ScheduleEditModel GetScheduleById(int id)
 {
     try
     {
         ScheduleEditModel           scheduleEditModel = new ScheduleEditModel();
         Repository <class_schedule> scheduleDal       = _unitOfWork.GetRepository <class_schedule>();
         class_schedule scheduleEntity = scheduleDal.GetObjectByKey(id).Entity;
         if (scheduleEntity != null)
         {
             Repository <status>  statusDal        = _unitOfWork.GetRepository <status>();
             IEnumerable <status> attendanceStatus = statusDal.Find(s => s.cat == "attendance").Entities;
             int attendedStatus = attendanceStatus.Single(s => s.description == "Attended").id;
             scheduleEditModel.InitEditModel(scheduleEntity, attendedStatus);
         }
         return(scheduleEditModel);
     }
     catch (RepositoryException rex)
     {
         string msg    = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg    = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
 }
Example #3
0
        private async Task bindStudentList()
        {
            IEqualityComparer <StudentDisplayModel> ec = new EntityComparer();
            IAsyncProxy <IScheduleService>          scheduleAsyncProxy = await Task.Run(() => ServiceHelper.GetScheduleService());

            IAsyncProxy <IStudentService> studentAyncProxy = await Task.Run(() => ServiceHelper.GetStudentService());

            ScheduleEditModel sem = await scheduleAsyncProxy.CallAsync(c => c.GetScheduleById(ScheduleId));

            lbClassName.Content   = "ClassName:" + sem.ClassName + "  LessonName:" + sem.LessonName;
            lbClassTime.Content   = "StartTime:" + sem.StartTime.ToString("yyyy-MM-dd HH:mm");
            lbTeacherName.Content = "Teacher:" + sem.TeacherName;

            IList <StudentDisplayModel> RM;

            if (sem.RealDate < DateTime.Now)
            {
                //如果选择的为历史,先获取列表
                RM = studentAyncProxy.Client.FindStudentsByScheduleId(ScheduleId);
                if (RM == null || RM.Count == 0)
                {
                    //说明该课程还没有历史记录,说明没有签到过,则需要根据班级查找
                    RM = studentAyncProxy.Client.FindStudentsByClassId(ClassId);
                }
                else
                {
                    //考虑可能后期维护的时候增加漏掉的新增学员,需要合并列表
                    RM = RM.Union(studentAyncProxy.Client.FindStudentsByClassId(ClassId), ec).ToList();
                }
            }
            else
            {
                //绑定该课程所关联班级所有学生列表
                RM = studentAyncProxy.Client.FindStudentsByClassId(ClassId);
            }
            this.StudentTree.ItemsSource = RM;
            this.StudentTree.ExpandAll();
            //选择当前已经点到学生

            if (sem.AttendedStudentIds != null && sem.AttendedStudentIds.Count > 0)
            {
                foreach (StudentDisplayModel sdm in StudentTree.Items)
                {
                    RadTreeViewItem targetItem = StudentTree.GetItemByPath(sdm.Name);
                    if (sem.AttendedStudentIds.Contains(sdm.Id))
                    {
                        targetItem.IsChecked = true;
                    }
                }
            }

            foreach (StudentDisplayModel sdm in StudentTree.Items)
            {
                RadTreeViewItem targetItem = StudentTree.GetItemByPath(sdm.Name);
                targetItem.ToolTip = sdm.Name + "\r\n" + sdm.Nickname + "\r\n" + sdm.Momsname + "\r\n" +
                                     sdm.Momsphone + "\r\n" + sdm.School + "\r\n" + sdm.Grade + "\r\n" + sdm.ExtraInfo;
            }
        }
Example #4
0
        public ActionResult Update(ScheduleEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var response = _scheduleService.Update(Mapper.Map <ScheduleModel>(model));

            if (!response.IsSuccessful)
            {
                ModelState.AddModelError("", response.Message);
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }
Example #5
0
        public ScheduleEditModel Update(ScheduleEditModel newScheduleEditModel)
        {
            try
            {
                Repository <class_schedule> scheduleDal = _unitOfWork.GetRepository <class_schedule>();
                class_schedule scheduleentity           = scheduleDal.GetObjectByKey(newScheduleEditModel.ScheduleId).Entity;
                if (scheduleentity != null)
                {
                    scheduleentity.classroom_id        = newScheduleEditModel.ClassroomId;
                    scheduleentity.real_date           = newScheduleEditModel.RealDate;
                    scheduleentity.end_date            = newScheduleEditModel.EndTime;
                    scheduleentity.start_time          = newScheduleEditModel.StartTime;
                    scheduleentity.status              = newScheduleEditModel.Status;
                    scheduleentity.teacher_id          = newScheduleEditModel.TeacherId;
                    scheduleentity.lesson_schemas_text = newScheduleEditModel.LessonName;
                    scheduleentity.note = newScheduleEditModel.Note;
                    if (newScheduleEditModel.AssistantId != 0)
                    {
                        scheduleentity.assistant_id = newScheduleEditModel.AssistantId;
                    }
                }

                _unitOfWork.AddAction(scheduleentity, DataActions.Update);
                _unitOfWork.Save();

                Repository <status> statusDal = _unitOfWork.GetRepository <status>();
                newScheduleEditModel.StatusDes = statusDal.GetObjectByKey(scheduleentity.status).Entity.description;

                return(newScheduleEditModel);
            }
            catch (RepositoryException rex)
            {
                string msg    = rex.Message;
                string reason = rex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
            catch (Exception ex)
            {
                string msg    = ex.Message;
                string reason = ex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
        }
Example #6
0
        private async void btnSetSchedule_Click(object sender, RoutedEventArgs e)
        {
            if (classSchedule.SelectedAppointment != null)
            {
                ScheduleAppointment appointment       = classSchedule.SelectedAppointment as ScheduleAppointment;
                EditScheduleWindow  newScheduleWindow = new EditScheduleWindow();
                if (appointment.ScheduleId == 0)
                {
                    newScheduleWindow.Om       = OperationMode.AddMode;
                    newScheduleWindow.Schedule = appointment;

                    if (newScheduleWindow.ShowDialog() == true)
                    {
                        ScheduleEditModel affterEdit = newScheduleWindow.AffterEditSchedule;
                        RadScheduleViewCommands.BeginEditAppointment.Execute(appointment, null);
                        appointment.ScheduleId = affterEdit.ScheduleId;
                        appointment.Start      = affterEdit.StartTime;
                        appointment.End        = affterEdit.EndTime;
                        if (affterEdit.StatusDes == "Normal")
                        {
                            appointment.Category = new Category("Green Category", new SolidColorBrush(Colors.Green));
                        }
                        else
                        {
                            appointment.Category = new Category("Red Category", new SolidColorBrush(Colors.Red));
                        }

                        RadScheduleViewCommands.CommitEditAppointment.Execute(appointment, null);

                        await bindSchedule();
                    }
                }
                else
                {
                    newScheduleWindow.Om       = OperationMode.EditMode;
                    newScheduleWindow.Schedule = appointment;

                    if (newScheduleWindow.ShowDialog() == true)
                    {
                        ScheduleEditModel affterEdit = newScheduleWindow.AffterEditSchedule;
                        RadScheduleViewCommands.BeginEditAppointment.Execute(appointment, null);

                        appointment.End           = affterEdit.EndTime;
                        appointment.ScheduleId    = affterEdit.ScheduleId;
                        appointment.Start         = affterEdit.StartTime;
                        appointment.Subject       = affterEdit.ClassName;
                        appointment.TeacherName   = affterEdit.TeacherName;
                        appointment.AssistantName = affterEdit.AssistantName;
                        appointment.ClassroomName = affterEdit.ClassroomName;
                        if (affterEdit.StatusDes == "Normal")
                        {
                            appointment.Category = new Category("Green Category", new SolidColorBrush(Colors.Green));
                        }
                        else
                        {
                            appointment.Category = new Category("Red Category", new SolidColorBrush(Colors.Red));
                        }

                        RadScheduleViewCommands.CommitEditAppointment.Execute(appointment, null);

                        await bindSchedule();
                    }
                }
            }
        }
Example #7
0
        private void SetSchedule(object parameter)
        {
            IEnumerable appointments = parameter as IEnumerable;

            if (appointments != null)
            {
                foreach (ScheduleAppointment appointment in appointments.OfType <ScheduleAppointment>())
                {
                    EditScheduleWindow newScheduleWindow = new EditScheduleWindow();
                    if (appointment.ScheduleId == 0)
                    {
                        newScheduleWindow.Om       = OperationMode.AddMode;
                        newScheduleWindow.Schedule = appointment;

                        if (newScheduleWindow.ShowDialog() == true)
                        {
                            ScheduleEditModel affterEdit = newScheduleWindow.AffterEditSchedule;
                            RadScheduleViewCommands.BeginEditAppointment.Execute(appointment, null);
                            appointment.ScheduleId = affterEdit.ScheduleId;
                            appointment.Start      = affterEdit.StartTime;
                            appointment.End        = affterEdit.EndTime;
                            if (affterEdit.StatusDes == "Normal")
                            {
                                appointment.Category = new Category("Green Category", new SolidColorBrush(Colors.Green));
                            }
                            else
                            {
                                appointment.Category = new Category("Red Category", new SolidColorBrush(Colors.Red));
                            }

                            RadScheduleViewCommands.CommitEditAppointment.Execute(appointment, null);
                        }
                    }
                    else
                    {
                        newScheduleWindow.Om       = OperationMode.EditMode;
                        newScheduleWindow.Schedule = appointment;

                        if (newScheduleWindow.ShowDialog() == true)
                        {
                            ScheduleEditModel affterEdit = newScheduleWindow.AffterEditSchedule;
                            RadScheduleViewCommands.BeginEditAppointment.Execute(appointment, null);

                            appointment.End           = affterEdit.EndTime;
                            appointment.ScheduleId    = affterEdit.ScheduleId;
                            appointment.Start         = affterEdit.StartTime;
                            appointment.Subject       = affterEdit.ClassName;
                            appointment.TeacherName   = affterEdit.TeacherName;
                            appointment.AssistantName = affterEdit.AssistantName;
                            appointment.ClassroomName = affterEdit.ClassroomName;
                            if (affterEdit.StatusDes == "Normal")
                            {
                                appointment.Category = new Category("Green Category", new SolidColorBrush(Colors.Green));
                            }
                            else
                            {
                                appointment.Category = new Category("Red Category", new SolidColorBrush(Colors.Red));
                            }

                            RadScheduleViewCommands.CommitEditAppointment.Execute(appointment, null);
                        }
                    }
                }
            }
        }
Example #8
0
        private async void btnOK_Click(object sender, RoutedEventArgs e)
        {
            #region 新增
            if (Om == OperationMode.AddMode || Om == OperationMode.CopyMode)
            {
                string strErrorMsg = string.Empty;
                try
                {
                    ScheduleEditModel newScheduleModel = new ScheduleEditModel();
                    newScheduleModel.ClassId     = schedule.ClassId;
                    newScheduleModel.ClassroomId = (cmbClassroom.SelectedItem as ClassroomModel).Id;
                    newScheduleModel.EndTime     = realDate.SelectedDate.Value.Date + timeEnd.SelectedValue.Value.TimeOfDay;
                    newScheduleModel.StartTime   = realDate.SelectedDate.Value.Date + timeStart.SelectedValue.Value.TimeOfDay;
                    newScheduleModel.RealDate    = realDate.SelectedDate.Value.Date;
                    newScheduleModel.TeacherId   = (cmbTeacher.SelectedItem as TeacherModel).Id;
                    newScheduleModel.Status      = (cmbStatus.SelectedItem as StatusModel).Id;
                    newScheduleModel.Note        = txtNote.Text.Trim();
                    newScheduleModel.LessonName  = txtSchemas.Text.Trim();
                    if (cmbAssistant.SelectedIndex != -1)
                    {
                        newScheduleModel.AssistantId = (cmbAssistant.SelectedItem as TeacherModel).Id;
                    }

                    newScheduleModel = await scheduleAsyncProxy.CallAsync(c => c.Add(newScheduleModel));

                    this.AffterEditSchedule = newScheduleModel;
                    this.DialogResult       = true;
                }
                catch (TimeoutException timeProblem)
                {
                    strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message;
                }
                catch (FaultException <LCFault> af)
                {
                    strErrorMsg = af.Detail.Message;
                }
                catch (FaultException unknownFault)
                {
                    strErrorMsg = UIResources.UnKnowFault + unknownFault.Message;
                }
                catch (CommunicationException commProblem)
                {
                    strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace;
                }
                if (strErrorMsg != string.Empty)
                {
                    await DialogManager.ShowMessageAsync(this, UIResources.MsgError, "新增(复制)排课信息失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null);
                }
            }

            #endregion

            //#region 复制
            //else if(Om == OperationMode.CopyMode)
            //{
            //    string strErrorMsg = string.Empty;
            //    try
            //    {
            //        ScheduleEditModel newScheduleModel = new ScheduleEditModel();
            //        newScheduleModel.ClassId = schedule.ClassId;
            //        newScheduleModel.ClassroomId = (cmbClassroom.SelectedItem as ClassroomModel).Id;
            //        newScheduleModel.EndTime = realDate.SelectedDate.Value.Date + timeEnd.SelectedValue.Value.TimeOfDay;
            //        newScheduleModel.StartTime = realDate.SelectedDate.Value.Date + timeStart.SelectedValue.Value.TimeOfDay;
            //        newScheduleModel.RealDate = realDate.SelectedDate.Value.Date;
            //        newScheduleModel.TeacherId = (cmbTeacher.SelectedItem as TeacherModel).Id;
            //        newScheduleModel.Status = (cmbStatus.SelectedItem as StatusModel).Id;
            //        if (cmbAssistant.SelectedIndex != -1)
            //        {
            //            newScheduleModel.AssistantId = (cmbAssistant.SelectedItem as TeacherModel).Id;
            //        }

            //        newScheduleModel = await scheduleAsyncProxy.CallAsync(c => c.Add(newScheduleModel));
            //        this.AffterEditSchedule = newScheduleModel;
            //        this.DialogResult = true;
            //    }
            //    catch (TimeoutException timeProblem)
            //    {
            //        strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message;
            //    }
            //    catch (FaultException<LCFault> af)
            //    {
            //        strErrorMsg = af.Detail.Message;
            //    }
            //    catch (FaultException unknownFault)
            //    {
            //        strErrorMsg = UIResources.UnKnowFault + unknownFault.Message;
            //    }
            //    catch (CommunicationException commProblem)
            //    {
            //        strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace;
            //    }
            //    if (strErrorMsg != string.Empty)
            //    {
            //        await DialogManager.ShowMessageAsync(this, UIResources.MsgError, "复制排课信息失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null);
            //    }
            //}
            //#endregion

            #region 修改
            else
            {
                string strErrorMsg = string.Empty;
                try
                {
                    AffterEditSchedule.ClassroomId   = (cmbClassroom.SelectedItem as ClassroomModel).Id;
                    AffterEditSchedule.ClassroomName = cmbClassroom.Text;
                    AffterEditSchedule.EndTime       = realDate.SelectedDate.Value.Date + timeEnd.SelectedValue.Value.TimeOfDay;
                    AffterEditSchedule.StartTime     = realDate.SelectedDate.Value.Date + timeStart.SelectedValue.Value.TimeOfDay;
                    AffterEditSchedule.RealDate      = realDate.SelectedDate.Value.Date;
                    AffterEditSchedule.TeacherId     = (cmbTeacher.SelectedItem as TeacherModel).Id;
                    AffterEditSchedule.TeacherName   = cmbTeacher.Text;
                    AffterEditSchedule.Status        = (cmbStatus.SelectedItem as StatusModel).Id;
                    AffterEditSchedule.StatusDes     = cmbStatus.Text;
                    AffterEditSchedule.Note          = txtNote.Text.Trim();
                    AffterEditSchedule.LessonName    = txtSchemas.Text.Trim();
                    if (cmbAssistant.SelectedIndex != -1)
                    {
                        AffterEditSchedule.AssistantId   = (cmbAssistant.SelectedItem as TeacherModel).Id;
                        AffterEditSchedule.AssistantName = cmbAssistant.Text;
                    }

                    await scheduleAsyncProxy.CallAsync(c => c.Update(AffterEditSchedule));

                    this.DialogResult = true;
                }
                catch (TimeoutException timeProblem)
                {
                    strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message;
                }
                catch (FaultException <LCFault> af)
                {
                    strErrorMsg = af.Detail.Message;
                }
                catch (FaultException unknownFault)
                {
                    strErrorMsg = UIResources.UnKnowFault + unknownFault.Message;
                }
                catch (CommunicationException commProblem)
                {
                    strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace;
                }
                if (strErrorMsg != string.Empty)
                {
                    await DialogManager.ShowMessageAsync(this, UIResources.MsgError, "修改排课信息失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null);
                }
            }
            #endregion
        }
Example #9
0
        private async void BindScheduleInfo()
        {
            string strErrorMsg = string.Empty;

            try
            {
                if (Om == OperationMode.EditMode)
                {
                    //选择了修改模式
                    this.AffterEditSchedule = await scheduleAsyncProxy.CallAsync(c => c.GetScheduleById(schedule.ScheduleId));

                    txtName.Text           = AffterEditSchedule.ClassName;
                    classid                = AffterEditSchedule.ClassId;
                    realDate.Text          = AffterEditSchedule.StartTime.Date.ToShortDateString();
                    timeStart.SelectedTime = AffterEditSchedule.StartTime.TimeOfDay;
                    timeEnd.SelectedTime   = AffterEditSchedule.EndTime.TimeOfDay;
                    cmbClassroom.Text      = AffterEditSchedule.ClassroomName;
                    cmbAssistant.Text      = AffterEditSchedule.AssistantName;
                    cmbTeacher.Text        = AffterEditSchedule.TeacherName;
                    cmbStatus.Text         = AffterEditSchedule.StatusDes;
                    txtNote.Text           = AffterEditSchedule.Note;
                    txtSchemas.Text        = AffterEditSchedule.LessonName;
                    this.Title             = this.Title + AffterEditSchedule.ScheduleId;
                }
                else if (Om == OperationMode.CopyMode)
                {
                    //复制模式
                    this.AffterEditSchedule = await scheduleAsyncProxy.CallAsync(c => c.GetScheduleById(schedule.ScheduleId));

                    txtName.Text           = AffterEditSchedule.ClassName;
                    classid                = AffterEditSchedule.ClassId;
                    realDate.Text          = AffterEditSchedule.StartTime.Date.ToShortDateString();
                    timeStart.SelectedTime = AffterEditSchedule.StartTime.TimeOfDay;
                    timeEnd.SelectedTime   = AffterEditSchedule.EndTime.TimeOfDay;
                    cmbClassroom.Text      = AffterEditSchedule.ClassroomName;
                    cmbAssistant.Text      = AffterEditSchedule.AssistantName;
                    cmbTeacher.Text        = AffterEditSchedule.TeacherName;
                    cmbStatus.Text         = AffterEditSchedule.StatusDes;
                    txtNote.Text           = AffterEditSchedule.Note;
                    txtSchemas.Text        = AffterEditSchedule.LessonName;
                    this.Title             = this.Title + "Copy";
                }
                else
                {
                    //新增模式
                    txtName.Text           = schedule.Subject;
                    classid                = schedule.ClassId;
                    realDate.Text          = schedule.Start.Date.ToShortDateString();
                    timeStart.SelectedTime = schedule.Start.TimeOfDay;
                    timeEnd.SelectedTime   = schedule.End.TimeOfDay;
                }
            }
            catch (TimeoutException timeProblem)
            {
                strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message;
            }
            catch (FaultException <LCFault> af)
            {
                strErrorMsg = af.Detail.Message;
            }
            catch (FaultException unknownFault)
            {
                strErrorMsg = UIResources.UnKnowFault + unknownFault.Message;
            }
            catch (CommunicationException commProblem)
            {
                strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace;
            }
            catch (Exception ex)
            {
                strErrorMsg = ex.Message;
            }
            if (strErrorMsg != string.Empty)
            {
                await DialogManager.ShowMessageAsync(this, UIResources.MsgError, "绑定班级信息失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null);
            }
        }