private void ProductionProcess_Load(object sender, EventArgs e)
        {
            dTPickerProductionActualFilterUpper.Value = DateTime.Today;
            dTPickerProductionActualFilterLower.Value = DateTime.Today.AddDays(-30);

            List <PlannedProduction> plansAddedToProduction = db.PlannedProductions.
                                                              Where(plannedProductionPlan => !db.ProductionProcesses.
                                                                    Select(productionProcessPlan => productionProcessPlan.IdPlan).
                                                                    Contains(plannedProductionPlan.IdPlan) && plannedProductionPlan.Inproduction.Value).ToList();

            foreach (PlannedProduction plannedProduction in plansAddedToProduction)
            {
                ProductionProcess newProductionProces = new ProductionProcess();
                newProductionProces.IdPlan    = plannedProduction.IdPlan;
                newProductionProces.StartDate = plannedProduction.PlannedStartd;
                newProductionProces.EndDate   = plannedProduction.PlannedEndd;
                db.ProductionProcesses.Add(newProductionProces);
            }

            List <PlannedProduction> plansToUpdate = db.PlannedProductions.
                                                     Where(plannedProductionPlanToUpdate => db.ProductionProcesses.
                                                           Select(productionProcessPlanToUpdate => productionProcessPlanToUpdate.IdPlan).
                                                           Contains(plannedProductionPlanToUpdate.IdPlan) && plannedProductionPlanToUpdate.Inproduction.Value).ToList();

            foreach (PlannedProduction plannedProductionToUpdate in plansToUpdate)
            {
                ProductionProcess updateProcess = db.ProductionProcesses.Find(plannedProductionToUpdate.IdPlan);
                updateProcess.StartDate = plannedProductionToUpdate.PlannedStartd;
                updateProcess.EndDate   = plannedProductionToUpdate.PlannedEndd;
            }
            db.SaveChanges();
            ProductionProcessGridView.DataSource = db.vProductionProcessFullDatas.
                                                   Where(ProdProc => ProdProc.EndDate >= DateTime.Now).ToList();
        }
Esempio n. 2
0
        private void btnProductionProcess_Click(object sender, EventArgs e)
        {
            ProductionProcess ProductionProcessForm = new ProductionProcess(db);

            ProductionProcessForm.Show();
            ProductionActual ProductionActualForm = new ProductionActual(db);

            ProductionActualForm.Show();
        }
Esempio n. 3
0
        private void btnCurrentProduction_Click(object sender, EventArgs e)
        {
            ProductionProcess ProductionProcessForm = new ProductionProcess(db);

            ProductionProcessForm.Show();
        }