private void btnAddIns_Click(object sender, EventArgs e) { //Se agrega el insumo con la cantidad digitada en la tabla, si este insumo ya está en la tabla, no se agregará de nuevo y saldrá mensaje de error Boolean condicion = false; for (int i = 0; i < dgIns.Rows.Count; i++) { if (dgIns[0, i].Value.ToString() == listIns.SelectedValue.ToString()) { MessageBox.Show("Ya agregaste este insumo", "Corregir", MessageBoxButtons.OK, MessageBoxIcon.Warning); condicion = true; } } if (!condicion) { DataRow row = ic.ConsultarPrecio(listIns.SelectedValue.ToString()); int costo = int.Parse(row["precio"].ToString()) * int.Parse(numCantIns.Value.ToString()); dgIns.Rows.Add(listIns.SelectedValue.ToString(), listIns.Text, numCantIns.Value, costo); numCantIns.Value = 1; } }
private void button1_Click(object sender, EventArgs e) { //Se agrega el insumo utilizado a la tabla Boolean condicion = false; for (int i = 0; i < dgIns.Rows.Count; i++) { if (dgIns[0, i].Value.ToString() == listIns.SelectedValue.ToString()) { MessageBox.Show("Ya agregaste este insumo", "Corregir", MessageBoxButtons.OK, MessageBoxIcon.Warning); condicion = true; } } if (!condicion) { DataRow row = ic.ConsultarPrecio(listIns.SelectedValue.ToString()); int costo = int.Parse(row["precio"].ToString()) * int.Parse(numCantIns.Value.ToString()); dgIns.Rows.Add(listIns.SelectedValue.ToString(), listIns.Text, numCantIns.Value, costo); numCantIns.Value = 1; } }