public ClassViewModel(int _id)
        {
            LoadGrades();
            _className = DataProvider.Ins.DB.classes.Where(x => x.id == _id).ToArray()[0].name;
            int IdGrade = DataProvider.Ins.DB.classes.Where(x => x.id == _id).ToArray()[0].id_grade;

            GradeName   = DataProvider.Ins.DB.grades.Where(x => x.id == IdGrade).ToArray()[0].name;
            SaveCommand = new RelayCommand <Window>((p) => { return(true); },
                                                    async(p) =>
            {
                EditClass w    = p as EditClass;
                var mySettings = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Ok",
                    ColorScheme           = w.MetroDialogOptions.ColorScheme
                };
                @class EditingClass   = DataProvider.Ins.DB.classes.Where(x => x.id == w.Id).ToArray()[0];
                EditingClass.name     = _className;
                EditingClass.id_grade = DataProvider.Ins.DB.grades.Where(x => x.name == _gradeName).ToArray()[0].id;
                if (DataProvider.Ins.DB.classes.Where(x => x.name == EditingClass.name && x.id_grade == EditingClass.id_grade).FirstOrDefault() != null)
                {
                    await w.ShowMessageAsync("Hello!", "The class is exist.", MessageDialogStyle.Affirmative, mySettings);
                    return;
                }
                DataProvider.Ins.DB.SaveChanges();
                await w.ShowMessageAsync("Hello!", "Saved success.", MessageDialogStyle.Affirmative, mySettings);
                LoadData();
                EnrollViewModel.LoadClasses();
                w.Close();
            });
        }
예제 #2
0
            protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam)
            {
                switch (message)
                {
                case MessageType.Create:
                    _editClass = new EditClass(EditStyles.Multiline | EditStyles.Left
                                               | EditStyles.AutoHorizontalScroll | EditStyles.AutoVerticalScroll);
                    _editHandle = _editClass.CreateWindow(
                        style: WindowStyles.Child | WindowStyles.Visible | WindowStyles.HorizontalScroll
                        | WindowStyles.VerticalScroll | WindowStyles.Border,
                        parentWindow: window);
                    return(0);

                case MessageType.SetFocus:
                    _editHandle.SetFocus();
                    return(0);

                case MessageType.Size:
                    var size = new Message.Size(wParam, lParam);
                    _editHandle.MoveWindow(new Rectangle(new Point(), size.NewSize), repaint: true);
                    return(0);
                }

                return(base.WindowProcedure(window, message, wParam, lParam));
            }
예제 #3
0
 public void Save()
 {
     if (EditorStatus != EditorStatus.NoChanged)
     {
         EditClass.SaveClassRecordEditor(new ClassRecordEditor[] { this });
     }
 }
예제 #4
0
        public override void Trigger(object sender, MouseEventArgs e, Invoker invoker)
        {
            Symbol foundSymbol = TargetDrawing.FindSymbolAtPosition(e.Location);

            if (foundSymbol == null)
            {
            }
            else if (foundSymbol.type == "Class")
            {
                ClassSymbol foundClass      = foundSymbol as ClassSymbol;
                EditClass   editClassWindow = new EditClass(foundClass, TargetDrawing, invoker);
                editClassWindow.Show();
            }
            else if (foundSymbol.type == "Binary")
            {
                BinaryRelationship foundBinary      = foundSymbol as BinaryRelationship;
                EditBinary         editBinaryWindow = new EditBinary(foundBinary, TargetDrawing, invoker);
                editBinaryWindow.Show();
            }
            else
            {
                Relationship foundLine      = foundSymbol as Relationship;
                EditLine     editLineWindow = new EditLine(foundLine, invoker, TargetDrawing);
                editLineWindow.Show();
            }
        }
