private void btn_receta_Click(object sender, EventArgs e) { int indice; Int32 selectedRowCount = dt_RecetaDetalle.Rows.GetRowCount(DataGridViewElementStates.Selected); try { if (selectedRowCount > 0) { if (selectedRowCount == 1) { for (int i = 0; i < selectedRowCount; i++) { id_producto = 0; indice = dt_RecetaDetalle.SelectedRows[i].Index; id_producto = Convert.ToInt32(dt_RecetaDetalle.Rows[indice].Cells[0].Value); string nombre = dt_RecetaDetalle.Rows[indice].Cells[1].Value.ToString(); DataSet data = Producto.getReceta(id_producto); if (data.Tables[0].Rows.Count == 0 || data == null) { Funciones.mError(this, "Este producto NO posee receta"); } else { //recorre la lista de form abiertos por la alicación y devuelve el form Frm_mozo si lo encuentra Form frm = Application.OpenForms.OfType <Form>().Where(Pre => Pre.Name == "Frm_ModificarReceta").SingleOrDefault(); // codigo para validar si el formulario no esta abierto con anterioridad, si no lo abre if (frm != null) { frm.Select(); frm.Show(); frm.WindowState = FormWindowState.Normal; } else { frm = new Frm_ModificarReceta(id_producto, nombre); frm.Show(); frm.WindowState = FormWindowState.Normal; } } } } else { Funciones.mError(this, "Por favor selecione UN SOLO producto"); } } else { Funciones.mError(this, "Por favor seleccione la fila del producto que desee ver la receta"); } } catch (Exception es) { Funciones.mError(this, es.Message); } }
private void btn_verReceta_Click(object sender, EventArgs e) { DataSet data = Producto.getReceta(Frm_Baja_Modificar_Producto.Id_producto1); if (data.Tables[0].Rows.Count == 0 || data == null) { Funciones.mError(this, "Este producto NO posee receta"); } else { //recorre la lista de form abiertos por la alicación y devuelve el form Frm_mozo si lo encuentra Form frm = Application.OpenForms.OfType <Form>().Where(Pre => Pre.Name == "Frm_ModificarReceta").SingleOrDefault(); // codigo para validar si el formulario no esta abierto con anterioridad, si no lo abre if (frm != null) { frm.Select(); frm.Show(); frm.WindowState = FormWindowState.Normal; } else { frm = new Frm_ModificarReceta(Frm_Baja_Modificar_Producto.Id_producto1, txtNombre.Text); frm.Show(); frm.WindowState = FormWindowState.Normal; } } }