Пример #1
0
 private void BtnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvInsumos.Rows.Count > 0)
         {
             string rpta = "";
             foreach (DataGridViewRow row in this.dgvInsumos.Rows)
             {
                 List <string> vs = new List <string>
                 {
                     Convert.ToString(this.txtPlato.Tag), Convert.ToString(row.Cells["Id_insumo"].Value),
                     Convert.ToString(row.Cells["Cantidad_usada"].Value)
                 };
                 rpta = NPlatos.InsertarDetallePlatos(vs);
                 if (!rpta.Equals("OK"))
                 {
                     break;
                 }
             }
             if (rpta.Equals("OK"))
             {
                 Mensajes.MensajeOkForm("Se insertaron todos los ingredientes correctamente");
                 this.Close();
             }
         }
     }
     catch (Exception ex)
     {
         Mensajes.MensajeErrorCompleto(this.Name, "BtnGuardar_Click",
                                       "Hubo un error al guardar los detalles del plato", ex.Message);
     }
 }
Пример #2
0
 private void BtnQuitarInsumosUsados_Click(object sender, EventArgs e)
 {
     if (this.dgvInsumosUsados.Rows.Count > 0)
     {
         DialogResult dialog;
         Mensajes.MensajePregunta("Se eliminará este insumo, ¿desea continuar?",
                                  "Continuar", "Cancelar", out dialog);
         if (dialog == DialogResult.Yes)
         {
             DataRowView   currentDataRowView = (DataRowView)dgvInsumosUsados.CurrentRow.DataBoundItem;
             DataRow       row = currentDataRowView.Row;
             List <string> vs  = new List <string>
             {
                 Convert.ToString(row["Id_detalle"]), Convert.ToString(0),
                 Convert.ToString(0), Convert.ToString(0), "ELIMINAR"
             };
             string rpta =
                 NPlatos.EditarDetallePlatos(vs);
             if (rpta.Equals("OK"))
             {
                 this.BuscarDetallePlatos("ID PLATO", Convert.ToString(this.txtPlato.Tag));
                 Mensajes.MensajeOkForm("Se eliminó correctamente");
             }
         }
     }
 }
Пример #3
0
        private void BuscarDetallePlatos(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                DataTable table =
                    NPlatos.BuscarDetallePlatos(tipo_busqueda, texto_busqueda);
                this.dgvInsumosUsados.DataSource = table;
                if (table != null)
                {
                    this.lblins.Text = "Insumos usados " + table.Rows.Count;

                    string[] columnsHeader =
                    {
                        "Id detalle", "Id plato", "Id insumos", "Insumo", "Cantidad", "Cantidad usada", "Id tipo insumo", "Tipo"
                    };
                    bool[] columnsVisible =
                    {
                        false, false, false, true, false, true, false, false
                    };
                    this.dgvInsumosUsados =
                        DatagridString.ChangeHeaderTextAndVisible(this.dgvInsumosUsados, columnsHeader, columnsVisible);
                }
                else
                {
                    this.lblins.Text = "No hay insumos agregados";
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarDetallePlatos",
                                              "Hubo un error al buscar un detalle", ex.Message);
            }
        }
 public static ComboBox LlenarListaTipoPlatos(ComboBox lista)
 {
     lista.DataSource    = NPlatos.BuscarTipoPlatos("COMPLETO", "");
     lista.ValueMember   = "Id_tipo_plato";
     lista.DisplayMember = "Tipo_plato";
     return(lista);
 }
Пример #5
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);
            }
        }
