Ejemplo n.º 1
0
        public Setting()
        {
            LVIP = new List<FixedClasses>();
            Repo = new MockDataBase.MockRepository();
            Repo.Init(null);
            //Repo = new Data.DataRepository();
            //Repo.Init(new string[] { @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=C:\USERS\СЕРГЕЙ\DOCUMENTS\ESPROJECT\ESPROJECT\BIN\DEBUG\BD4.MDF;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" });

            //storage = DataConvertor.ConvertData(Repo.GetTeachers(), Repo.GetStudentsGroups(), Repo.GetClassRoomsTypes(), Repo.GetClassRooms(), Repo.GetStudentsClasses());
            storage = CurrentBase.EStorage;
            this.Clases = storage.Classes;
            LVIPB = new List<VIPClasesBin>();
            BinaryFormatter formatter = new BinaryFormatter();

            if (File.Exists("Setting.dat"))
            {

                using (FileStream fs = new FileStream("Setting.dat", FileMode.OpenOrCreate))
                {
                    LVIPB = (List<VIPClasesBin>)formatter.Deserialize(fs);
                }

                foreach (var item in LVIPB)
                {
                    FixedClasses n = new FixedClasses(Clases[item.Cla], item.Time, storage.ClassRooms[item.Aud]);
                    LVIP.Add(n);
                }

            }
        }
Ejemplo n.º 2
0
        public Setting(EntityStorage storage, StudentsClass[] Clases)
        {
            LVIP = new List<FixedClasses>();
            LVIPB = new List<VIPClasesBin>();
            this.storage = storage;
            this.Clases = Clases;
            BinaryFormatter formatter = new BinaryFormatter();

            if (File.Exists("Setting.dat"))
            {

                using (FileStream fs = new FileStream("Setting.dat", FileMode.OpenOrCreate))
                {
                    LVIPB = (List<VIPClasesBin>)formatter.Deserialize(fs);
                }

                foreach (var item in LVIPB)
                {
                    FixedClasses n = new FixedClasses(Clases[item.Cla], item.Time, storage.ClassRooms[item.Aud]);
                    LVIP.Add(n);
                }

            }
        }
Ejemplo n.º 3
0
        private async void AddClasses()
        {
            try
            {
                int timeIndex = -1;

                StudentsClass sClass;
                sClass = (StudentsClass)ClasseslistBox.SelectedItem;
                ClassRoom classRoom;
                if (UpperWeekradioButton.IsChecked == true && TimecomboBox.SelectedIndex !=-1 && DaycomboBox.SelectedIndex != -1)
                {
                    timeIndex = 0;
                    timeIndex += DaycomboBox.SelectedIndex * 6;
                    timeIndex += TimecomboBox.SelectedIndex;
                }
                if (LowerWeekradioButton.IsChecked == true && TimecomboBox.SelectedIndex != -1 && DaycomboBox.SelectedIndex != -1)
                {
                    timeIndex = 0;
                    timeIndex += 36;
                    timeIndex += DaycomboBox.SelectedIndex * 6;
                    timeIndex += TimecomboBox.SelectedIndex;
                }
                classRoom = (ClassRoom)ClassRoomlistView.Items[0];
                bool freeClassroom = true, existAddClassInLVIP = false;
                foreach (var item in settings)
                {
                    //Проверка не занята ли аудитория в это время
                    if (item.Room == classRoom && item.Time == timeIndex)
                    { freeClassroom = false; break; }
                }
                if (sClass != null && classRoom != null && timeIndex != -1)
                {
                    if (freeClassroom)
                    {
                        foreach (var item in settings)
                        {

                            if (item.sClass == sClass)
                            {
                                item.Room = classRoom;
                                item.Time = timeIndex;
                                existAddClassInLVIP = true;
                                var infoWindow = new InfoWindow
                                {
                                    Message = { Text = "Пара зафиксирована" }
                                };

                                await DialogHost.Show(infoWindow, "VIPHost");
                            }

                        }
                        if (!existAddClassInLVIP)
                        {
                            FixedClasses vi = new FixedClasses(sClass, timeIndex, classRoom);
                            settings.Add(vi);
                            var infoWindow = new InfoWindow
                            {
                                Message = { Text = "Пара зафиксирована" }
                            };

                            await DialogHost.Show(infoWindow, "VIPHost");
                        }
                    }
                    else
                    {
                        var infoWindow = new InfoWindow
                        {
                            Message = { Text = "В это время в этой аудитории уже стоит пара" }
                        };

                        await DialogHost.Show(infoWindow, "VIPHost");
                    }
                }
            }
            catch
            {

            }
        }
Ejemplo n.º 4
0
        private void AddClasses(object sender, RoutedEventArgs e)
        {
            try
            {
                int timeIndex = -1;

                StudentsClass sClass;
                sClass = (StudentsClass)ClasseslistBox.SelectedItem;
                ClassRoom classRoom;
                if (UpperWeekradioButton.IsChecked == true)
                {
                    timeIndex = 0;
                    timeIndex += DaycomboBox.SelectedIndex * 6;
                    timeIndex += TimecomboBox.SelectedIndex;
                }
                if (LowerWeekradioButton.IsChecked == true)
                {
                    timeIndex = 0;
                    timeIndex += 36;
                    timeIndex += DaycomboBox.SelectedIndex * 6;
                    timeIndex += TimecomboBox.SelectedIndex;
                }
                classRoom = (ClassRoom)ClassRoomlistView.Items[0];
                bool freeClassroom = true, existAddClassInLVIP = false;
                foreach (var item in setting.LVIP)
                {
                    //Проверка не занята ли аудитория в это время
                    if (item.Room == classRoom && item.Time == timeIndex)
                    { freeClassroom = false; break; }
                }
                if (sClass != null)
                {
                    if (classRoom != null && timeIndex != -1)
                    {
                        if (freeClassroom)
                        {
                            foreach (var item in setting.LVIP)
                            {

                                if (item.sClass == sClass)
                                {
                                    item.Room = classRoom;
                                    item.Time = timeIndex;
                                    existAddClassInLVIP = true;
                                    MessageBox.Show("Всё ок");
                                }

                            }
                        }
                        else { MessageBox.Show("В это время в этой аудитории уже стоит пара"); }

                        if (freeClassroom)
                        {
                            if (!existAddClassInLVIP)
                            {
                                FixedClasses vi = new FixedClasses(sClass, timeIndex, classRoom);
                                setting.LVIP.Add(vi);
                                MessageBox.Show("Всё ок");
                            }

                        }
                        else { MessageBox.Show("В это время в этой аудитории уже стоит пара"); }

                    }
                }
                setting.LVIPB = new List<VIPClasesBin>();
                foreach (var item in setting.LVIP)
                {
                    VIPClasesBin vipClasesBin =
                        new VIPClasesBin(Array.FindIndex(CurrentBase.EStorage.Classes, c => c == item.sClass), item.Time, Array.FindIndex(CurrentBase.EStorage.ClassRooms, c => c == item.Room));
                    setting.LVIPB.Add(vipClasesBin);

                }
                BinaryFormatter formatter = new BinaryFormatter();
                using (FileStream fs = new FileStream("Setting.dat", FileMode.Create))
                {
                    formatter.Serialize(fs, setting.LVIPB);
                }
            }
            catch
            {

            }
        }