private void btn_modificarProducto_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount =
                dt_RecetaDetalle.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount == 1)
            {
                for (int i = 0; i < selectedRowCount; i++)
                {
                    Id_producto1 = Convert.ToInt32(dt_RecetaDetalle.SelectedRows[i].Cells["id"].Value);
                }

                //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_AltaProducto").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_AltaProducto(1);
                //frm.ShowDialog();
                var result = frm.ShowDialog();
                frm.WindowState = FormWindowState.Normal;
                if (result == DialogResult.OK)
                {
                    DataTable data = Producto.getAll();
                    if (data == null)
                    {
                        Funciones.mError(this, "Sin productos");
                    }
                    else
                    {
                        dt_RecetaDetalle.DataSource = Producto.getAll();
                    }
                    rdTodosProductos.Select();
                }
                //}
            }
            else
            {
                Funciones.mError(this, "Por favor seleccione un producto");
            }
        }
Example #2
0
        //ABRIR ALTA PRODUCTO
        private void button2_Click(object sender, EventArgs e)
        {
            //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_AltaProducto").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_AltaProducto(0);
                frm.Show();
                frm.WindowState = FormWindowState.Normal;
            }
        }