Пример #6
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            string rpta    = "";
            string mensaje = "";

            try
            {
                if (this.Comprobaciones())
                {
                    int id_plato = 0;
                    if (this.IsEditar)
                    {
                        rpta    = NPlatos.EditarPlatos(this.Variables());
                        mensaje = "actualizó";
                    }
                    else
                    {
                        rpta    = NPlatos.InsertarPlatos(this.Variables(), out id_plato);
                        mensaje = "agregó";
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (!this.adjuntarImagen.Nombre_imagen.Equals("SIN IMAGEN"))
                        {
                            rpta = ArchivosAdjuntos.GuardarArchivo(id_plato, "rutaImages",
                                                                   this.adjuntarImagen.Nombre_imagen,
                                                                   this.adjuntarImagen.RutaOrigen);
                        }
                        if (rpta.Equals("OK"))
                        {
                            Mensajes.MensajeOkForm("Se " + mensaje + " el plato correctamente");
                            this.Close();
                        }
                        else
                        {
                            Mensajes.MensajeErrorCompleto(this.Name, "BtnGuardar_Click",
                                                          "Se " + mensaje + " el plato, pero hubo un error al guardar la imagen", rpta);
                        }
                    }
                }
                else
                {
                    throw new Exception(rpta);
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BtnGuardar_Click",
                                              "Hubo un error al " + mensaje + " el plato", ex.Message);
            }
        }
Пример #7
0
        private void BuscarPlatos(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                string    estado = this.rdActivo.Checked ? "ACTIVO" : "INACTIVO";
                DataTable Tabla  =
                    NPlatos.BuscarPlatos(tipo_busqueda, texto_busqueda, estado, out string rpta);
                if (Tabla != null)
                {
                    this.dgvPlatos.Enabled  = true;
                    this.dgvPlatos.PageSize = 25;
                    this.dgvPlatos.SetPagedDataSource(Tabla, this.bindingNavigator1);

                    this.lblResultados.Text =
                        "Se encontraron " + Tabla.Rows.Count + " platos";

                    string[] columns_header_text =
                    {
                        "Id plato",    "Nombre", "Id tipo", "Precio", "Imagen",
                        "Descripción", "Estado", "Id tipo", "Tipo"
                    };

                    bool[] columns_visible =
                    {
                        false, true, false, true, false, true, false, false, true
                    };

                    this.dgvPlatos =
                        DatagridString.ChangeHeaderTextAndVisibleCustomDataGrid(this.dgvPlatos,
                                                                                columns_header_text, columns_visible);
                }
                else
                {
                    this.dgvPlatos.clearDataSource();
                    this.dgvPlatos.Enabled  = false;
                    this.lblResultados.Text =
                        "No se encontraron platos";

                    if (!rpta.Equals("OK"))
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarPlatos",
                                              "Hubo un error al buscar los platos", ex.Message);
            }
        }
Пример #8
0
 private void BtnEditar_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvInsumosUsados.CurrentRow != null)
         {
             DataGridViewRow row =
                 this.dgvInsumosUsados.CurrentRow;
             int           id_detalle = Convert.ToInt32(row.Cells["Id_detalle"].Value);
             List <string> vs         = new List <string>
             {
                 Convert.ToString(id_detalle), Convert.ToString(0),
                 Convert.ToString(0), Convert.ToString(0), "ELIMINAR"
             };
             string rpta =
                 NPlatos.EditarDetallePlatos(vs);
             if (rpta.Equals("OK"))
             {
                 List <string> datos = new List <string>
                 {
                     Convert.ToString(row.Cells["Id_insumo"].Value), Convert.ToString(row.Cells["Nombre_insumo"].Value),
                     Convert.ToString(row.Cells["Id_tipo_insumo"].Value), Convert.ToString(row.Cells["Tipo_insumo"].Value)
                 };
                 this.txtInsumo.Text = Convert.ToString(row.Cells["Nombre_insumo"].Value);
                 this.txtInsumo.Tag  = datos;
             }
             else
             {
                 Mensajes.MensajeErrorForm("Hubo un problema al eliminar el insumo del plato");
             }
             this.BuscarDetallePlatos("ID PLATO", Convert.ToString(this.txtPlato.Tag));
         }
     }
     catch (Exception ex)
     {
         Mensajes.MensajeErrorForm("Hubo un error al editar un plato " + ex.Message);
     }
 }