private void btnGuardar_Click(object sender, EventArgs e) { int valorIdSupplier = int.Parse(dgvProveedor.Rows[dgvProveedor.CurrentRow.Index].Cells[0].Value.ToString()); // MessageBox.Show(idd.ToString()); DataSet1TableAdapters.ProductTableAdapter ta = new DataSet1TableAdapters.ProductTableAdapter(); // MessageBox.Show(idd.ToString()); if (string.IsNullOrWhiteSpace(txtNombre.Text)) { MessageBox.Show("Verifique que todos los campos hayan sido llenados correctamente"); } else if (idd == 0) { // ta.InsertQueryMaterial(txtNombre.Text.Trim()); ta.InsertQueryProduct(txtNombre.Text.Trim(), (int)udCantidad.Value, clnFechaExp.SelectionRange.Start.ToShortDateString(), (decimal)udUnidades.Value, (int)valorIdSupplier, txtTipoUnidad.Text.Trim(), txtPresentacion.Text.Trim()); txtNombre.Clear(); udCantidad.Value = 0; udUnidades.Value = 0; clnFechaExp.SetDate(DateTime.Now); txtTipoUnidad.Clear(); txtProveedor.Clear(); txtProveedor.Enabled = true; dgvProveedor.Enabled = true; btnElegir.Enabled = true; btnLimpiar.Enabled = true; idd = 0; Refresh(); valorIdSupplier = 0; txtPresentacion.Clear(); } else { // int valorIdSupplier = int.Parse(dgvProveedor.Rows[dgvProveedor.CurrentRow.Index].Cells[0].Value.ToString()); ta.UpdateQueryProduct(txtNombre.Text.Trim(), (int)udCantidad.Value, txtPresentacion.Text.Trim(), clnFechaExp.SelectionRange.Start.ToShortDateString(), (decimal)udUnidades.Value, txtTipoUnidad.Text.Trim(), valorIdSupplier , (int)idd); txtNombre.Clear(); udCantidad.Value = 0; udUnidades.Value = 0; clnFechaExp.SetDate(DateTime.Now); valorIdSupplier = 0; txtTipoUnidad.Clear(); txtProveedor.Clear(); txtProveedor.Enabled = true; dgvProveedor.Enabled = true; btnElegir.Enabled = true; btnLimpiar.Enabled = true; idd = 0; Refresh(); } }