Ejemplo n.º 1
0
        private void buttonUpdateImage_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridViewDisplayImage.SelectedRows)
            {
                int     id    = Convert.ToInt32(row.Cells[0].Value);
                Imagine image = _carService.FindImageById(id);

                image.Titlu     = row.Cells[1].Value.ToString();
                image.Data      = Convert.ToDateTime(row.Cells[2].Value);
                image.Descriere = row.Cells[4].Value.ToString();

                _carService.UpdateImage(image);
            }

            // reload to view changes
            FormDisplayDetails_Load(sender, e);
        }
Ejemplo n.º 2
0
 public Imagine FindImageById(int id)
 {
     return(_api.FindImageById(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);
        }