public ActionResult Moving(TechnologMealViewModel model) { if (string.IsNullOrEmpty(model.Quantity)) { return(RedirectToAction("Index")); } var quantity = decimal.Parse(model.Quantity.Replace(".", ",")); DatabaseHelper.CreateMealStorageMoving( DateTime.Now, model.ProductFromId, model.ProductFromId, model.ClassificationFromId, model.ClassificationToId, model.SilageFromId, model.SilageToId, quantity); DatabaseHelper.SetUserChangesLog(User.Identity.Name, "Перемещение на элеваторе", 0); return(RedirectToAction("Index")); }
public ActionResult Index(TechnologMealViewModel model) { var newModel = new TechnologMealViewModel(); long dayShiftId = DatabaseHelper.GetCurrentDayShiftId(); var d = DateTime.Now.Date; var bd = d.Date; if (model.DateBegin == DateTime.MinValue) { newModel.DateBegin = new DateTime(bd.Year, bd.Month, bd.Day, 7, 0, 0); } else { newModel.DateBegin = model.DateBegin; } if (model.TimeBegin == DateTime.MinValue) { newModel.TimeBegin = new DateTime(bd.Year, bd.Month, bd.Day, 7, 0, 0); } else { newModel.TimeBegin = model.TimeBegin; } if (model.DateFinish == DateTime.MinValue) { newModel.DateFinish = new DateTime(d.Year, d.Month, d.Day, 19, 00, 00); } else { newModel.DateFinish = model.DateFinish; } if (model.TimeFinish == DateTime.MinValue) { newModel.TimeFinish = new DateTime(d.Year, d.Month, d.Day, 19, 00, 00); } else { newModel.TimeFinish = model.TimeFinish; } if (model.ShiftId == 0) { newModel.ShiftId = dayShiftId; } else { newModel.ShiftId = model.ShiftId; } newModel.Shifts.Add(new ListItemModel { Id = 0, Name = "Виберіть зміну" }); newModel.Shifts.AddRange(DatabaseHelper.GetDayShifts()); var activeCars = DatabaseHelper.GetActualCarInfo().Where(c => c.ProcessStatus == "Прийом насіння"); newModel.Bunkers = DatabaseHelper.GetBunkersState(); DateTime startPeriod = new DateTime(newModel.DateBegin.Year, newModel.DateBegin.Month, newModel.DateBegin.Day, newModel.TimeBegin.Hour, newModel.TimeBegin.Minute, newModel.TimeBegin.Second); DateTime finishPeriod = new DateTime(newModel.DateFinish.Year, newModel.DateFinish.Month, newModel.DateFinish.Day, newModel.TimeFinish.Hour, newModel.TimeFinish.Minute, newModel.TimeFinish.Second); var mealShifts = DatabaseHelper.GetMealShiftsInfo(startPeriod, finishPeriod); foreach (var item in mealShifts) { newModel.MealShifts.Add(new TechnologMealCurrentActivitiesPerShift { ShiftDate = item.StartShift.HasValue ? string.Format("{0:dd.MM.yyyy}", item.StartShift.Value) : "", ShiftName = item.ShiftName, StoragedHusk = item.StoragedHusk.HasValue ? item.StoragedHusk.Value : 0, StoragedHuskGran = item.StoragedHuskGran.HasValue ? item.StoragedHuskGran.Value : 0, PackedHusk = item.PackedHusk.HasValue ? item.PackedHusk.Value : 0, PackedSchrotte = item.PackedSchrotte.HasValue ? item.PackedSchrotte.Value : 0, StoragedSchrotte = item.StoragedSchrotte.HasValue ? item.StoragedSchrotte.Value : 0, StoragedSchrotteGran = item.StoragedSchrotteGran.HasValue ? item.StoragedSchrotteGran.Value : 0 }); } var shiftInfo = DatabaseHelper.GetMealShiftInfo(newModel.ShiftId); newModel.TechnologMealCurrentShift.AmountCarsBeforeTruck = shiftInfo.AmountCarsBeforeTruck.Value; newModel.TechnologMealCurrentShift.AmountExpectedRevenuesByTTN = shiftInfo.AmountExpectedRevenuesByTTN.HasValue?shiftInfo.AmountExpectedRevenuesByTTN.Value:0; newModel.TechnologMealCurrentShift.AmountGoOnProduction = shiftInfo.AmountGoOnProduction.HasValue ? shiftInfo.AmountGoOnProduction.Value : 0; newModel.TechnologMealCurrentShift.PackedHusk = shiftInfo.PackedHusk.HasValue ? shiftInfo.PackedHusk.Value : 0; newModel.TechnologMealCurrentShift.PackedSchrotte = shiftInfo.PackedSchrotte.HasValue ? shiftInfo.PackedSchrotte.Value : 0; newModel.TechnologMealCurrentShift.PackedHuskGran = shiftInfo.PackedHuskGran.HasValue ? shiftInfo.PackedHuskGran.Value : 0; newModel.TechnologMealCurrentShift.PackedSchrotteGran = shiftInfo.PackedSchrotteGran.HasValue ? shiftInfo.PackedSchrotteGran.Value : 0; newModel.TechnologMealCurrentShift.StoragedHusk = shiftInfo.StoragedHusk.HasValue ? shiftInfo.StoragedHusk.Value : 0; newModel.TechnologMealCurrentShift.StoragedHuskGran = shiftInfo.StoragedHuskGran.HasValue ? shiftInfo.StoragedHuskGran.Value : 0; newModel.TechnologMealCurrentShift.StoragedSchrotte = shiftInfo.StoragedSchrotte.HasValue ? shiftInfo.StoragedSchrotte.Value : 0; newModel.TechnologMealCurrentShift.StoragedSchrotteGran = shiftInfo.StoragedSchrotteGran.HasValue ? shiftInfo.StoragedSchrotteGran.Value : 0; newModel.TechnologMealCurrentShift.StoragedCake = shiftInfo.StoragedCake.HasValue ? shiftInfo.StoragedCake.Value : 0; newModel.CurrentStorageState.OilCakesWeight = DatabaseHelper.GetOilCakesWeight(); newModel.CurrentStorageState.HuskCharacteristicWeight = DatabaseHelper.GetHuskCharacteristicWeight(); newModel.CurrentStorageState.HuskCharacteristicGranWeight = DatabaseHelper.GetHuskCharacteristicGranWeight(); newModel.CurrentStorageState.SchrothGranWeight = DatabaseHelper.GetSchrothGranWeight(); newModel.CurrentStorageState.SchrothWeight = DatabaseHelper.GetSchrothWeight(); newModel.CurrentStorageState.BigbagBunker1 = DatabaseHelper.GetBigbagWeight(1, newModel.ShiftId); newModel.CurrentStorageState.BigbagBunker2 = DatabaseHelper.GetBigbagWeight(2, newModel.ShiftId); newModel.CurrentStorageState.BigBagStorage = DatabaseHelper.GetBigBagStorage(); newModel.BunkersFrom = DatabaseHelper.GetBunkerForMoving().Where(b => b.ParentId > 0 && (b.Id != 119 || b.Id != 120)).OrderBy(b => b.Id).ToList(); newModel.BunkersTo = DatabaseHelper.GetBunkerForMoving().OrderBy(b => b.Id).ToList(); newModel.Products = DatabaseHelper.GetMealProducts(); newModel.TransactionDate = d; newModel.Classifications.Add(new ListItemModel { Id = 8, Name = "Не гранульований" }); newModel.Classifications.Add(new ListItemModel { Id = 7, Name = "Гранульований" }); var mealIncomingCars = DatabaseHelper.GetActualCarInfo().Where(c => c.OrderTypeId == 4); foreach (var item in mealIncomingCars) { var order = DatabaseHelper.GetOrderById(item.OrderId); var deliveryNote = DatabaseHelper.GetDeliveryNoteBy(item.OrderId); newModel.IncomingCarList.Add( new CarOnAriaInfo { CarNumber = item.CarNumber, Characteristic = item.ClassificationName, GrossWeight = order.GrossWeight.HasValue?order.GrossWeight.Value:0, Product = item.ProductName, Proccess = item.CarPlaceName, WeightOnTTN = deliveryNote.TtnNettoWeight.HasValue ? deliveryNote.TtnNettoWeight.Value : 0, }); } var carShipmentList = DatabaseHelper.GetActualCarInfo().Where(c => c.OrderTypeId == 5 || c.OrderTypeId == 8 || c.OrderTypeId == 12); foreach (var item in carShipmentList) { var order = DatabaseHelper.GetOrderById(item.OrderId); var deliveryNote = DatabaseHelper.GetDeliveryNoteBy(item.OrderId); if (item.ElevatorNUmber == 1) { newModel.CarShipmentList.Add( new CarOnAriaInfo { CarNumber = item.CarNumber, Characteristic = item.ClassificationName, //GrossWeight = order.GrossWeight.HasValue ? order.GrossWeight.Value : 0, Product = item.ProductName, Proccess = item.CarPlaceName, NetWeight = double.Parse(item.Weight), WeightOnTTN = deliveryNote.TtnNettoWeight.HasValue ? deliveryNote.TtnNettoWeight.Value : 0, }); } if (item.ElevatorNUmber == 2) { newModel.CarShipmentList2.Add( new CarOnAriaInfo { CarNumber = item.CarNumber, Characteristic = item.ClassificationName, //GrossWeight = order.GrossWeight.HasValue ? order.GrossWeight.Value : 0, Product = item.ProductName, Proccess = item.CarPlaceName, NetWeight = double.Parse(item.Weight), WeightOnTTN = deliveryNote.TtnNettoWeight.HasValue ? deliveryNote.TtnNettoWeight.Value : 0, }); } } return(View(newModel)); }