protected void gridEjes_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // Logger variables
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true);
            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
            string className  = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
            string methodName = stackFrame.GetMethod().Name;


            int camion_ejes_ID = Convert.ToInt32(gridEjes.DataKeys[e.RowIndex].Value);

            using (bonisoftEntities context = new bonisoftEntities())
            {
                camion_ejes obj = context.camion_ejes.First(x => x.Camion_ejes_ID == camion_ejes_ID);
                context.camion_ejes.Remove(obj);
                context.SaveChanges();

                #region Guardar log
                try
                {
                    string userID1  = HttpContext.Current.Session["UserID"].ToString();
                    string username = HttpContext.Current.Session["UserName"].ToString();
                    Global_Objects.Logs.AddUserLog("Borra ejes de camión", obj.GetType().Name + ": " + obj.Camion_ejes_ID, userID1, username);
                }
                catch (Exception ex)
                {
                    Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message);
                }
                #endregion

                BindGrid();
                lblMessage.Text = "Borrado correctamente.";
            }
        }
        protected void gridEjes_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            // Logger variables
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true);
            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
            string className  = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
            string methodName = stackFrame.GetMethod().Name;


            if (e.CommandName == "InsertNew")
            {
                GridViewRow row  = gridEjes.FooterRow;
                TextBox     txb1 = row.FindControl("txbNew1") as TextBox;
                TextBox     txb2 = row.FindControl("txbNew2") as TextBox;
                if (txb1 != null && txb2 != null)
                {
                    using (bonisoftEntities context = new bonisoftEntities())
                    {
                        camion_ejes obj = new camion_ejes();
                        obj.Ejes        = txb1.Text;
                        obj.Comentarios = txb2.Text;

                        context.camion_ejes.Add(obj);
                        context.SaveChanges();

                        #region Guardar log
                        try
                        {
                            int         id           = 1;
                            camion_ejes camion_ejes1 = (camion_ejes)context.camion_ejes.OrderByDescending(p => p.Camion_ejes_ID).FirstOrDefault();
                            if (camion_ejes1 != null)
                            {
                                id = camion_ejes1.Camion_ejes_ID;
                            }

                            string userID1  = HttpContext.Current.Session["UserID"].ToString();
                            string username = HttpContext.Current.Session["UserName"].ToString();
                            Global_Objects.Logs.AddUserLog("Agrega ejes de camión", camion_ejes1.GetType().Name + ": " + id, userID1, username);
                        }
                        catch (Exception ex)
                        {
                            Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message);
                        }
                        #endregion

                        lblMessage.Text = "Agregado correctamente.";
                        BindGrid();
                    }
                }
            }
        }
        protected void gridEjes_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            // Logger variables
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true);
            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
            string className  = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
            string methodName = stackFrame.GetMethod().Name;


            GridViewRow row  = gridEjes.Rows[e.RowIndex];
            TextBox     txb1 = row.FindControl("txb1") as TextBox;
            TextBox     txb2 = row.FindControl("txb2") as TextBox;

            if (txb1 != null && txb2 != null)
            {
                using (bonisoftEntities context = new bonisoftEntities())
                {
                    int         camion_ejes_ID = Convert.ToInt32(gridEjes.DataKeys[e.RowIndex].Value);
                    camion_ejes obj            = context.camion_ejes.First(x => x.Camion_ejes_ID == camion_ejes_ID);
                    obj.Ejes        = txb1.Text;
                    obj.Comentarios = txb2.Text;

                    context.SaveChanges();

                    #region Guardar log
                    try
                    {
                        string userID1  = HttpContext.Current.Session["UserID"].ToString();
                        string username = HttpContext.Current.Session["UserName"].ToString();
                        Global_Objects.Logs.AddUserLog("Modifica ejes de camión", obj.GetType().Name + ": " + obj.Camion_ejes_ID, userID1, username);
                    }
                    catch (Exception ex)
                    {
                        Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message);
                    }
                    #endregion

                    lblMessage.Text    = "Guardado correctamente.";
                    gridEjes.EditIndex = -1;
                    BindGrid();
                }
            }
        }
        protected void gridCamiones_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            #region Updatepanel triggers

            ScriptManager ScriptManager1 = ScriptManager.GetCurrent(this.Page);
            if (ScriptManager1 != null)
            {
                LinkButton lnk = null;
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    lnk = e.Row.FindControl("lnkEdit") as LinkButton;
                    if (lnk != null)
                    {
                        ScriptManager1.RegisterAsyncPostBackControl(lnk);
                    }

                    lnk = e.Row.FindControl("lnkDelete") as LinkButton;
                    if (lnk != null)
                    {
                        ScriptManager1.RegisterAsyncPostBackControl(lnk);
                    }

                    lnk = e.Row.FindControl("lnkInsert") as LinkButton;
                    if (lnk != null)
                    {
                        ScriptManager1.RegisterAsyncPostBackControl(lnk);
                    }

                    lnk = e.Row.FindControl("lnkCancel") as LinkButton;
                    if (lnk != null)
                    {
                        ScriptManager1.RegisterAsyncPostBackControl(lnk);
                    }
                }
            }

            #endregion

            #region DDL Options

            DropDownList ddl = null;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ddl = e.Row.FindControl("ddlEjes1") as DropDownList;
            }
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                ddl = e.Row.FindControl("ddlEjes2") as DropDownList;
            }
            if (ddl != null)
            {
                using (bonisoftEntities context = new bonisoftEntities())
                {
                    DataTable dt1 = new DataTable();
                    dt1 = Extras.ToDataTable(context.camion_ejes.ToList());

                    ddl.DataSource     = dt1;
                    ddl.DataTextField  = "Ejes";
                    ddl.DataValueField = "Camion_ejes_ID";
                    ddl.DataBind();
                    ddl.Items.Insert(0, new ListItem("Elegir", "0"));
                }
            }

            #endregion

            #region DDL Default values

            // Ejes ----------------------------------------------------
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton lbl = e.Row.FindControl("lbl3") as LinkButton;
                if (lbl != null)
                {
                    using (bonisoftEntities context = new bonisoftEntities())
                    {
                        camion camion = (camion)(e.Row.DataItem);
                        if (camion != null)
                        {
                            int         id          = camion.Ejes_ID;
                            camion_ejes camion_ejes = (camion_ejes)context.camion_ejes.FirstOrDefault(c => c.Camion_ejes_ID == id);
                            if (camion_ejes != null)
                            {
                                string nombre = camion_ejes.Ejes;
                                lbl.Text            = nombre;
                                lbl.CommandArgument = "ejes," + nombre;
                            }
                        }
                    }
                }
            }

            #endregion DDL Default values
        }