private void Button3_Click(object sender, EventArgs e) { String nombreOperario = comboBox1.SelectedItem.ToString(); int cantidadHoras = int.Parse(textBox1.Text); Classes.Operario operarioAux = principal.buscarOperario(nombreOperario); Classes.TipoLabor tipoaux = darTipoLabor(operarioAux.tipo); double pUnitario = 0; if (tipoaux != null) { pUnitario = tipoaux.valuePerhour; } else { MessageBox.Show("El tipo de labor es nulo."); } int pos = tablaManoObra.Rows.Count; double pTotal = pUnitario * cantidadHoras; tablaManoObra.Rows.Add(nombreOperario, cantidadHoras, pUnitario, pTotal); }
public double calcularTotal() { double suma = 0; for (int i = 0; i < tablaManoObra.Rows.Count - 1; i++) { suma += double.Parse(tablaManoObra.Rows[i].Cells[3].Value.ToString()); Classes.Operario opAux = principal.buscarOperario(tablaManoObra.Rows[i].Cells[0].Value.ToString()); Classes.Operario operario = new Classes.Operario(tablaManoObra.Rows[i].Cells[0].Value.ToString(), opAux.id, opAux.tipo); operario.horasTrabajadas = int.Parse(tablaManoObra.Rows[i].Cells[1].Value.ToString()); operario.valorUnitario = double.Parse(tablaManoObra.Rows[i].Cells[2].Value.ToString()); operario.totalValue = double.Parse(tablaManoObra.Rows[i].Cells[3].Value.ToString()); manoDeObras.Add(operario); } textBox2.Text = suma + ""; totalMO = suma; return(suma); }