Example #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (editPlan() || flagEditPlan)
     {
         PlannedProduction existingPlan = db.PlannedProductions.First(f => f.IdPlan == idPlan);
         existingPlan.IdDetail      = Convert.ToInt32(this.viewOrderDetail.CurrentRow.Cells[0].Value);
         existingPlan.IdMachine     = Convert.ToInt32(comboBoxMachine.SelectedValue);
         existingPlan.PlannedStartd = dateTimeStart.Value;
         existingPlan.PlannedEndd   = dateTimeEnd.Value;
         existingPlan.Inproduction  = Convert.ToBoolean(cBoxIntoProduction.CheckState);
         db.SaveChanges();
         MessageBox.Show("Dokonano edycji planu!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         employeesQuantity = viewProcessEmpl.RowCount;
         if (employeesQuantity == 0)
         {
             MessageBox.Show("Nie przydzielono pracownika!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         }
         else
         {
             newPlan.IdDetail      = Convert.ToInt32(this.viewOrderDetail.CurrentRow.Cells[0].Value);
             newPlan.IdMachine     = Convert.ToInt32(comboBoxMachine.SelectedValue);
             newPlan.PlannedStartd = dateTimeStart.Value;
             newPlan.PlannedEndd   = dateTimeEnd.Value;
             newPlan.Inproduction  = Convert.ToBoolean(cBoxIntoProduction.CheckState);
             db.SaveChanges();
             MessageBox.Show("Dodano nowy plan!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             btnSave.Enabled = false;
         }
     }
     flagExitPermission = false;
 }
Example #2
0
        private void NewProductionPlan_Load(object sender, EventArgs e)
        {
            //// DODAŁEM TO

            cBoxMachine.DataSource = (from maintenanceForCBox in db.Maintenances
                                      join machineForCBox in db.Machines
                                      on maintenanceForCBox.IdMachine equals machineForCBox.IdMachine
                                      //join maintenanceRealization in db.Realizations
                                      //on maintenance.IdMaintenance equals maintenanceRealization.IdMaintenance
                                      //where maintenance.EndDatePlan < DateTime.Now && maintenanceRealization.EndRealDate < DateTime.Now
                                      select new
            {
                machineIdForCBox = maintenanceForCBox.IdMachine,
                fullMachineNameForCBox = machineForCBox.MachineName + " " + machineForCBox.CatalogMachineNr
            }).Distinct().ToList();
            cBoxMachine.ValueMember   = "machineIdForCBox";
            cBoxMachine.DisplayMember = "fullMachineNameForCBox";
            cBoxMachine.Invalidate();

            cBoxEmployee.DataSource = (from allocationForCBox in db.Allocations
                                       join employeeForCBox in db.Employees
                                       on allocationForCBox.IdEmployee equals employeeForCBox.IdEmployee
                                       where allocationForCBox.IdDepartment == 1
                                       select new
            {
                employeeIdForCBox = employeeForCBox.IdEmployee,
                employeeFullNameForCBox = employeeForCBox.EmployeeName + " " + employeeForCBox.EmployeeSurname
            }).Distinct().ToList();
            cBoxEmployee.ValueMember   = "employeeIdForCBox";
            cBoxEmployee.DisplayMember = "employeeFullNameForCBox";
            cBoxEmployee.Invalidate();
            ////
            if (idPlan > 0)
            {
                PlannedProduction      plan        = db.PlannedProductions.FirstOrDefault(f => f.IdPlan == idPlan);
                vUnhandledOrderDetails order       = new vUnhandledOrderDetails();
                OrderDetail            orderDetail = db.OrderDetails.FirstOrDefault(f => f.IdDetail == plan.IdDetail);
                Product product = db.Products.FirstOrDefault(f => f.IdProduct == orderDetail.IdProduct);
                if (plan != null)
                {
                    tBoxPlanNr.Text   = Convert.ToString(plan.IdPlan);
                    cBoxMachine.Text  = Convert.ToString(plan.IdMachine);
                    order.IdDetail    = plan.IdDetail;
                    order.Quantity    = orderDetail.Quantity;
                    order.ProductCode = product.ProductCode;
                }
                List <vUnhandledOrderDetails> handledOrder = new List <vUnhandledOrderDetails>();
                handledOrder.Add(order);
                viewOrderDetail.DataSource = handledOrder;
            }
            viewProcessEmpl.DataSource = (from PlannedProductionEmployeeDetail in db.PlannedProductionEmployeeDetails
                                          where PlannedProductionEmployeeDetail.IdProces == idPlan
                                          select PlannedProductionEmployeeDetail).ToList();
        }
Example #3
0
 private void NewProductionPlan_Load(object sender, EventArgs e)
 {
     comboBoxMachine.DataSource    = db.vComboBoxMachines.ToList();
     comboBoxMachine.ValueMember   = "idMachine";
     comboBoxMachine.DisplayMember = "machineFullName";
     comboBoxMachine.Invalidate();
     comboBoxEmployee.DataSource    = db.vComboBoxEmployees.ToList();
     comboBoxEmployee.ValueMember   = "idEmployee";
     comboBoxEmployee.DisplayMember = "employeeFullName";
     comboBoxEmployee.Invalidate();
     if (idPlan > 0)
     {
         PlannedProduction     plan        = db.PlannedProductions.First(f => f.IdPlan == idPlan);
         vUnhandledOrderDetail order       = new vUnhandledOrderDetail();
         OrderDetail           orderDetail = db.OrderDetails.First(f => f.IdDetail == plan.IdDetail);
         Product product = db.Products.First(f => f.IdProduct == orderDetail.IdProduct);
         if (plan != null)
         {
             vComboBoxMachine selectedMachine = db.vComboBoxMachines.First(f => f.IdMachine == plan.IdMachine);
             tBoxPlanNr.Text            = Convert.ToString(plan.IdPlan);
             comboBoxMachine.Text       = Convert.ToString(selectedMachine.machineFullName);
             order.IdDetail             = plan.IdDetail;
             order.Quantity             = orderDetail.Quantity;
             order.ProductCode          = product.ProductCode;
             cBoxIntoProduction.Checked = (bool)plan.Inproduction;
         }
         else
         {
             MessageBox.Show("Brak planu!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         List <vUnhandledOrderDetail> handledOrder = new List <vUnhandledOrderDetail>();
         handledOrder.Add(order);
         viewOrderDetail.DataSource = handledOrder;
     }
     else
     {
         MessageBox.Show("Nieprawidłowy numer planu!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     viewProcessEmpl.DataSource = (from PlannedProductionEmployeeDetail in db.PlannedProductionEmployeeDetails
                                   where PlannedProductionEmployeeDetail.IdProces == idPlan
                                   select PlannedProductionEmployeeDetail).ToList();
     dateTimeStart.Format               = DateTimePickerFormat.Custom;
     dateTimeEnd.Format                 = DateTimePickerFormat.Custom;
     dateTimeEmployeeStart.Format       = DateTimePickerFormat.Custom;
     dateTimeEmployeeEnd.Format         = DateTimePickerFormat.Custom;
     dateTimeStart.CustomFormat         = "yyyy-MM-dd HH:mm";
     dateTimeEnd.CustomFormat           = "yyyy-MM-dd HH:mm";
     dateTimeEmployeeStart.CustomFormat = "yyyy-MM-dd HH:mm";
     dateTimeEmployeeEnd.CustomFormat   = "yyyy-MM-dd HH:mm";
 }
Example #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            PlannedProduction newPlan = new PlannedProduction();

            newPlan.IdDetail = Convert.ToInt32(this.viewOrderDetail.CurrentRow.Cells[0].Value);
            ///ZMIENIŁEM TO
            newPlan.IdMachine = Convert.ToInt32(cBoxMachine.SelectedValue);
            ///
            newPlan.PlannedStartd = dateTimeStart.Value;
            newPlan.PlannedEndd   = dateTimeEnd.Value;
            newPlan.Inproduction  = Convert.ToBoolean(cBoxIntoProduction.CheckState);
            db.PlannedProductions.Add(newPlan);
            db.SaveChanges();
            MessageBox.Show("Dodano nowy plan!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void PlannedProductionGridView_SelectionChanged(object sender, EventArgs e)
        {
            id = Convert.ToInt32(this.PlannedProductionGridView.CurrentRow.Cells[0].Value);
            PlannedProduction selectedPlan                  = db.PlannedProductions.First(f => f.IdPlan == id);
            Machine           planMachine                   = db.Machines.First(f => f.IdMachine == selectedPlan.IdMachine);
            OrderDetail       planDetail                    = db.OrderDetails.First(f => f.IdDetail == selectedPlan.IdDetail);
            Product           planProduct                   = db.Products.First(f => f.IdProduct == planDetail.IdProduct);
            string            infoAboutOrderProduct         = Convert.ToString(planProduct.ProductCode);
            string            infoAboutOrderProductQuantity = Convert.ToString(planDetail.Quantity);
            string            infoAboutMachine              = Convert.ToString(planMachine.MachineName) + " " + Convert.ToString(planMachine.CatalogMachineNr);

            labelMachine.Text         = infoAboutMachine;
            labelProductCode.Text     = infoAboutOrderProduct;
            labelProductQuantity.Text = infoAboutOrderProductQuantity;
        }