示例#1
0
        private void bEndWork_Click(object sender, RoutedEventArgs e)
        {
            repairerExecuteServices_Result currentRES = dbGridMyServiceExecution.SelectedItem as repairerExecuteServices_Result;

            if (currentRES == null)
            {
                MessageBox.Show("Заявка не выбрана");
            }
            else
            {
                Int32            RSid                = (currentRES).Id;
                requestedService currentRS           = core.serviceCenterDB.requestedServices.Where(rs => rs.Id == RSid).FirstOrDefault();
                Windows.serviceExecuteResultWindow w = new Windows.serviceExecuteResultWindow();
                w.ShowDialog();
                if (w.DialogResult == true)
                {
                    var rse = core.serviceCenterDB.servicesExecution.Where(se => se.requestedService.Id == RSid).FirstOrDefault();
                    rse.dateOfEnd = DateTime.Now;
                    rse.result    = w.Result;
                    rse.requestedService.stageOfImplementationId = 3;
                    core.serviceCenterDB.SaveChanges();
                    updateMyServiceExecution();
                }
            }
        }
        private void bEditService_Click(object sender, RoutedEventArgs e)
        {//обработчик кнопки "редактировать" услугу
            requestedService rs = dgServices.SelectedItem as requestedService;

            if (rs == null)
            {
                MessageBox.Show("выберите услугу");
            }
            else
            {
                Windows.ServicesWindow w = new ServicesWindow(rs);
                w.ShowDialog();
                if (w.DialogResult == true)              //если пользователь завершил ввод
                {
                    Contract.approximateCost -= rs.cost; //вычетаем прежнюю стоимость услуги
                    rs.service                 = w.Service;
                    rs.cost                    = w.Cost;
                    rs.description             = w.Description;
                    rs.stageOfImplementationId = 1;

                    Contract.approximateCost += w.Cost; //добавляем стоимость услуги к общей стоимости
                    tbApproximateEndCost.Text = Contract.approximateCost.ToString();
                    clientDevice currentDevice = rs.clientDevice;
                    updateDbGridService(ref currentDevice); //обновляем список услуг для данного устройства
                    controlBokEnable();
                    controlButtonsEnable();
                }
            }
        }
        private void bReplaceUpgrade_Click(object sender, RoutedEventArgs e)
        {
            requestedService currentRS = dgServices.SelectedItem as requestedService;

            if (currentRS == null)
            {
                MessageBox.Show("Услуга не выбрана");
            }
            else if (currentRS.service.name != "Замена модуля")
            {
                MessageBox.Show("Данная заявка не требует установки модулей");
            }
            else
            {
                List <upgradeReplacement> ur = core.serviceCenterDB.upgradesReplacements.Where(u => u.clientDeviceId == currentRS.clientDeviceId).ToList();

                {
                    Windows.replaceUpgradeModuleWindow w = new Windows.replaceUpgradeModuleWindow(ur, currentRS.clientDevice, null);
                    w.bAddModule.Visibility           = w.bSave.Visibility = Visibility.Collapsed;
                    w.bCancel.Content                 = "Закрыть";
                    w.dgModules.Columns[4].Visibility = Visibility.Collapsed;
                    w.ShowDialog();
                }
            }
        }
