private void btnServicios_Click(object sender, EventArgs e) { this.Hide(); Servicios se = new Servicios(); se.Closed += (s, args) => this.Close(); se.Show(); }
private void btnInsertar_Click(object sender, EventArgs e) { try { if (cboTipo.SelectedIndex == -1) { MessageBox.Show("Seleccionar tipo de servicio"); } if (txtCodigo.Text == "") { MessageBox.Show("Ingresar codigo de servicio"); txtCodigo.Focus(); } if (txtDescripcion.Text == "") { MessageBox.Show("Ingresar descripción de servicio"); txtDescripcion.Focus(); } if (cboMoneda.SelectedIndex == -1) { MessageBox.Show("Seleccionar moneda"); } if (txtValorUnitario.Text == "") { MessageBox.Show("Ingresar valor unitario"); txtValorUnitario.Focus(); } if (txtPrecioUnitario.Text == "") { MessageBox.Show("Ingresar precio unitario"); txtPrecioUnitario.Focus(); } else { string q = "insert into Productos values('" + cboTipo.SelectedValue.ToString() + "','" + txtCodigo.Text + "','" + txtDescripcion.Text + "','" + cboMoneda.SelectedValue.ToString() + "','" + txtValorUnitario.Text + "','" + txtPrecioUnitario.Text + "')"; cn.Open(); SqlCommand cmd = new SqlCommand(q, cn); cmd.ExecuteNonQuery(); cn.Close(); MessageBox.Show("Servicio Insertado"); this.Hide(); Servicios se = new Servicios(); se.Closed += (s, args) => this.Close(); se.Show(); } } catch (Exception ex) { MessageBox.Show("Error al insertar servicio"); } }