Ejemplo n.º 1
0
        void saveCommand(object obj)
        {
            var win = obj as CreateMasterApprentticeWindow;

            var has = this.Apprentices.Any(a => a.IsChecked);

            if (!has)
            {
                this.ShowDialog("提示信息", "没有选中徒弟!", CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning);
                return;
            }

            var results            = new List <UIMasterApprenttice>();
            var checkedApprenttics = this.Apprentices.Where(a => a.IsChecked)?.ToList();

            checkedApprenttics?.ForEach(ca =>
            {
                var masterApprenttice = new UIMasterApprenttice()
                {
                    Master        = this.SelectMaster.Name,
                    MasterID      = this.SelectMaster.ID,
                    ApprentticeID = ca.ID,
                    Apprenttice   = ca.Name,
                    Course        = this.SelectCourse.Name,
                    CourseID      = this.SelectCourse.ID,
                    FollowMode    = this.SelectMasterType,
                };
                results.Add(masterApprenttice);
            });

            win.Rules        = results;
            win.DialogResult = true;
        }
        public void Initilize()
        {
            this.Comments = CommonDataManager.GetAdminRuleComments(AdministrativeRuleEnum.MasterApprenttice);

            Messenger.Default.Register <HostView>(this, save);

            var cp   = CommonDataManager.GetCPCase(base.LocalID);
            var rule = CommonDataManager.GetAminRule(base.LocalID);

            rule.MasterApprenttices.ForEach(m =>
            {
                var course = cp.Courses.FirstOrDefault(c => c.ID.Equals(m.CourseID));
                var master = cp.Teachers.FirstOrDefault(t => t.ID.Equals(m.MasterID));

                UIMasterApprenttice uirule = new UIMasterApprenttice();
                uirule.CourseID            = m.CourseID;
                uirule.MasterID            = m.MasterID;
                uirule.Master        = master?.Name;
                uirule.Course        = course?.Name;
                uirule.ApprentticeID = cp.GetTeachersByIds(m.ApprenticeIDs);
                uirule.Weight        = (Models.Enums.WeightTypeEnum)m.Weight;

                this.Rules.Add(uirule);
            });
        }
        private void Dg_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            UIMasterApprenttice masterApprenttice = e.Row.DataContext as UIMasterApprenttice;

            if (masterApprenttice != null)
            {
                masterApprenttice.IsChecked = true;
            }
        }