protected void GVTipoEventos_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string IdTipoEvento = GVTipoEventos.DataKeys[e.RowIndex].Values["IdTipoEvento"].ToString();
            string Nombre       = e.NewValues["Nombre"].ToString();
            double Precio       = double.Parse(e.NewValues["Precio"].ToString());
            string Descripcion  = e.NewValues["Descripcion"].ToString();
            //Disponibilidad
            CheckBox ChkAux         = (CheckBox)GVTipoEventos.Rows[e.RowIndex].FindControl("ChkEditDisponible");
            bool     Disponibilidad = ChkAux.Checked;
            string   Clave          = e.NewValues["Clave"].ToString();

            //DropDownList TipoCamionAux = (DropDownList)GVTipoEventos.Rows[e.RowIndex].FindControl("DDLTipoCamion");

            //string TipoCamion = TipoCamionAux.SelectedValue;

            //bool Disponibilidad = bool.Parse(e.NewValues["Disponibilidad"].ToString());

            try
            {
                string resultado = BLLTipoEventos.UpdTipoEvento(int.Parse(IdTipoEvento), Nombre, Precio, Descripcion, null, Disponibilidad, Clave);
                GVTipoEventos.EditIndex = -1;
                RefrescaGrid();
                Util.Library.UtilControls.SweetBox(resultado, "", "success", this.Page, this.GetType());
            }
            catch (Exception ex)
            {
                Util.Library.UtilControls.SweetBox("ERROR!", ex.Message, "danger", this.Page, this.GetType());
            }
        }// fin metodo
        } //btnSubeImagen

        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string Nombre      = txtNombre.Text;
                double Precio      = double.Parse(txtPrecio.Text);
                string Descripcion = txtDescripcion.Text;
                string urlfoto     = UrlFoto.InnerText;
                string Clave       = txtClave.Text;
                string Resultado   =
                    BLLTipoEventos.InsTipoEvento(Nombre, Precio, Descripcion, urlfoto, Clave);

                if (Resultado.IndexOf("Tipo de evento agregado") > -1)
                {
                    Util.Library.UtilControls.SweetBoxConfirm("OK!", Resultado, "success", "ListaTipoEventos.aspx", this.Page, this.GetType());
                }
                else
                {
                    //Mensaje de error
                    Util.Library.UtilControls.SweetBox("Atención!", Resultado, "warning", this.Page, this.GetType());
                }
            }
            catch (Exception ex)
            {
                //Enviar mensaje de error
                Util.Library.UtilControls.SweetBox("ERROR!", ex.Message, "danger", this.Page, this.GetType());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) //Primera carga de la página
            {
                //Obtenemos la información del Camión seleccionado
                string Id = Request.QueryString["Id"];
                if ((Id == null) || (!IsNumeric(Id)))
                {
                    Response.Redirect("ListaTipoEventos.aspx");
                }
                else
                {
                    //Verificamos que el camion exista
                    TipoEventoVO TipoEvento = BLLTipoEventos.GetTipoEventoById(int.Parse(Id));
                    if (TipoEvento.IdTipoEvento == int.Parse(Id))
                    {
                        //Desplegamos la información del camion
                        lblIdTipoEvento.Text = TipoEvento.IdTipoEvento.ToString();

                        txtNombre.Text            = TipoEvento.Nombre;
                        txtPrecio.Text            = TipoEvento.Precio.ToString();
                        txtDescripcion.Text       = TipoEvento.Descripcion;
                        chkDisponibilidad.Checked = TipoEvento.Disponibilidad;
                        txtClave.Text             = TipoEvento.Clave;
                        UrlFoto.InnerText         = TipoEvento.UrlFoto;
                    }
                    else
                    {
                        Response.Redirect("ListaTipoEventos.aspx");
                    }
                }
            }
        }
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         int    IdTipoEvento   = int.Parse(lblIdTipoEvento.Text);
         string Nombre         = txtNombre.Text;
         double Precio         = double.Parse(txtPrecio.Text);
         string Descripcion    = txtDescripcion.Text;
         string urlfoto        = UrlFoto.InnerText;
         bool   Disponibilidad = chkDisponibilidad.Checked;
         string Clave          = txtClave.Text;
         string Resultado      =
             BLLTipoEventos.UpdTipoEvento(IdTipoEvento, Nombre, Precio, Descripcion, urlfoto, Disponibilidad, Clave);
         //BLLCamiones.UpdCamion(IdCamion, Matricula, TipoCamion, Modelo, Marca, Capacidad, Kilometraje, Disponibilidad, urlfoto);
         if (Resultado.IndexOf("Tipo Evento actualizado correctamente") > -1)
         {
             Util.Library.UtilControls.SweetBoxConfirm("OK!", Resultado, "success", "ListaTipoEventos.aspx", this.Page, this.GetType());
         }
         else
         {
             //Mensaje de error
             Util.Library.UtilControls.SweetBox("Atención!", Resultado, "warning", this.Page, this.GetType());
         }
     }
     catch (Exception ex)
     {
         //Enviar mensaje de error
         Util.Library.UtilControls.SweetBox("ERROR!", ex.Message, "danger", this.Page, this.GetType());
     }
 } // del btnGuardar_Click
        }// fin metodo

        protected void GVTipoEventos_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string IdTipoEvento = GVTipoEventos.DataKeys[e.RowIndex].Values["IdTipoEvento"].ToString();

            try
            {
                string Resultado = BLLTipoEventos.DelTipoEvento(int.Parse(IdTipoEvento));
                string mensaje   = "";
                //string sub = "";
                string clase = "";


                if (Resultado == "Tipo Evento eliminado")
                {
                    mensaje = "OK!";
                    clase   = "success";
                    //sub = Resultado;
                }
                else
                {
                    mensaje = "Atención!";
                    clase   = "warning";
                    //sub = Resultado;
                }

                //Creamos el log de borrado
                string[] args = new string[3];
                args[0] = mensaje;
                args[1] = Resultado;// sub;
                args[2] = DateTime.Now.ToShortDateString();
                WriteLog(args);

                RefrescaGrid();
                Util.Library.UtilControls.SweetBox(mensaje, Resultado, clase, this.Page, this.GetType());
            }
            catch (Exception ex)
            {
                Util.Library.UtilControls.SweetBox("ERROR!", ex.Message, "danger", this.Page, this.GetType());
            }
        } // fin de metodo
        } //del PageLoad

        private void RefrescaGrid()
        {
            //Llenar el grid con una lista de CamionVO
            GVTipoEventos.DataSource = BLLTipoEventos.GetLstTipoEventos(null);
            GVTipoEventos.DataBind();
        }  // del RefrescaGrid
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) // es la primer carga de la pagina
            {
                //Llena las lista del formulario
                Util.Library.UtilControls.EnumToListBox(typeof(Comidas), DDLComidas, true);
                //Util.Library.UtilControls.EnumToListBox(typeof(Comidas), DDLComidas, false);

                DDLComidas.Items.Insert(0, new ListItem("Selecciona Comida", ""));
                DDLComidas.SelectedIndex = 0;

                //Llenamos los combos de camión y chofer
                UtilControls.FillDropDownList(DDLTipoEvento, "IdTipoEvento", "Nombre", BLLTipoEventos.GetLstTipoEventos(true), "", "Selecciona Tipo Evento");
                UtilControls.FillDropDownList(DDLCliente, "IdCliente", "Nombre", BLLClientes.GetLstClientes(true), "", "Selecciona Cliente");
                Session["CargaRuta"] = null;
            }
        }