Exemplo n.º 1
0
 private bool CloseProductionShift(ProductionShift shift)
 {
     using (StatisticsDetailsForm form = new StatisticsDetailsForm(_currentValidator))
     {
         if (form.ShowDialog() == DialogResult.OK)
         {
             if (shift != null &&
                 form.UpdateTime > shift.ProductionStart.Add(Settings.Default.MaximumLegLength))
             {
                 if (QuestionForm.ShowQuestion(Strings.ProductionShiftWarning, string.Format(Strings.ProductionLengthIsLong, Math.Floor((form.UpdateTime - shift.ProductionStart).TotalHours))) == DialogResult.Cancel)
                 {
                     return false;
                 }
             }
             try
             {
                 shift.CurrentLeg.UpdateStatistics(form.UpdateTime, form.ProductionCounter, form.DiscardedItems);
                 SaveLeg(shift.CurrentLeg);
                 SaveShift(_currentShift);
                 _currentValidator = new ProductionStatisticsValidator(form.UpdateTime, form.ProductionCounter, form.DiscardedItems);
                 return true;
             }
             catch (Exception ex)
             {
                 log.Error("An exception were caught while updating production counters.", ex);
                 MessageForm.ShowMessage(Strings.ExceptionCaught, Strings.CouldNotUpdateProductionCounters);
             }
         }
     }
     return false;
 }
Exemplo n.º 2
0
        public void UpdateDisplay(ProductionShift shift, Production production, IEnumerable<ProductionStop> allStops)
        {
            productionStart = production.ProductionStart.ToString("g", System.Globalization.CultureInfo.CurrentUICulture);
            productionShiftStartDate = shift.ProductionStart.ToShortDateString();
            ClearDisplay();

            ClearChart(chartShift);
            ClearChart(chartProduction);
            if (production == null ||
                shift == null)
                return;

            team = shift.Team.Name;

            DisplayOrder(production.Order);
            DisplayProduct(production.Product);
            DisplayProductionStart(shift.ProductionStart, production.ProductionStart);
            DisplayProductionTime(shift.Duration, production.Duration);
            DisplayProducedItems(shift.ProducedItems, production.ProducedItems, production.ProducedItemsPerHour);
            DisplayDiscardedItems(shift.DiscardedItems, production.DiscardedItems);
            DisplayFactors(new FactorCalculator(shift), new FactorCalculator(production));

            DisplayStopRegistrationsOnChart(chartShift, shift.ProductionStopRegistrations, allStops, production.ValidatedStartTime);
            DisplayStopRegistrationsOnChart(chartProduction, production.ProductionStopRegistrations, allStops, production.ValidatedStartTime);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ProductionShift productionshift = db.ProductionShifts.Find(id);

            db.ProductionShifts.Remove(productionshift);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,PlantID,TypeID,Code,StartTime,EndTime,DateEntered,EnteredBy,LastModified,ModifiedBy")] ProductionShift productionshift)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productionshift).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PlantID = new SelectList(db.Plants, "ID", "Code", productionshift.PlantID);
     ViewBag.TypeID  = new SelectList(db.ProductionShiftTypes, "ID", "Code", productionshift.TypeID);
     return(View(productionshift));
 }
        // GET: /TPOProductionShift/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductionShift productionshift = db.ProductionShifts.Find(id);

            if (productionshift == null)
            {
                return(HttpNotFound());
            }
            return(View(productionshift));
        }
        // GET: /TPOProductionShift/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductionShift productionshift = db.ProductionShifts.Find(id);

            if (productionshift == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PlantID = new SelectList(db.Plants, "ID", "Code", productionshift.PlantID);
            ViewBag.TypeID  = new SelectList(db.ProductionShiftTypes, "ID", "Code", productionshift.TypeID);
            return(View(productionshift));
        }
Exemplo n.º 7
0
 private void StopDataEntry()
 {
     if (!CloseProductionShift(_currentShift))
         return;
     UpdateDisplay();
     _currentShift = null;
     UpdateButtons();
 }
Exemplo n.º 8
0
        private void StartDataEntry()
        {
            _currentShift = StartProductionShift();

            if (_currentShift == null)
            {
                if (!started)
                    Application.Exit();
                return;
            }

            started = true;
            LastOrder = _currentShift.Order;
            _currentValidator = new ProductionStatisticsValidator(_currentShift.CurrentLeg.ProductionStart, _currentShift.CurrentLeg.CounterStart, 0);
            UpdateHeader(_currentShift.Production);
            UpdateDisplay();

            UpdateButtons();
        }
Exemplo n.º 9
0
 private void SaveShift(ProductionShift shift)
 {
     try
     {
         using (IEntityRepository<ProductionShift> repository = _repositoryFactory.CreateEntityRepository<ProductionShift>())
         {
             repository.Save(shift);
         }
     }
     catch (Exception ex)
     {
         log.Error("An exception were caught while saving a shift.", ex);
         MessageForm.ShowMessage(Strings.ExceptionCaught, Strings.CouldNotAddProductionShift);
     }
 }
Exemplo n.º 10
0
 public ProductionShiftViewEntity(ProductionShift entity)
 {
     this.entity = entity;
 }