Пример #1
0
        private void DgvPlatos_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                DataGridViewRow row = this.dgvPlatos.CurrentRow;
                if (this.dgvPlatos.Enabled && this.dgvPlatos.Focused && row != null)
                {
                    string rpta = "OK";
                    int    fila = this.dgvPlatos.CurrentRow.Cells[0].RowIndex;
                    if (this.FrmAgregarPlato != null)
                    {
                        this.FrmAgregarPlato.ObtenerDatos
                            (DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
                    }
                    else if (this.agregarDetallePlato != null)
                    {
                        this.agregarDetallePlato.ObtenerDatosPlato
                            (DatagridString.ReturnValuesOfCells(sender, fila, out rpta));
                    }
                    else if (this.InactivarPlatos)
                    {
                        Mensajes.MensajePregunta("¿Seguro desea inactivar el plato?",
                                                 "Continuar", "Cancelar", out DialogResult dialog);
                        if (dialog == DialogResult.Yes)
                        {
                            int id_plato = Convert.ToInt32(row.Cells["Id_plato"].Value);
                            rpta = NPlatos.InactivarPlato(id_plato);
                            if (rpta.Equals("OK"))
                            {
                                Mensajes.MensajeOkForm("Se inactivó el plato correctamente");
                                this.BuscarPlatos("COMPLETO", "");
                                return;
                            }
                            else
                            {
                                throw new Exception(rpta);
                            }
                        }
                    }

                    if (rpta.Equals("OK"))
                    {
                        this.Close();
                    }
                    else
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "DgvPlatos_DoubleClick",
                                              "Hubo un error con la tabla de datos", ex.Message);
            }
        }