Exemple #1
0
 private void cargarDatos()
 {
     if (Request.Params["negocio"] != null)
     {
         lgNegocio          = new LogicaNegocio();
         negocio            = lgNegocio.SessionNegocio(int.Parse(Request.Params["negocio"]));
         txtDescdrip.Text   = negocio.descripcion;
         txtNombre.Text     = negocio.nombre;
         hdCodNegocio.Value = negocio.id_negocio.ToString();
         //hdImag.Value = negocio.foto_negocio;
         txtTelefono.Text = negocio.telefono.ToString();
         lgEstaNegocio    = new LogicaEstadoNegocio();
         List <csEstadoNegocio> lista = new List <csEstadoNegocio>();
         hpRegresar1.NavigateUrl = "PerfilUsuarioAdminn.aspx?perfil=" + Request.Params["perfil"];
         hpRegresar2.NavigateUrl = "PerfilUsuarioAdminn.aspx?perfil=" + Request.Params["perfil"];
         lista = lgEstaNegocio.listEstadoNegocio(negocio.id_negocio);
         for (int i = 0; i < chekListCategoria.Items.Count; i++)
         {
             foreach (csEstadoNegocio estNeg in lista)
             {
                 if (chekListCategoria.Items[i].Value == estNeg.fk_id_categoria.ToString())
                 {
                     chekListCategoria.Items[i].Selected = true;
                 }
             }
         }
     }
     else
     {
         Response.Redirect("NegocioPropietario.aspx");
     }
 }
Exemple #2
0
        protected void btnAgregarNegocio_Click(object sender, EventArgs e)
        {
            LogicaNegocio lgNegocio = new LogicaNegocio();

            lgPath = new LogicaPath();
            csUsuario usuario = (csUsuario)Session["Usuario"];

            lgExtNegocio = new LogicaEstadoNegocio();

            if (IsValid)
            {
                if ((uploadFile1.PostedFile != null) && (uploadFile1.PostedFile.ContentLength > 0))
                {
                    try
                    {
                        string    fn           = System.IO.Path.GetFileName(uploadFile1.PostedFile.FileName);
                        string    SaveLocation = Server.MapPath("media\\img") + "\\" + fn;
                        csNegocio negocio      = new csNegocio(0, txtNombre.Text, txtDescdrip.Text, txtTelefono.Text, usuario.id_usuario, uploadFile1.FileName, hdLonft.Value, txtUbicacion.Text, hdLatFt.Value);
                        int       codNegoc     = int.Parse(lgNegocio.CrearNegocio(negocio));
                        if (codNegoc > 0)
                        {
                            uploadFile1.PostedFile.SaveAs(SaveLocation);
                            foreach (ListItem item in chekListCategoria.Items)
                            {
                                if (item.Selected)
                                {
                                    estNegocio = new csEstadoNegocio(0, int.Parse(item.Value.ToString()), codNegoc);
                                    lgExtNegocio.CrearEstadoNegocio(estNegocio);
                                }
                            }

                            Button2_ModalPopupExtender.Show();
                        }
                        else
                        {
                            ltRepuesta.Text = @"<div class='alert alert-danger'>
                             <strong>Danger!</strong> no guardor el registro.
                             </div>";
                        }
                    }
                    catch (Exception ex)
                    {
                        ltRepuesta.Text = @"<div class='alert alert-danger'>
                    <strong>Advertencia</strong> " + ex.Message + "</div>";
                    }
                }
                else
                {
                    ltRepuesta.Text = @"<div class='alert alert-danger'>
                    <strong>Danger!</strong> No cargo la Foto.
                    </div>";
                }
            }
        }
Exemple #3
0
        protected void btnModificar_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValid)
                {
                    LogicaNegocio lgNegocio = new LogicaNegocio();
                    lgPath = new LogicaPath();
                    csUsuario usuario  = (csUsuario)Session["Usuario"];
                    int       codNegoc = int.Parse(Request.Params["negocio"]);
                    lgEstaNegocio = new LogicaEstadoNegocio();
                    if ((uploadFile1.PostedFile != null) && (uploadFile1.PostedFile.ContentLength > 0))
                    {
                        string    fn           = System.IO.Path.GetFileName(uploadFile1.PostedFile.FileName);
                        string    SaveLocation = Server.MapPath("media/img") + "/" + fn;
                        csNegocio negocio      = new csNegocio(int.Parse(hdCodNegocio.Value), txtNombre.Text, txtDescdrip.Text, txtTelefono.Text, usuario.id_usuario, uploadFile1.FileName, hdLonft.Value, txtUbicacion.Text, hdLatFt.Value);

                        if (lgNegocio.ModificarNegocio(negocio))
                        {
                            foreach (ListItem item in chekListCategoria.Items)
                            {
                                if (item.Selected)
                                {
                                    if (lgEstaNegocio.validarEstadNegocio(int.Parse(item.Value.ToString()), codNegoc) == false)
                                    {
                                        estNegocio = new csEstadoNegocio(0, int.Parse(item.Value.ToString()), codNegoc);
                                        lgEstaNegocio.CrearEstadoNegocio(estNegocio);
                                    }
                                }
                                if (item.Selected == false)
                                {
                                    if (lgEstaNegocio.validarEstadNegocio(int.Parse(item.Value.ToString()), codNegoc))
                                    {
                                        lgEstaNegocio.EliminarEstadoNegocio(int.Parse(item.Value.ToString()));
                                    }
                                }
                            }
                            uploadFile1.PostedFile.SaveAs(SaveLocation);
                            Button2_ModalPopupExtender.Show();
                        }
                        else
                        {
                            ltRepuesta.Text = @"<div class='alert alert-danger'>
                             <strong>Danger!</strong> no guardor el registro.
                             </div>";
                        }
                    }
                    else
                    {
                        //string fn = System.IO.Path.GetFileName(uploadFile1.PostedFile.FileName);
                        //string SaveLocation = Server.MapPath("media/img") + "/" + fn;
                        csNegocio negocio = new csNegocio(int.Parse(hdCodNegocio.Value), txtNombre.Text, txtDescdrip.Text, txtTelefono.Text, usuario.id_usuario, "", hdLonft.Value, txtUbicacion.Text, hdLatFt.Value);

                        if (lgNegocio.ModificarNegocio2(negocio))
                        {
                            foreach (ListItem item in chekListCategoria.Items)
                            {
                                if (item.Selected)
                                {
                                    if (lgEstaNegocio.validarEstadNegocio(int.Parse(item.Value.ToString()), codNegoc) == false)
                                    {
                                        estNegocio = new csEstadoNegocio(0, int.Parse(item.Value.ToString()), codNegoc);
                                        lgEstaNegocio.CrearEstadoNegocio(estNegocio);
                                    }
                                }
                                if (item.Selected == false)
                                {
                                    if (lgEstaNegocio.validarEstadNegocio(int.Parse(item.Value.ToString()), codNegoc))
                                    {
                                        lgEstaNegocio.EliminarEstadoNegocio(int.Parse(item.Value.ToString()));
                                    }
                                }
                            }
                            //uploadFile1.PostedFile.SaveAs(SaveLocation);
                            Button2_ModalPopupExtender.Show();
                        }
                        else
                        {
                            ltRepuesta.Text = @"<div class='alert alert-danger'>
                             <strong>Danger!</strong> no guardor el registro.
                             </div>";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ltRepuesta.Text = @"<div class='alert alert-danger alert-dismissable'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>
<strong>Error! </strong> " + ex.Message + "</div>";
            }
        }