예제 #1
0
        private void buttonUpdateOrders_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridViewDisplayOrders.SelectedRows)
            {
                int          state      = Convert.ToInt32(row.Cells[7].Value);
                StareComanda orderState = getOrderState(state);
                int          id         = Convert.ToInt32(row.Cells[0].Value);

                Comanda order = _carService.FindOrderById(id);
                order.DataProgramare = Convert.ToDateTime(row.Cells[2].Value);
                order.DataFinalizare = Convert.ToDateTime(row.Cells[3].Value);
                order.KmBord         = Convert.ToInt32(row.Cells[4].Value);
                order.Descriere      = row.Cells[5].Value.ToString();
                order.ValoarePiese   = Convert.ToDecimal(row.Cells[6].Value);
                order.StareComanda   = orderState;

                _carService.UpdateOrder(order);
            }

            FormDisplayOrders_Load(sender, e);
        }
예제 #2
0
 public void UpdateOrder(Comanda order)
 {
     _api.UpdateOrder(order);
 }
        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);
        }