Beispiel #1
0
        private DataTable dtImages(out string rpta)
        {
            rpta = "OK";
            try
            {
                DataTable table = new DataTable("Images");
                table.Columns.Add("Imagen", typeof(string));
                table.Columns.Add("Descripcion_imagen", typeof(string));

                foreach (UploadImage upload in this.panel1.controls)
                {
                    rpta =
                        ArchivosAdjuntos.GuardarArchivo(01, "RutaImagenesArticulos", upload.Nombre_imagen, upload.Ruta_origen);
                    if (rpta.Equals("OK"))
                    {
                        DataRow row = table.NewRow();
                        row["Imagen"]             = upload.Nombre_imagen;
                        row["Descripcion_imagen"] = upload.Observaciones != null ? "" : upload.Observaciones;
                        table.Rows.Add(row);
                    }
                }
                return(table);
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
                return(null);
            }
        }
Beispiel #2
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);
            }
        }
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                int    id_bebida = 0;
                string rpta      = "";
                if (this.Comprobaciones())
                {
                    if (this.IsEditar)
                    {
                        rpta = NBebidas.EditarBebida(this.Parametros());
                    }
                    else
                    {
                        rpta = NBebidas.InsertarBebida(this.Parametros(), out id_bebida);
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (!this.adjuntarImagen.Nombre_imagen.Equals("SIN IMAGEN"))
                        {
                            rpta = ArchivosAdjuntos.GuardarArchivo(id_bebida, "rutaImages",
                                                                   this.adjuntarImagen.Nombre_imagen,
                                                                   this.adjuntarImagen.RutaOrigen);
                        }
                    }

                    if (rpta.Equals("OK"))
                    {
                        Mensajes.MensajeOkForm("Se agregó correctamente la bebida");
                        this.Close();
                    }
                    else
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, Metodo_error,
                                              Informacion_error, ex.Message);
            }
        }