예제 #5
0
        private void _btnEditClass_Click(object sender, RoutedEventArgs e)
        {
            var selected = _datagridClasses.SelectedItem;

            if (selected == null)
            {
                MessageBox.Show("هیچ موردی انتخاب نشده", "پیغام", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else
            {
                Class     cl  = (Class)selected;
                EditClass win = new EditClass(cl);
                win.ShowDialog();
                _datagridClasses.ItemsSource = db.Classes.ToList();
            }
        }
예제 #6
0
        void btn_Click(object sender, EventArgs e)
        {
            if (SmartSchool.ClassRelated.Class.Instance.SelectionClasses.Count > 0)
            {
                string ErrorMessage = "";
                try
                {
                    //var ID = "" + ( (MenuButton)sender ).Tag;
                    var         info   = ((MenuButton)sender).Tag as GraduationPlanInfo;
                    var         ID     = info.ID;
                    DSXmlHelper helper = new DSXmlHelper("UpdateRequest");
                    helper.AddElement("Class");
                    helper.AddElement("Class", "Field");
                    helper.AddElement("Class/Field", "RefGraduationPlanID", ID);
                    helper.AddElement("Class", "Condition");
                    foreach (ClassInfo classinfo in SmartSchool.ClassRelated.Class.Instance.SelectionClasses)
                    {
                        helper.AddElement("Class/Condition", "ID", classinfo.ClassID);
                    }
                    EditClass.Update(new DSRequest(helper));

                    //log
                    foreach (ClassInfo classinfo in SmartSchool.ClassRelated.Class.Instance.SelectionClasses)
                    {
                        CurrentUser.Instance.AppLog.Write(
                            SmartSchool.ApplicationLog.EntityType.Class,
                            "指定班級課程規劃",
                            classinfo.ClassID,
                            string.Format("指定「{0}」採用課程規劃:{1}", classinfo.ClassName, info.Name),
                            "班級",
                            string.Format("班級ID: {0},課程規劃ID: {1}", classinfo.ClassID, ID));
                    }
                }
                catch
                {
                    GraduationPlan.GraduationPlan.Instance.LoadClassReference();
                    EventHub.Instance.InvokeClassReferenceGranduationPlanChanged();
                    MsgBox.Show("設定班級課程規劃表發生錯誤。");
                    return;
                }
                GraduationPlan.GraduationPlan.Instance.LoadClassReference();
                EventHub.Instance.InvokeClassReferenceGranduationPlanChanged();
                //MsgBox.Show("課程規劃表設定完成");
            }
        }
예제 #7
0
        void item_Click(object sender, EventArgs e)
        {
            if (SmartSchool.ClassRelated.Class.Instance.SelectionClasses.Count > 0)
            {
                try
                {
                    MenuButton  item   = sender as MenuButton;
                    DSXmlHelper helper = new DSXmlHelper("UpdateRequest");
                    helper.AddElement("Class");
                    helper.AddElement("Class", "Field");
                    helper.AddElement("Class/Field", "RefScoreCalcRuleID", (item.Tag as ScoreCalcRuleInfo).ID);
                    helper.AddElement("Class", "Condition");
                    foreach (ClassInfo classinfo in SmartSchool.ClassRelated.Class.Instance.SelectionClasses)
                    {
                        helper.AddElement("Class/Condition", "ID", classinfo.ClassID);
                    }
                    EditClass.Update(new DSRequest(helper));

                    //log
                    foreach (ClassInfo classinfo in SmartSchool.ClassRelated.Class.Instance.SelectionClasses)
                    {
                        CurrentUser.Instance.AppLog.Write(
                            SmartSchool.ApplicationLog.EntityType.Class,
                            "指定班級計算規則",
                            classinfo.ClassID,
                            string.Format("指定「{0}」採用計算規則:{1}", classinfo.ClassName, (item.Tag as ScoreCalcRuleInfo).Name),
                            "班級",
                            string.Format("班級ID: {0},計算規則ID: {1}", classinfo.ClassID, (item.Tag as ScoreCalcRuleInfo).ID));
                    }
                }
                catch
                {
                    ScoreCalcRule.ScoreCalcRule.Instance.LoadClassReference();
                    EventHub.Instance.InvokeClassReferenceCaleRuleChanged();
                    MsgBox.Show("設定計算規則發生錯誤。");
                    return;
                }
                ScoreCalcRule.ScoreCalcRule.Instance.LoadClassReference();
                EventHub.Instance.InvokeClassReferenceCaleRuleChanged();
                //MsgBox.Show("計算規則設定完成");
            }
        }
        public ClassViewModel()
        {
            LoadGrades();
            AddClassCommand = new RelayCommand <UserControl>((p) => { return(true); },
                                                             async(p) =>
            {
                MetroWindow CurrentWindow = Application.Current.MainWindow as MetroWindow;
                var mySettings            = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Ok",
                    ColorScheme           = CurrentWindow.MetroDialogOptions.ColorScheme
                };

                var mySettings2 = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Yes",
                    NegativeButtonText    = "No",
                    ColorScheme           = CurrentWindow.MetroDialogOptions.ColorScheme
                };

                if (_className == null || _className == "")
                {
                    await CurrentWindow.ShowMessageAsync("Hello!", "Please fill in every blanks.", MessageDialogStyle.Affirmative, mySettings);
                    return;
                }

                if (_gradeName == null || _gradeName == "")
                {
                    await CurrentWindow.ShowMessageAsync("Hello!", "This grade doesn't exist.", MessageDialogStyle.Affirmative, mySettings);
                    return;
                }

                if (DataProvider.Ins.DB.grades.Where(x => x.name == _gradeName).Count() == 0)
                {
                    await CurrentWindow.ShowMessageAsync("Hello!", "This grade doesn't exist.", MessageDialogStyle.Affirmative, mySettings);
                    return;
                }

                MessageDialogResult mr = await CurrentWindow.ShowMessageAsync("Hello!", "Do you want to add class " + _className + " ?", MessageDialogStyle.AffirmativeAndNegative, mySettings2);
                if (mr == MessageDialogResult.Negative)
                {
                    return;
                }
                if (DataProvider.Ins.DB.classes.Where(x => x.name == this._className).Count() > 0)
                {
                    await CurrentWindow.ShowMessageAsync("Hello!", "This class existed.", MessageDialogStyle.Affirmative, mySettings);
                }
                else
                {
                    @class AddingClass   = new @class();
                    AddingClass.name     = this._className;
                    AddingClass.id_grade = DataProvider.Ins.DB.grades.Where(x => x.name == _gradeName).ToArray()[0].id;
                    DataProvider.Ins.DB.classes.Add(AddingClass);
                    DataProvider.Ins.DB.SaveChanges();
                    await CurrentWindow.ShowMessageAsync("Hello!", "Added successfully.", MessageDialogStyle.Affirmative, mySettings);
                }
                LoadData();
                EnrollViewModel.LoadClasses();
                ReportViewModel.LoadClass();
            });



            EditCommand = new RelayCommand <Button>((p) => { return(true); },
                                                    (p) =>
            {
                int id = Convert.ToInt32(p.Tag);
                EditClass editClass = new EditClass(id);
                editClass.ShowDialog();
            });

            DeleteCommand = new RelayCommand <int>((p) => { return(true); },
                                                   async(p) =>
            {
                MetroWindow CurrentWindow = Application.Current.MainWindow as MetroWindow;
                var mySettings            = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Ok",
                    ColorScheme           = CurrentWindow.MetroDialogOptions.ColorScheme
                };
                var mySettings2 = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Yes",
                    NegativeButtonText    = "No",
                    ColorScheme           = CurrentWindow.MetroDialogOptions.ColorScheme
                };

                MessageDialogResult mr = await CurrentWindow.ShowMessageAsync("Hello!", "Do you really want to delete this class?", MessageDialogStyle.AffirmativeAndNegative, mySettings2);
                if (mr == MessageDialogResult.Affirmative)
                {
                    @class DeletingClass = DataProvider.Ins.DB.classes.Where(x => x.id == p).ToArray()[0];
                    DataProvider.Ins.DB.classes.Remove(DeletingClass);
                    DataProvider.Ins.DB.SaveChanges();
                    await CurrentWindow.ShowMessageAsync("Hello!", "Deleted successfully.", MessageDialogStyle.Affirmative, mySettings);
                    LoadData();
                    EnrollViewModel.LoadClasses();
                }
            });
            SearchCommand = new RelayCommand <String>((p) => { return(true); },
                                                      (p) =>
            {
                if (p == null)
                {
                    return;
                }
                List <@class> SearchedClass = DataProvider.Ins.DB.classes.Where <@class>(x => x.name.Contains(p)).Join(
                    DataProvider.Ins.DB.grades,
                    d => d.id_grade,
                    f => f.id,
                    (d, f) => d
                    ).ToList();
                LoadData(SearchedClass);
            });
            LoadData();
        }
예제 #9
0
 /// <summary>
 /// 儲存在集合中的所有班級資料。
 /// </summary>
 public static void SaveAllEditors(this IEnumerable <ClassRecordEditor> editors)
 {
     EditClass.SaveClassRecordEditor(editors);
 }