示例#4
0
        private void bReplaceUpgrade_Click(object sender, RoutedEventArgs e)
        {
            Int32            reqestedServiceID = (dbGridMyServiceExecution.SelectedItem as repairerExecuteServices_Result).Id;
            requestedService currentRS         = core.serviceCenterDB.requestedServices.Where(rs => rs.Id == reqestedServiceID).First();

            if (currentRS.service.name != "Замена модуля")
            {
                MessageBox.Show("Данная заявка не требует установки модулей");
            }
            else if (currentRS.stageOfImplementation.name == "Выполнено")
            {
                MessageBox.Show("Заявка уже выполнена");
            }
            else
            {
                List <upgradeReplacement> ur = core.serviceCenterDB.upgradesReplacements.Where(u => u.clientDeviceId == currentRS.clientDeviceId).ToList();
                if (ur.Count == 0)
                {
                    Windows.replaceUpgradeModuleWindow w = new Windows.replaceUpgradeModuleWindow(currentRS.clientDevice, currentUser);
                    w.ShowDialog();
                    if (w.DialogResult == true)
                    {
                        foreach (var i in w.UR)
                        {
                            core.serviceCenterDB.upgradesReplacements.Add(i);
                        }
                        core.serviceCenterDB.SaveChanges();
                    }
                }

                else
                {
                    Windows.replaceUpgradeModuleWindow w = new Windows.replaceUpgradeModuleWindow(ur, currentRS.clientDevice, currentUser);
                    w.ShowDialog();
                    if (w.DialogResult == true)
                    {
                        List <upgradeReplacement> urOrigin = core.serviceCenterDB.upgradesReplacements.Where(u => u.clientDeviceId == currentRS.clientDeviceId).ToList();
                        foreach (var i in urOrigin)
                        {
                            if (!ur.Contains(i))
                            {
                                core.serviceCenterDB.upgradesReplacements.Remove(i);
                            }
                        }

                        foreach (var i in w.UR)
                        {
                            var entry = core.serviceCenterDB.Entry(i);
                            if (entry.State == System.Data.Entity.EntityState.Detached)
                            {
                                core.serviceCenterDB.upgradesReplacements.Add(i);
                            }
                        }
                        core.serviceCenterDB.SaveChanges();
                    }
                }
            }
        }
        private void bShowExecution_Click(object sender, RoutedEventArgs e)
        {
            requestedService currentRS = dgServices.SelectedItem as requestedService;

            if (requestedServiceIsExecution(currentRS))
            {
                Windows.serviceExecutionWindow w = new serviceExecutionWindow(currentRS.servicesExecution.First());
                w.ShowDialog();
            }
        }
 public ServicesWindow(requestedService rs)
 {//конструктор для редактирования
     InitializeComponent();
     dgServices.ItemsSource = core.serviceCenterDB.services.ToList();
     //указываем источник данных для списка услуг
     bOk.IsEnabled           = false;
     dgServices.SelectedItem = rs.service;
     tbCost.Text             = rs.cost.ToString();
     tbDescription.Text      = rs.description;
     bOk.Content             = "Сохранить";
 }
 private void bDeleteSevice_Click(object sender, RoutedEventArgs e)
 {//Обработчик кнопки удалить услугу
     if (dgServices.SelectedItem != null)
     {
         clientDevice     currentdevice  = dgDevices.SelectedItem as clientDevice; //выбираем текущее устройство
         service          currentService = (dgServices.SelectedItem as requestedService).service;
         requestedService rs             = currentdevice.requestedServices.Where(r => r.service == currentService).FirstOrDefault();
         Contract.approximateCost -= rs.cost;
         currentdevice.requestedServices.Remove(rs);
         updateDbGridService(ref currentdevice);
         tbApproximateEndCost.Text = Contract.approximateCost.ToString();
         controlButtonsEnable();
     }
 }
        private void bReturnToRepairer_Click(object sender, RoutedEventArgs e)
        {
            requestedService currentRS = dgServices.SelectedItem as requestedService;

            if (requestedServiceIsExecution(currentRS))
            {
                currentRS.stageOfImplementationId = 2;
                currentRS.servicesExecution.First().dateOfEnd = null;
                core.serviceCenterDB.SaveChanges();
                MessageBox.Show("Возвращено в работу мастеру");
                clientDevice currentDevice = currentRS.clientDevice;
                updateDbGridService(ref currentDevice);
            }
        }
 private bool requestedServiceIsExecution(requestedService currentRS)
 {
     if (currentRS != null)
     {
         if (currentRS.servicesExecution.FirstOrDefault() != null)
         {
             return(true);
         }
         else
         {
             MessageBox.Show("Выполнение данной услуги еще не начато");
         }
     }
     else
     {
         MessageBox.Show("Услуга не выбрана");
     }
     return(false);
 }
 private void bAddService_Click(object sender, RoutedEventArgs e)
 {//обработчик кнопки "добавить" услугу
     Windows.ServicesWindow w = new ServicesWindow();
     w.ShowDialog();
     if (w.DialogResult == true)                                                  //если пользователь выбрал услугу
     {
         clientDevice     currentdevice = dgDevices.SelectedItem as clientDevice; //выбираем текущее устройство
         requestedService rs            = new requestedService();                 //формируем запрос на услугу
         rs.clientDevice = currentdevice;
         currentdevice.requestedServices.Add(rs);
         rs.service                 = w.Service;
         rs.cost                    = w.Cost;
         rs.description             = w.Description;
         rs.stageOfImplementationId = 1;
         Contract.approximateCost  += w.Cost;    //добавляем стоимость услуги к общей стоимости
         tbApproximateEndCost.Text  = Contract.approximateCost.ToString();
         updateDbGridService(ref currentdevice); //обновляем список услуг для данного устройства
         controlBokEnable();
         controlButtonsEnable();
     }
 }
示例#11
0
        private void bAddForWork_Click(object sender, RoutedEventArgs e)
        {
            if (dbGridRequestedServices.SelectedItem == null)
            {
                MessageBox.Show("Заявка не выбрана");
            }
            else
            {
                serviceExecution se = new serviceExecution();
                se.dateOfBegin = DateTime.Now;
                se.employee    = currentUser;
                Int32            id        = (dbGridRequestedServices.SelectedItem as View_requestedServices).Id;
                requestedService currentRS = core.serviceCenterDB.requestedServices.Where(rs => rs.Id == id).FirstOrDefault();
                se.requestedService = currentRS;
                se.requestedService.stageOfImplementation = core.serviceCenterDB.stagesOfImplementations.Where(st => st.name == "В работе").FirstOrDefault();
                core.serviceCenterDB.servicesExecution.Add(se);
                core.serviceCenterDB.SaveChanges();

                updateMyServiceExecution();
                updateRequestedServices();
                updateModules();
            }
        }