Beispiel #1
0
        //private void CargarList()
        //{
        //    lgTpServicios = new LogicaTipoServicio();
        //    dpListServicios.DataSource = lgTpServicios.dtTpServicio();
        //    dpListServicios.DataTextField = "tipo_servicio";
        //    dpListServicios.DataValueField = "id_tipo_servicio";
        //    dpListServicios.DataBind();

        //}
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["show"] == null)
                {
                    Response.Redirect("IndexPropietario.aspx");
                }
                else
                {
                    try
                    {
                        util       = new csUtilidades();
                        lgServicio = new LogicaServicio();
                        servicio   = lgServicio.SessionServicio(int.Parse(Request.Params["service"].ToString()));
                        bntRegresar.NavigateUrl  = "IndexNegocioPropietario.aspx?show=" + Request.Params["show"];
                        bntRegresar2.NavigateUrl = "IndexNegocioPropietario.aspx?show=" + Request.Params["show"];
                        //CargarList();
                        txtNombre.Text           = servicio.nombre;
                        txtDescripcion.Text      = servicio.descripcion;
                        txtValor.Text            = servicio.valor.ToString();
                        lbImagen.Text            = servicio.imagen;
                        ViewState["codServicio"] = servicio.id_servicio;
                    }
                    catch (Exception ex)
                    {
                        ltError.Text = @"<div class='alert alert-danger'><strong>Error!</strong> " + ex.Message + ".</div>";
                    }
                }
            }
        }
Beispiel #2
0
 protected void btnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         lgServicio = new LogicaServicio();
         HttpFileCollection file = Request.Files;
         util = new csUtilidades();
         for (int i = 0; i <= file.Count - 1; i++)
         {
             HttpPostedFile postefile = file[i];
             String[]       nombres   = new String[file.Count - 1];
             if (postefile.ContentLength > 0)
             {
                 int codService = int.Parse(ViewState["codServicio"].ToString());
                 int codNegocio = int.Parse(util.desencriptar(Request.Params["show"].ToString()));
                 postefile.SaveAs(Server.MapPath(@"media\img\") + Path.GetFileName(postefile.FileName));
                 servicio = new csServicio(codService, txtNombre.Text, txtDescripcion.Text, postefile.FileName.ToString(), "", "", int.Parse(txtValor.Text), codNegocio);
                 if (lgServicio.ModificarServicio(servicio))
                 {
                     Button2_ModalPopupExtender.Show();
                 }
                 else
                 {
                     ltError.Text = @"<div class='alert alert-danger'>
                   <strong>Error!</strong> " + "Servicio Modificado" + ".</div>";
                 }
             }
             else
             {
                 int codService = int.Parse(ViewState["codServicio"].ToString());
                 int codNegocio = int.Parse(util.desencriptar(Request.Params["show"].ToString()));
                 servicio = new csServicio(codService, txtNombre.Text, txtDescripcion.Text, "", "", "", int.Parse(txtValor.Text), codNegocio);
                 if (lgServicio.ModificarServicio2(servicio))
                 {
                     Button2_ModalPopupExtender.Show();
                 }
                 else
                 {
                     ltError.Text = @"<div class='alert alert-danger'>
                   <strong>Error!</strong> " + "Servicio Modificado" + ".</div>";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ltError.Text = @"<div class='alert alert-danger'>
                   <strong>Error!</strong> " + ex.Message + ".</div>";
     }
 }
Beispiel #3
0
 protected void btnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         util = new csUtilidades();
         int codnegocio = int.Parse(util.desencriptar(Request.Params["show"]));
         lgServicio = new LogicaServicio();
         DateTime time  = DateTime.Now;
         string   fecha = time.Date.ToString("yyyy-MM-dd");
         //string hora = time.TimeOfDay.ToString("HH:mm");
         string             hora = "14:05:12";
         HttpFileCollection file = Request.Files;
         for (int i = 0; i <= file.Count - 1; i++)
         {
             HttpPostedFile postefile = file[i];
             String[]       nombres   = new String[file.Count - 1];
             if (postefile.ContentLength > 0)
             {
                 postefile.SaveAs(Server.MapPath(@"media\img\") + Path.GetFileName(postefile.FileName));
                 servicio = new csServicio(0, txtNombre.Text, txtDescripcion.Text, postefile.FileName.ToString(), fecha, hora, int.Parse(txtValor.Text), codnegocio);
                 if (lgServicio.CrearServicio(servicio))
                 {
                     Button2_ModalPopupExtender.Show();
                 }
                 else
                 {
                     ltError.Text = @"<div class='alert alert-danger'>
                   <strong>Error!</strong> " + "Servicio no creado" + ".</div>";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ltError.Text = @"<div class='alert alert-danger'>
                   <strong>Error!</strong> " + ex.Message + ".</div>";
     }
 }