Exemple #1
0
        private void buttonUpdateMecanic_Click_1(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridViewDisplayMechanics.SelectedRows)
            {
                int     id      = Convert.ToInt32(row.Cells[0].Value);
                Mecanic mecanic = _carService.FindMecanicById(id);

                mecanic.Nume    = row.Cells[1].Value.ToString();
                mecanic.Prenume = row.Cells[2].Value.ToString();
                _carService.UpdateMecanic(mecanic);
            }

            // reload to view changes
            FormDisplayDetails_Load(sender, e);
        }
Exemple #2
0
 public Mecanic FindMecanicById(int id)
 {
     return(_api.FindMecanicById(id));
 }
        private void buttonAddDetails_Click(object sender, EventArgs e)
        {
            List <Material> materials  = new List <Material>();
            List <Operatie> operations = new List <Operatie>();
            List <Mecanic>  mechanics  = new List <Mecanic>();
            List <Imagine>  images     = new List <Imagine>();

            int             index       = dataGridViewAddDetailByOrder.CurrentCell.RowIndex;
            DataGridViewRow selectedRow = dataGridViewAddDetailByOrder.Rows[index];
            int             orderId     = Convert.ToInt32(selectedRow.Cells[0].Value);

            foreach (DataGridViewRow row in dataGridViewAddDetailsMaterials.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells[0].Value);

                Material material = _carService.FindMaterialById(id);
                TotalCost += material.Pret;

                material.Cantitate -= 1;
                _carService.UpdateMaterial(material);

                materials.Add(material);
            }

            foreach (DataGridViewRow row in dataGridViewAddDetailsOperations.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells[0].Value);

                Operatie operation = _carService.FindOperationById(id);
                operations.Add(operation);
            }

            foreach (DataGridViewRow row in dataGridViewAddDetailsMechanics.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells[0].Value);

                Mecanic mecanic = _carService.FindMecanicById(id);
                mechanics.Add(mecanic);
            }

            foreach (DataGridViewRow row in dataGridViewAddDetailsImages.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells[0].Value);

                Imagine image = _carService.FindImageById(id);
                images.Add(image);
            }

            DetaliuComanda orderDetails = new DetaliuComanda()
            {
                ComandaId = orderId,
                Imagini   = images,
                Mecanici  = mechanics,
                Materiale = materials,
                Operatii  = operations
            };

            _carService.AddOrderDetails(orderDetails);
            labelAddDetails.Text    = @"Order details added.";
            labelAddDetails.Visible = true;

            Comanda order = _carService.FindOrderById(orderId);

            order.ValoarePiese = TotalCost + ServiceFee;
            _carService.UpdateOrder(order);
        }