Esempio n. 1
0
 public MainForm()
 {
     InitializeComponent();
     mainController = new Controller();
     mainDataStorage = DataStorage.get();
     mainController.registerSalon(DEFAULT_SALON_ADRESS, DEFAULT_SALON_NAME);
     this.Text = "Управление салоном \"" + mainDataStorage.getSalon().name + "\" (" + mainDataStorage.getSalon().address + ")";
     showPanel(0);
 }
Esempio n. 2
0
 public MainForm()
 {
     InitializeComponent();
     mainController  = new Controller();
     mainDataStorage = DataStorage.get();
     mainController.registerSalon(DEFAULT_SALON_ADRESS, DEFAULT_SALON_NAME);
     this.Text = "Управление салоном \"" + mainDataStorage.getSalon().name + "\" (" + mainDataStorage.getSalon().address + ")";
     showPanel(0);
 }
Esempio n. 3
0
        /// <summary>
        /// Проводит создание и начальную подготовку объекта класса Master
        /// </summary>
        /// <param name="targetMaster">экземпляр объекта, сгенерированный в интерфейсе</param>
        public void registerMaster(string name, int salary, List <String> serviceNames)
        {
            Debug.WriteLine("Запущен registerMaster");
            List <Service> finalServiceList = new List <Service>();

            Debug.WriteLine("Количество названий услуг, полученных контроллером " + serviceNames.Count);
            foreach (String serviceName in serviceNames)
            {
                Service targetService = getService(serviceName);
                if (targetService == null)
                {
                    Debug.WriteLine("Запись не найдена при создании мастера");
                }
                else
                {
                    finalServiceList.Add(targetService);
                }
                targetService = null;
            }
            Master master = mainDataStorage.newMaster(name, salary);

            mainDataStorage.getSalon().addMaster(master);

            foreach (Service finalService in finalServiceList)
            {
                master.addService(finalService);
                finalService.addMaster(master);
                Debug.WriteLine("Добавили услугу " + finalService.name + " мастеру " + master.name);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Возвращает список часов, свободных для записи
        /// </summary>
        /// <param name="day">Дата, для которой ищутся свободные часы</param>
        public List <int> getFreeHours(DateTime day)
        {
            mainDataStorage = DataStorage.get();
            List <int> fullHours = new List <int>();
            List <int> freeHours = new List <int>();

            foreach (Record record in recordList)
            {
                if (record.day == day)
                {
                    fullHours.Add(record.hour);
                }
            }
            for (int hour = mainDataStorage.getSalon().openHour; hour <= mainDataStorage.getSalon().closeHour; hour++)
            {
                if (!fullHours.Contains(hour))
                {
                    freeHours.Add(hour);
                }
            }
            return(freeHours);
        }
Esempio n. 5
0
        private void toolStripButtonLoad_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("Запущена загрузка");
            DataStorage data;

            try
            {
                using (Stream fStream = File.OpenRead(DATASTORAGE_FILE_NAME))
                {
                    try
                    {
                        BinaryFormatter binFormat = new BinaryFormatter();
                        data = (DataStorage)binFormat.Deserialize(fStream);
                        DataStorage.set(data);
                        statusStripLabel.Text = "Загрузка информации для салона " + "\"" + mainDataStorage.getSalon().name + "\" успешно завершена";
                    }
                    catch (SerializationException ex)
                    {
                        Debug.WriteLine("Не удалось провести сериализацию - " + ex.Message);
                        throw;
                    }
                    finally
                    {
                        fStream.Close();
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                Debug.WriteLine("Не найден " + DATASTORAGE_FILE_NAME + " - " + ex.Message);
                MessageBox.Show("Файл с данными не найден", "Ошибка", MessageBoxButtons.OK);
            }
            catch (IOException ex)
            {
                Debug.WriteLine("Ошибка ввода/вывода - " + ex.Message);
                MessageBox.Show("Ошибка программы при работе с файлом данных " + DATASTORAGE_FILE_NAME, "Ошибка", MessageBoxButtons.OK);
            }

            textBoxMasterSearch.Text  = "";
            textBoxServiceSearch.Text = "";
            textBoxRecordSearch.Text  = "";
            textBoxClientSearch.Text  = "";
            textBoxMasterSearch_TextChanged(sender, e);
            textBoxServiceSearch_TextChanged(sender, e);
            textBoxRecordSearch_TextChanged(sender, e);
            textBoxClientSearch_TextChanged(sender, e);
            this.Text = "Управление салоном \"" + mainDataStorage.getSalon().name + "\" (" + mainDataStorage.getSalon().address + ")";
        }
Esempio n. 6
0
 private void buttonCreateReport_Click(object sender, EventArgs e)
 {
     if (monthCalendarReport.SelectionStart != null && monthCalendarReport.SelectionEnd != null)
     {
         DataStorage   dataStorage = DataStorage.get();
         List <String> salonReport;
         salonReport = dataStorage.getSalon().getStatistics(monthCalendarReport.SelectionStart, monthCalendarReport.SelectionEnd);
         try
         {
             System.IO.File.WriteAllLines(AppDomain.CurrentDomain.BaseDirectory + "salonStatistic.htm", salonReport);
         }
         catch (Exception exception)
         {
             MessageBox.Show("Ошибка сохранения отчета - " + exception.Message, "Ошибка сохранения", MessageBoxButtons.OK);
         }
         System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + "salonStatistic.htm");
         this.Close();
     }
 }