private void buttonUpdateOperation_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridViewDisplayOperations.SelectedRows) { int id = Convert.ToInt32(row.Cells[0].Value); Operatie operation = _carService.FindOperationById(id); operation.Denumire = row.Cells[1].Value.ToString(); operation.TimpExecutie = Convert.ToDecimal(row.Cells[2].Value); _carService.UpdateOperation(operation); } // reload to view changes FormDisplayDetails_Load(sender, e); }
public Operatie FindOperationById(int id) { return(_api.FindOperationById(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); }