private IList <ClassTypeModel> BuildModelList(List <class_types> classTypes, bool withClasses = false) { if (classTypes == null) { return(null); } else { IList <ClassTypeModel> moduledisplays = new List <ClassTypeModel>(); foreach (class_types classtypes in classTypes) { ClassTypeModel moduledisplay = BuildModel(classtypes); if (withClasses) { moduledisplay.classDisplayModels = new List <ClassDisplayModel>(); foreach (classes cs in classtypes.subclasses) { if (cs.is_active) { ClassDisplayModel cdm = new ClassDisplayModel(); cdm.Id = cs.class_id; cdm.Name = cs.class_name; cdm.LastCount = cs.last_count; moduledisplay.classDisplayModels.Add(cdm); } } } moduledisplays.Add(moduledisplay); } return(moduledisplays); } }
private async void MetroWindow_Loaded(object sender, RoutedEventArgs e) { string strErrorMsg = string.Empty; ClassEditModel classEditModel = new ClassEditModel(); try { classTypeAsyncProxy = await Task.Run(() => ServiceHelper.GetClassTypeService()); classesAsyncProxy = await Task.Run(() => ServiceHelper.GetClassService()); IList <ClassTypeModel> classTypeLists = await classTypeAsyncProxy.CallAsync(c => c.GetAllClassType()); this.cmbClassType.ItemsSource = classTypeLists; if (this.classTypeId != 0) { classTypeModel = await classTypeAsyncProxy.CallAsync(c => c.GetClassTypeById(classTypeId)); } } 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); return; } if (Om == OperationMode.AddMode) { this.Title = "新增班级"; txtName.IsEnabled = true; BindClassInfo(); } else { this.Title = "修改班级"; //txtName.IsEnabled = false; BindClassInfo(); } }
private async void gvClassTypes_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e) { if (gvClassTypes.SelectedItem != null) { this.selectClassType = gvClassTypes.SelectedItem as ClassTypeModel; await bindClassList(); await bindSchemasList(); } }
private async void UpdateClassType_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ClassTypeModel selectClassType = this.gvClassTypes.SelectedItem as ClassTypeModel; if (selectClassType != null) { string strErrorMsg = string.Empty; try { EditClassTypeWindow newClassTypeWindow = new EditClassTypeWindow(); newClassTypeWindow.SelectClassType = selectClassType; newClassTypeWindow.Om = OperationMode.EditMode; if (newClassTypeWindow.ShowDialog() == true) { await bindClassTypeList(); } } 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.GetMainWindow(), UIResources.MsgError, "更新班级类型失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null); } } }
private async void BindClassTypeInfo(ClassTypeModel selectClassType) { string strErrorMsg = string.Empty; try { if (selectClassType != null) { txtName.Text = selectClassType.Name; numTotal.Value = selectClassType.TotalLessons; numPrice.Value = selectClassType.UnitPrice; numStuLimit.Value = selectClassType.StudentLimit; numTeacherRate.Value = selectClassType.TeacherRate; numAssistantRate.Value = selectClassType.AssistantRate; numConsultantRate.Value = selectClassType.ConsultantRate; txtRemark.Text = selectClassType.Des; } } 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); } }
/// <summary> /// 删除班级类型信息 /// </summary> /// <param name="deleteUserModel">删除班级类型信息</param> public bool Delete(ClassTypeModel deleteClassTypeModel) { try { return(DeleteById(deleteClassTypeModel.Id)); } 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); } }
/// <summary> /// 更新班级类型信息 /// </summary> /// <param name="newUserModel">需要更新的班级类型信息</param> public ClassTypeModel Update(ClassTypeModel newClassTypeModel) { try { Repository <class_types> classtypesDal = _unitOfWork.GetRepository <class_types>(); class_types classtypes = classtypesDal.GetObjectByKey(newClassTypeModel.Id).Entity; if (classtypes != null) { classtypes.name = newClassTypeModel.Name; classtypes.commission_rate_consultant = Convert.ToDecimal(newClassTypeModel.ConsultantRate); classtypes.commission_rate_assistant = Convert.ToDecimal(newClassTypeModel.AssistantRate); classtypes.commission_rate_teacher = Convert.ToDecimal(newClassTypeModel.TeacherRate); classtypes.description = newClassTypeModel.Des; classtypes.is_active = newClassTypeModel.IsActive; classtypes.student_limit = newClassTypeModel.StudentLimit; classtypes.total_lessons = newClassTypeModel.TotalLessons; classtypes.unit_price = newClassTypeModel.UnitPrice; } _unitOfWork.AddAction(classtypes, DataActions.Update); _unitOfWork.Save(); return(newClassTypeModel); } 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); } }
private ClassTypeModel BuildModel(class_types classtypesModule) { if (classtypesModule == null) { return(null); } else { ClassTypeModel classtypemodel = new ClassTypeModel(); classtypemodel.Id = classtypesModule.id; classtypemodel.Name = classtypesModule.name; classtypemodel.AssistantRate = Convert.ToDouble(classtypesModule.commission_rate_assistant); classtypemodel.ConsultantRate = Convert.ToDouble(classtypesModule.commission_rate_consultant); classtypemodel.Des = classtypesModule.description; classtypemodel.IsActive = classtypesModule.is_active; classtypemodel.StudentLimit = classtypesModule.student_limit; classtypemodel.TeacherRate = Convert.ToDouble(classtypesModule.commission_rate_teacher); classtypemodel.TotalLessons = classtypesModule.total_lessons; classtypemodel.UnitPrice = classtypesModule.unit_price; return(classtypemodel); } }
/// <summary> /// Todays Timetable /// </summary> public void TodaysTimetableLayout() { try { TitleBar lblPageName = new TitleBar("Today's TimeTable"); StackLayout slTitle = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 5, 0, 0), BackgroundColor = Color.White, Children = { lblPageName } }; Seperator spTitle = new Seperator(); BindableRadioGroup radByTeacherOrClass = new BindableRadioGroup(); radByTeacherOrClass.ItemsSource = new[] { "By Teacher", "By Class" }; radByTeacherOrClass.HorizontalOptions = LayoutOptions.FillAndExpand; radByTeacherOrClass.Orientation = StackOrientation.Horizontal; radByTeacherOrClass.TextColor = Color.Black; StackLayout slRadio = new StackLayout { Children = { radByTeacherOrClass }, HorizontalOptions = LayoutOptions.FillAndExpand }; #region By Teacher Image imgTeacherDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblTeacher = new Label { TextColor = Color.Black, Text = "Teacher" }; Picker pcrTeacher = new Picker { IsVisible = false, Title = "Teacher" }; StackLayout slTeacherDisplay = new StackLayout { Children = { lblTeacher, pcrTeacher, imgTeacherDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmTeacher = new Frame { Content = slTeacherDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var teacherTap = new TapGestureRecognizer(); teacherTap.NumberOfTapsRequired = 1; // single-tap teacherTap.Tapped += (s, e) => { pcrTeacher.Focus(); }; frmTeacher.GestureRecognizers.Add(teacherTap); slTeacherDisplay.GestureRecognizers.Add(teacherTap); StackLayout slTeacherFrameLayout = new StackLayout { Children = { frmTeacher } }; StackLayout slTeacherLayout = new StackLayout { Children = { slTeacherFrameLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = false }; Label lblStandardName = new Label { Text = "Standard Name", TextColor = Color.Black }; StackLayout slStandardName = new StackLayout { Children = { lblStandardName }, VerticalOptions = LayoutOptions.CenterAndExpand, }; Label lblClassTypeName = new Label { Text = "Class Type Name", TextColor = Color.Black }; StackLayout slClassTypeName = new StackLayout { Children = { lblClassTypeName }, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lblStubjectName = new Label { Text = "Subject Name", TextColor = Color.Black }; StackLayout slSubjectName = new StackLayout { Children = { lblStubjectName }, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.EndAndExpand }; #endregion #region By Class Image imgStandardDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblStandard = new Label { TextColor = Color.Black, Text = "Standard" }; Picker pcrStandard = new Picker { IsVisible = false, Title = "Standard" }; StackLayout slStandardDisplay = new StackLayout { Children = { lblStandard, pcrStandard, imgStandardDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmStandard = new Frame { Content = slStandardDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var standardTap = new TapGestureRecognizer(); standardTap.NumberOfTapsRequired = 1; // single-tap standardTap.Tapped += (s, e) => { pcrStandard.Focus(); }; frmStandard.GestureRecognizers.Add(standardTap); slStandardDisplay.GestureRecognizers.Add(standardTap); StackLayout slStandardFrameLayout = new StackLayout { Children = { frmStandard } }; StackLayout slStandardLayout = new StackLayout { Children = { slStandardFrameLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, }; Image imgClassDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblClass = new Label { TextColor = Color.Black, Text = "Class" }; Picker pcrClass = new Picker { IsVisible = false, Title = "Class" }; StackLayout slClassDisplay = new StackLayout { Children = { lblClass, pcrClass, imgClassDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmClass = new Frame { Content = slClassDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var classTap = new TapGestureRecognizer(); classTap.NumberOfTapsRequired = 1; // single-tap classTap.Tapped += (s, e) => { pcrClass.Focus(); }; frmClass.GestureRecognizers.Add(classTap); slClassDisplay.GestureRecognizers.Add(classTap); StackLayout slClassFrameLayout = new StackLayout { Children = { frmClass } }; StackLayout slClassLayout = new StackLayout { Children = { slClassFrameLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = false }; //Grid Header Label lblTeachername = new Label { Text = "Teacher Name", TextColor = Color.Black }; StackLayout slTeacherName = new StackLayout { Children = { lblTeachername }, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lblStubject = new Label { Text = "Subject Name", TextColor = Color.Black }; StackLayout slSubject = new StackLayout { Children = { lblStubject }, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.EndAndExpand }; #endregion Label lblSequensNo = new Label { Text = "No", TextColor = Color.Black }; StackLayout slSequensNo = new StackLayout { Children = { lblSequensNo }, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand }; StackLayout grid = new StackLayout { //Children = { slTeacherName, slSequensNo, slSubjectName }, Orientation = StackOrientation.Horizontal, IsVisible = false }; Seperator spDisplayHeader = new Seperator { IsVisible = false }; StackLayout slSearchinOneCol = new StackLayout { Children = { slStandardLayout, slClassLayout }, Orientation = StackOrientation.Horizontal, IsVisible = false }; _NotAvailData = new Label { Text = "No data availalble for this search data.", TextColor = Color.Red, IsVisible = false }; _Loader = new LoadingIndicator(); radByTeacherOrClass.CheckedChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async () => { var radio = sender as CustomRadioButton; if (radio == null || radio.Id == -1) { return; } if (radio.Text == "By Teacher") { slTeacherLayout.IsVisible = true; slSearchinOneCol.IsVisible = false; foreach (TeacherModel item in _TeacherList) { pcrTeacher.Items.Add(item.Name); } grid.Children.Add(slSequensNo); grid.Children.Add(slStandardDisplay); grid.Children.Add(slClassTypeName); grid.Children.Add(slSubjectName); } else { slSearchinOneCol.IsVisible = true; slTeacherLayout.IsVisible = false; grid.Children.Add(slSequensNo); grid.Children.Add(slTeacherName); grid.Children.Add(slSubject); _StatndardList = await StandardModel.GetStandard(); foreach (StandardModel item in _StatndardList) { pcrStandard.Items.Add(item.Name); } } }); }; //List view ListView TimeTableListView = new ListView { RowHeight = 50, SeparatorColor = Color.Gray }; TimeTableListView.ItemTemplate = new DataTemplate(() => new FillUpAttendanceCell()); pcrStandard.SelectedIndexChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async () => { try { _Loader.IsShowLoading = true; pcrClass.Items.Clear(); string standardName = lblStandard.Text = pcrStandard.Items[pcrStandard.SelectedIndex]; _SelectedStandardID = _StatndardList.Where(x => x.Name == standardName).FirstOrDefault().Id; _ClassTypeList = await ClassTypeModel.GetClassType(_SelectedStandardID); if (_ClassTypeList.Count > 0 && _ClassTypeList != null) { slClassLayout.IsVisible = true; _NotAvailData.IsVisible = false; } else { slClassLayout.IsVisible = false; _NotAvailData.IsVisible = true; } foreach (ClassTypeModel item in _ClassTypeList) { pcrClass.Items.Add(item.Name); } _Loader.IsShowLoading = false; } catch (Exception ex) { } }); }; //Class Picker Selected pcrClass.SelectedIndexChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async () => { _Loader.IsShowLoading = true; _NotAvailData.IsVisible = false; string className = lblClass.Text = pcrClass.Items[pcrClass.SelectedIndex]; _SelectedClassTypeID = _ClassTypeList.FirstOrDefault(x => x.Name == className).Id; //Get time table list _TimeTableList = await TimeTableModel.ShowTimeTable(_SelectedStandardID, _SelectedClassTypeID); if (_TimeTableList != null && _TimeTableList.Count > 0) { grid.IsVisible = true; spDisplayHeader.IsVisible = true; Items = new ObservableCollection<TimeTableModel>(_TimeTableList); TimeTableListView.ItemsSource = Items; } else { grid.IsVisible = false; spDisplayHeader.IsVisible = false; _NotAvailData.Text = "There is no data for selected standard and class."; _NotAvailData.IsVisible = true; } _Loader.IsShowLoading = false; }); }; //Class Picker Selected pcrTeacher.SelectedIndexChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async () => { _Loader.IsShowLoading = true; _NotAvailData.IsVisible = false; string teacherName = lblTeacher.Text = pcrTeacher.Items[pcrTeacher.SelectedIndex]; _SelectedTeacherID = _TeacherList.FirstOrDefault(x => x.Name == teacherName).ID; //Get time table list _TimeTableList = await TimeTableModel.ShowTimeTable(_SelectedTeacherID); if (_TimeTableList != null && _TimeTableList.Count > 0) { grid.IsVisible = true; spDisplayHeader.IsVisible = true; Items = new ObservableCollection<TimeTableModel>(_TimeTableList); TimeTableListView.ItemsSource = Items; } else { grid.IsVisible = false; spDisplayHeader.IsVisible = false; _NotAvailData.Text = "There is no data for selected standard and class."; _NotAvailData.IsVisible = true; } _Loader.IsShowLoading = false; }); }; StackLayout slTimeTable = new StackLayout { Children = { new StackLayout{ Padding = new Thickness(20, Device.OnPlatform(40,20,0), 20, 20), Children = {slTitle, spTitle.LineSeperatorView,slRadio,slTeacherLayout, slSearchinOneCol,grid,spDisplayHeader.LineSeperatorView, _Loader, _NotAvailData,TimeTableListView}, VerticalOptions = LayoutOptions.FillAndExpand, }, }, BackgroundColor = LayoutHelper.PageBackgroundColor }; Content = new ScrollView { Content = slTimeTable, }; } catch (Exception ex) { throw; } }
public bool IsVerifyable(ClassTypeModel type) { return(type.Properties.Any(p => p.Required)); }
/// <summary> /// Student BehaviourNotice Layout. /// </summary> public void StudentBehaviourLayout() { TitleBar lblPageName = new TitleBar("Student Behaviour Notice"); StackLayout slTitle = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 5, 0, 0), BackgroundColor = Color.White, Children = { lblPageName } }; Seperator spTitle = new Seperator(); Image imgStandardDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblStandard = new Label { TextColor = Color.Black, Text = "Standard" }; Picker pcrStandard = new Picker { IsVisible = false, Title = "Standard" }; foreach (StandardModel item in _StandardList) { pcrStandard.Items.Add(item.Name); } StackLayout slStandardDisplay = new StackLayout { Children = { lblStandard, pcrStandard, imgStandardDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmStandard = new Frame { Content = slStandardDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var standardTap = new TapGestureRecognizer(); standardTap.NumberOfTapsRequired = 1; // single-tap standardTap.Tapped += (s, e) => { pcrStandard.Focus(); }; frmStandard.GestureRecognizers.Add(standardTap); slStandardDisplay.GestureRecognizers.Add(standardTap); StackLayout slStandardFrameLayout = new StackLayout { Children = { frmStandard } }; StackLayout slStandardLayout = new StackLayout { Children = { slStandardFrameLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand }; Image imgClassDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblClass = new Label { TextColor = Color.Black, Text = "Class" }; Picker pcrClass = new Picker { IsVisible = false, Title = "Class" }; StackLayout slClassDisplay = new StackLayout { Children = { lblClass, pcrClass, imgClassDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmClass = new Frame { Content = slClassDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var classTap = new TapGestureRecognizer(); classTap.NumberOfTapsRequired = 1; // single-tap classTap.Tapped += (s, e) => { pcrClass.Focus(); }; frmClass.GestureRecognizers.Add(classTap); slClassDisplay.GestureRecognizers.Add(classTap); StackLayout slClassFrmaeLayout = new StackLayout { Children = { frmClass } }; StackLayout slClassLayout = new StackLayout { Children = { slClassFrmaeLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = false }; Image imgStudentNameDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblStudentName = new Label { TextColor = Color.Black, Text = "Student Name" }; Picker pcrStudentName = new Picker { IsVisible = false, Title = "Student Name" }; StackLayout slStudentNameDisplay = new StackLayout { Children = { lblStudentName, pcrStudentName, imgStudentNameDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmStudentName = new Frame { Content = slStudentNameDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var studentNameTap = new TapGestureRecognizer(); studentNameTap.NumberOfTapsRequired = 1; // single-tap studentNameTap.Tapped += (s, e) => { pcrStudentName.Focus(); }; frmStudentName.GestureRecognizers.Add(studentNameTap); slStudentNameDisplay.GestureRecognizers.Add(studentNameTap); StackLayout slStudentNameFrmaeLayout = new StackLayout { Children = { frmStudentName } }; StackLayout slStudentNameLayout = new StackLayout { Children = { slStudentNameFrmaeLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = false }; //ExtendedEntry txtComment = new ExtendedEntry //{ // Placeholder = "Comment", // TextColor = Color.Black //}; Label lblComment = new Label { Text = "Comment", TextColor = Color.Black }; StackLayout slLableComment = new StackLayout { Children = { lblComment }, Padding = new Thickness(0, 0, 0, 10) }; Editor txtComment = new Editor { HeightRequest = 80, VerticalOptions = LayoutOptions.FillAndExpand }; StackLayout slTextComment = new StackLayout { Children = { txtComment }, Padding = new Thickness(0, 0, 0, 10) }; //txtComment.Focused += (sender, e) => //{ // if (txtComment.Text == "Comment") // { // txtComment.Text = string.Empty; // //txtComment.TextColor = Color.Black; // } //}; StackLayout slComment = new StackLayout { Children = { slLableComment, slTextComment }, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical }; StackLayout slSearchinOneCol = new StackLayout { Children = { slStandardLayout, slClassLayout }, Orientation = StackOrientation.Horizontal }; StackLayout slSearchLayout = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(0, 0, 0, 10), Children = { slStudentNameLayout, slComment } }; _NotAvailData = new Label { Text = "No data availalble for this search data.", TextColor = Color.Red, IsVisible = false }; _Loader = new LoadingIndicator(); //Stanndard Picker Selected pcrStandard.SelectedIndexChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async() => { _Loader.IsShowLoading = true; pcrClass.Items.Clear(); pcrStudentName.Items.Clear(); string standardName = lblStandard.Text = pcrStandard.Items[pcrStandard.SelectedIndex]; _SelectedStandardID = _StandardList.Where(x => x.Name == standardName).FirstOrDefault().Id; _ClassTypeList = await ClassTypeModel.GetClassType(_SelectedStandardID); if (_ClassTypeList.Count > 0 && _ClassTypeList != null) { slClassLayout.IsVisible = true; _NotAvailData.IsVisible = false; } else { _NotAvailData.IsVisible = true; } foreach (ClassTypeModel item in _ClassTypeList) { pcrClass.Items.Add(item.Name); } _Loader.IsShowLoading = false; }); }; //Class Picker Selected pcrClass.SelectedIndexChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async() => { _Loader.IsShowLoading = true; pcrStudentName.Items.Clear(); string className = lblClass.Text = pcrClass.Items[pcrClass.SelectedIndex]; _SelectedClassTypeID = _ClassTypeList.FirstOrDefault(x => x.Name == className).Id; List <StudentModel> lstStudentList = await StudentModel.GetStudent(_SelectedStandardID, _SelectedClassTypeID); if (lstStudentList != null && lstStudentList.Count > 0) { slStudentNameLayout.IsVisible = true; _NotAvailData.IsVisible = false; foreach (StudentModel item in _StudentModelList) { pcrStudentName.Items.Add(item.Name); } } else { _NotAvailData.Text = "There is no student for this class and standard"; _NotAvailData.IsVisible = true; } _Loader.IsShowLoading = false; }); }; Button btnSave = new Button { IsVisible = false }; btnSave.Text = "Save"; btnSave.TextColor = Color.White; btnSave.BackgroundColor = LayoutHelper.ButtonColor; pcrStudentName.SelectedIndexChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async() => { //btnSave.IsVisible = true; string studentName = lblStudentName.Text = pcrStudentName.Items[pcrStudentName.SelectedIndex]; _SelectedStudentID = _StudentModelList.FirstOrDefault(x => x.Name == studentName).Id; //Exam list call slStudentNameLayout.IsVisible = true; }); }; btnSave.Clicked += (sender, e) => { Device.BeginInvokeOnMainThread(async() => { _Loader.IsShowLoading = true; StudentBehaviourNoticeModel studentBehaviourNoticeModel = new StudentBehaviourNoticeModel(); studentBehaviourNoticeModel.ClassTypeId = _SelectedClassTypeID; studentBehaviourNoticeModel.StandardId = _SelectedStandardID; studentBehaviourNoticeModel.StudentId = _SelectedStudentID; studentBehaviourNoticeModel.Comment = txtComment.Text; bool isSaveAttendance = await StudentBehaviourNoticeModel.SaveStudentBehaviour(studentBehaviourNoticeModel); if (isSaveAttendance) { await DisplayAlert(string.Empty, "Save Successfully.", Messages.Ok); } else { await DisplayAlert(Messages.Error, "Some problem ocuured when saving data.", Messages.Ok); } _Loader.IsShowLoading = false; }); }; var cvBtnSave = new ContentView { Padding = new Thickness(10, 5, 10, 10), Content = btnSave }; StackLayout slStudentBehaviourNotice = new StackLayout { Children = { new StackLayout { Padding = new Thickness(20, Device.OnPlatform(40, 20, 0), 20, 20), Children = { slTitle, spTitle.LineSeperatorView, slSearchinOneCol, slSearchLayout, _Loader, cvBtnSave, _NotAvailData }, VerticalOptions = LayoutOptions.FillAndExpand, }, }, BackgroundColor = LayoutHelper.PageBackgroundColor }; Content = new ScrollView { Content = slStudentBehaviourNotice, }; }
private async void DeleteClassType_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (gvClassTypes.SelectedItem == null) { await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgInfo, "请选择需要删除的班级类型!", MessageDialogStyle.Affirmative, null); return; } MessageDialogResult delResult = await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgInfo, "确定删除该班级类型吗?", MessageDialogStyle.AffirmativeAndNegative, null); if (delResult == MessageDialogResult.Affirmative) { ClassTypeModel selectClassType = this.gvClassTypes.SelectedItem as ClassTypeModel; if (selectClassType != null) { string strErrorMsg = string.Empty; try { IAsyncProxy <IClassTypeService> _classtypeAyncProxy = await Task.Run(() => ServiceHelper.GetClassTypeService()); if (selectClassType.Id != 0) { //删除已经存在于数据库的数据,对于没有存于数据库的,则事件处理完成时都会刷新列表,故不用处理 bool blIsSuccess = await _classtypeAyncProxy.CallAsync(c => c.DeleteById(selectClassType.Id)); if (blIsSuccess == true) { await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgInfo, "删除班级类型成功!", MessageDialogStyle.Affirmative, null); } } await bindClassTypeList(); } 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.GetMainWindow(), UIResources.MsgError, "删除班级类型失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null); } } } }
/// <summary> /// Fill Up Attendance Layout. /// </summary> public void FillUpAttendanceLayout() { TitleBar lblPageName = new TitleBar("FillUp Attendance"); StackLayout slTitle = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 5, 0, 0), BackgroundColor = Color.White, Children = { lblPageName } }; Seperator spTitle = new Seperator(); Image imgStandardDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblStandard = new Label { TextColor = Color.Black, Text = "Standard" }; Picker pcrStandard = new Picker { IsVisible = false, Title = "Standard" }; foreach (StandardModel item in _StandardList) { pcrStandard.Items.Add(item.Name); } StackLayout slStandardDisplay = new StackLayout { Children = { lblStandard, pcrStandard, imgStandardDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmStandard = new Frame { Content = slStandardDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var standardTap = new TapGestureRecognizer(); standardTap.NumberOfTapsRequired = 1; // single-tap standardTap.Tapped += (s, e) => { pcrStandard.Focus(); }; frmStandard.GestureRecognizers.Add(standardTap); slStandardDisplay.GestureRecognizers.Add(standardTap); StackLayout slStandardFrameLayout = new StackLayout { Children = { frmStandard } }; StackLayout slStandardLayout = new StackLayout { Children = { slStandardFrameLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand }; Seperator spStandard = new Seperator(); Image imgClassDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblClass = new Label { TextColor = Color.Black, Text = "Class" }; Picker pcrClass = new Picker { IsVisible = false, Title = "Class" }; StackLayout slClassDisplay = new StackLayout { Children = { lblClass, pcrClass, imgClassDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmClass = new Frame { Content = slClassDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var classTap = new TapGestureRecognizer(); classTap.NumberOfTapsRequired = 1; // single-tap classTap.Tapped += (s, e) => { pcrClass.Focus(); }; frmClass.GestureRecognizers.Add(classTap); slClassDisplay.GestureRecognizers.Add(classTap); StackLayout slClassFrmaeLayout = new StackLayout { Children = { frmClass } }; StackLayout slClassLayout = new StackLayout { Children = { slClassFrmaeLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = false }; Image imgStartDateDropDown = new Image { Source = Constants.ImagePath.DropDownArrow, HorizontalOptions = LayoutOptions.EndAndExpand }; Label lblCurrentDate = new Label { TextColor = Color.Black, Text = DateTime.Now.ToString("dd-MM-yy") }; DatePicker dtTimePicker = new DatePicker { IsVisible = false }; StackLayout slSelectMonthDisplay = new StackLayout { Children = { lblCurrentDate, dtTimePicker, imgStartDateDropDown }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 5, 0), Device.OnPlatform(0, 10, 0), Device.OnPlatform(0, 5, 0)) }; Frame frmSelectMonth = new Frame { Content = slSelectMonthDisplay, HorizontalOptions = LayoutOptions.FillAndExpand, OutlineColor = Color.Black, Padding = new Thickness(10) }; var dateTimePickerTap = new TapGestureRecognizer(); dateTimePickerTap.NumberOfTapsRequired = 1; // single-tap dateTimePickerTap.Tapped += (s, e) => { dtTimePicker.Focus(); }; frmSelectMonth.GestureRecognizers.Add(dateTimePickerTap); slSelectMonthDisplay.GestureRecognizers.Add(dateTimePickerTap); StackLayout slStartDateFrmaeLayout = new StackLayout { Children = { frmSelectMonth } }; StackLayout slStartDateLayout = new StackLayout { Children = { slStartDateFrmaeLayout }, Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = false }; StackLayout slSearchinOneCol = new StackLayout { Children = { slStandardLayout, slClassLayout }, Orientation = StackOrientation.Horizontal }; StackLayout slSearchLayout = new StackLayout { Padding = new Thickness(0, 0, 0, 10), Children = { slStartDateLayout } }; _NotAvailData = new Label { Text = "No data availalble for this search data.", TextColor = Color.Red, IsVisible = false }; _Loader = new LoadingIndicator(); //List view ListView FillUpAttendanceListView = new ListView { RowHeight = 50, SeparatorColor = Color.Gray }; FillUpAttendanceListView.ItemsSource = Items; FillUpAttendanceListView.ItemTemplate = new DataTemplate(() => new FillUpAttendanceCell()); //Grid Header Layout Label lblAttendance = new Label { Text = "Attendance", TextColor = Color.Black }; StackLayout slAttendance = new StackLayout { Children = { lblAttendance }, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; Label lblStudent = new Label { Text = "Student", TextColor = Color.Black }; StackLayout slStudentName = new StackLayout { Children = { lblStudent }, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand }; Label lblIsPresent = new Label { Text = "A/P", TextColor = Color.Black }; StackLayout slExamMarks = new StackLayout { Children = { lblIsPresent }, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.EndAndExpand }; StackLayout grid = new StackLayout { Children = { slStudentName, slAttendance, slExamMarks }, Orientation = StackOrientation.Horizontal, IsVisible = false }; Seperator spDisplayHeader = new Seperator { IsVisible = false }; Button btnSave = new Button { IsVisible = false }; btnSave.Text = "Save"; btnSave.TextColor = Color.White; btnSave.BackgroundColor = LayoutHelper.ButtonColor; //Stanndard Picker Selected pcrStandard.SelectedIndexChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async() => { try { _Loader.IsShowLoading = true; btnSave.IsVisible = false; pcrClass.Items.Clear(); lblCurrentDate.Text = DateTime.Now.ToString("dd-MM-yy"); string standardName = lblStandard.Text = pcrStandard.Items[pcrStandard.SelectedIndex]; _SelectedStandardID = _StandardList.Where(x => x.Name == standardName).FirstOrDefault().Id; _ClassTypeList = await ClassTypeModel.GetClassType(_SelectedStandardID); if (_ClassTypeList.Count > 0 && _ClassTypeList != null) { slClassLayout.IsVisible = true; _NotAvailData.IsVisible = false; } else { slClassLayout.IsVisible = false; _NotAvailData.IsVisible = true; } foreach (ClassTypeModel item in _ClassTypeList) { pcrClass.Items.Add(item.Name); } _Loader.IsShowLoading = false; } catch (Exception ex) { } }); }; //Class Picker Selected pcrClass.SelectedIndexChanged += (sender, e) => { Device.BeginInvokeOnMainThread(async() => { _Loader.IsShowLoading = true; btnSave.IsVisible = false; Items.Clear(); lblCurrentDate.Text = DateTime.Now.ToString("dd-MM-yy"); string className = lblClass.Text = pcrClass.Items[pcrClass.SelectedIndex]; _SelectedClassTypeID = _ClassTypeList.FirstOrDefault(x => x.Name == className).Id; slStartDateLayout.IsVisible = true; _Loader.IsShowLoading = false; }); }; //dtTimePicker.Unfocused += (sender, e) => //{ // if (lblCurrentDate.Text == "Date") // { // lblCurrentDate.Text = DateTime.Now.ToString("dd-MM-yy"); // } //}; dtTimePicker.DateSelected += (sender, e) => { try { Device.BeginInvokeOnMainThread(async() => { _Loader.IsShowLoading = true; btnSave.IsVisible = false; lblCurrentDate.Text = dtTimePicker.Date.ToString("dd-MM-yy"); int dateCounter = dtTimePicker.Date.ConvetDatetoDateCounter(); //get student list _FillUpAttendanceModel = await FillUpAttendanceModel.GetFillUpAttendance(_SelectedStandardID, _SelectedClassTypeID, dateCounter); if (_FillUpAttendanceModel.Students != null) { Items = new ObservableCollection <Student>(_FillUpAttendanceModel.Students); if (Items.Count > 0 && Items != null) { FillUpAttendanceListView.ItemsSource = Items; grid.IsVisible = true; btnSave.IsVisible = true; spDisplayHeader.IsVisible = true; _NotAvailData.IsVisible = false; } else { grid.IsVisible = false; spDisplayHeader.IsVisible = false; btnSave.IsVisible = false; _NotAvailData.IsVisible = true; } } else { grid.IsVisible = false; spDisplayHeader.IsVisible = false; _NotAvailData.IsVisible = true; btnSave.IsVisible = false; } _Loader.IsShowLoading = false; }); } catch (Exception ex) { grid.IsVisible = false; spDisplayHeader.IsVisible = false; _NotAvailData.IsVisible = true; btnSave.IsVisible = false; _Loader.IsShowLoading = false; } }; btnSave.Clicked += (sender, e) => { Device.BeginInvokeOnMainThread(async() => { try { btnSave.IsVisible = false; _Loader.IsShowLoading = true; FillUpAttendanceModel fillupAttendanceModel = new FillUpAttendanceModel(); fillupAttendanceModel.StandardId = _SelectedStandardID; fillupAttendanceModel.ClassTypeId = _SelectedClassTypeID; fillupAttendanceModel.Date = Convert.ToDateTime(lblCurrentDate.Text).ToString("dd/MM/yyyy"); fillupAttendanceModel.Students = Items.ToList(); bool isSaveAttendance = await FillUpAttendanceModel.SaveStudentAttendance(fillupAttendanceModel); if (isSaveAttendance) { await DisplayAlert(string.Empty, "Save Successfully.", Messages.Ok); //_StudentAttendanceList = await StudentAttendanceModel.GetStudentAttendance(_SelectedBatchID, 9); //if (_StudentAttendanceList.Count > 0) //{ // _NotAvailData.IsVisible = false; // Items = new ObservableCollection<StudentAttendanceModel>(_StudentAttendanceList); // if (Items.Count > 0) // { // int noCount = 1; // for (int i = 0; i < Items.Count; i++) // { // Items[i].IndexNo = noCount; // noCount++; // } // grid.IsVisible = true; // _Loader.IsShowLoading = false; // _NotAvailLecture.IsVisible = false; // studentAttendanceListView.ItemsSource = Items; // } // else // { // grid.IsVisible = false; // _Loader.IsShowLoading = false; // _NotAvailLecture.IsVisible = true; // } //} } else { await DisplayAlert(Messages.Error, "Some problem ocuured when saving data.", Messages.Ok); } _Loader.IsShowLoading = false; } catch (Exception ex) { btnSave.IsVisible = true; _Loader.IsShowLoading = false; } }); }; var cvBtnSave = new ContentView { Padding = new Thickness(10, 5, 10, 10), Content = btnSave }; StackLayout slViewAttendance = new StackLayout { Children = { new StackLayout { Padding = new Thickness(20, Device.OnPlatform(40, 20, 0), 20, 20), Children = { slTitle, spTitle.LineSeperatorView, slSearchinOneCol, slSearchLayout, grid, spDisplayHeader.LineSeperatorView, _Loader, _NotAvailData, FillUpAttendanceListView, cvBtnSave }, VerticalOptions = LayoutOptions.FillAndExpand, }, }, BackgroundColor = LayoutHelper.PageBackgroundColor }; Content = new ScrollView { Content = slViewAttendance, }; }
private async void btnOK_Click(object sender, RoutedEventArgs e) { #region 新增 if (Om == OperationMode.AddMode) { string strErrorMsg = string.Empty; try { ClassTypeModel newClassTypeModel = new ClassTypeModel(); newClassTypeModel.Name = txtName.Text.Trim(); newClassTypeModel.TotalLessons = Convert.ToInt16(numTotal.Value); newClassTypeModel.UnitPrice = Convert.ToInt16(numPrice.Value); newClassTypeModel.StudentLimit = Convert.ToInt16(numStuLimit.Value); newClassTypeModel.TeacherRate = Convert.ToDouble(numTeacherRate.Value); newClassTypeModel.AssistantRate = Convert.ToDouble(numAssistantRate.Value); newClassTypeModel.ConsultantRate = Convert.ToDouble(numConsultantRate.Value); newClassTypeModel.Des = txtRemark.Text.Trim(); newClassTypeModel.IsActive = true; newClassTypeModel = await classTypeAsyncProxy.CallAsync(c => c.Add(newClassTypeModel)); this.ShowAutoCloseDialogOwter(UIResources.MsgInfo, "新增班级类型成功!"); 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 { selectClassType.TotalLessons = Convert.ToInt16(numTotal.Value); selectClassType.UnitPrice = Convert.ToInt16(numPrice.Value); selectClassType.StudentLimit = Convert.ToInt16(numStuLimit.Value); selectClassType.TeacherRate = Convert.ToDouble(numTeacherRate.Value); selectClassType.AssistantRate = Convert.ToDouble(numAssistantRate.Value); selectClassType.ConsultantRate = Convert.ToDouble(numConsultantRate.Value); selectClassType.Des = txtRemark.Text.Trim(); selectClassType.IsActive = true; selectClassType = await classTypeAsyncProxy.CallAsync(c => c.Update(selectClassType)); this.ShowAutoCloseDialogOwter(UIResources.MsgInfo, "修改班级类型成功!"); 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 }
/// <summary> /// 将实时考勤数据转移至本月数据表中 /// </summary> /// <returns></returns> public OpResult TransimitAttendDatas(DateTime qryDate) { qryDate = qryDate.ToDate(); //处理总记录数 int totalRecord = 0, record = 0; var datasInTime = this.fingerPrintDataInTime.FingPrintDatas.FindAll(e => e.SlodCardDate == qryDate); if (datasInTime == null || datasInTime.Count == 0) { return(OpResult.SetErrorResult("没有考勤数据要进行汇总")); } AttendanceDbHelpHandler.BackupData(datasInTime); //一次载入该日期的所有考勤数据到内存中 var dayAttendDatas = this.irep.Entities.Where(e => e.AttendanceDate == qryDate); //获取所有人员信息到内存中 var workers = AttendanceDbHelpHandler.GetWorkerInfos(); var departments = AttendanceDbHelpHandler.GetDepartmentDatas(); //中间时间 DateTime middleTime = new DateTime(qryDate.Year, qryDate.Month, qryDate.Day, 13, 0, 0); //处理实时考勤数据 ArWorkerInfo worker = null; //将考勤中数据中的人进行分组 List <string> attendWorkerIdList = datasInTime.Select(e => e.WorkerId).Distinct().ToList(); ClassTypeModel ctmdl = null; DepartmentModel depm = null; attendWorkerIdList.ForEach(workerId => { record = 0; //获取每个人的信息 worker = workers.FirstOrDefault(w => w.WorkerId == workerId); if (worker == null) { var m = ArchiveService.ArchivesManager.WorkerIdChangeManager.GetModel(workerId); if (m != null) { worker = workers.FirstOrDefault(w => w.WorkerId == m.NewWorkerId); } } //从实时考勤数据表中获取该员工的考勤数据 var attendDataPerWorker = datasInTime.FindAll(f => f.WorkerId == workerId).OrderBy(o => o.SlodCardTime).ToList(); var currentAttendData = dayAttendDatas.FirstOrDefault(e => e.WorkerId == workerId);//从内存中进行查找 if (worker != null) { ctmdl = AttendanceDbHelpHandler.GetClassType(workerId, qryDate); depm = departments.FirstOrDefault(d => d.DataNodeName == worker.Department); worker.ClassType = ctmdl == null ? "白班" : ctmdl.ClassType; worker.Department = depm == null ? worker.Department : depm.DataNodeText; int len = attendDataPerWorker.Count; for (int i = 0; i < len; i++) { var attendance = attendDataPerWorker[i]; //如果考勤数据表没有该人员的考勤数据 if (currentAttendData == null) { //则初始化考勤数据 record += InitAttendData(attendance, worker, attendance.SlodCardTime, out currentAttendData, middleTime); } else { //反之则合并数据 record += MergeAttendTime(currentAttendData, attendance.SlodCardTime); } } if (record == len)//如果处理记录与目标数量一致则进行备份数据 { this.fingerPrintDataInTime.BackupData(attendDataPerWorker, record); //从内存中移除数据,减少查询时间 //workers.Remove(worker); //从内存中移除该人员的考勤数据,减少查询时间 attendDataPerWorker.ForEach(m => datasInTime.Remove(m)); totalRecord += record; } } else { this.fingerPrintDataInTime.StoreNoIdentityWorkerInfo(attendDataPerWorker[0]); } }); return(OpResult.SetSuccessResult("处理考勤数据成功!", record > 0)); }