コード例 #1
0
 protected void ListaAreas_GV_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Editar")
     {
         try
         {
             int id = Convert.ToInt32(e.CommandArgument);
             Response.Redirect("Area.aspx?id=" + id);
         }
         catch (Exception ex)
         { throw ex; }
     }
     if (e.CommandName == "Eliminar")
     {
         try
         {
             int id = Convert.ToInt32(e.CommandArgument);
             //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('id=" + id + "')", true);
             AreaBLL.DeleteArea(id);
             CargarLista();
         }
         catch (Exception ex)
         { throw ex; }
     }
 }
コード例 #2
0
    protected void DeleteArea_Click(object sender, EventArgs e)
    {
        LinkButton btnClick = (LinkButton)sender;
        int        areaId   = Convert.ToInt32(btnClick.Attributes["data-id"]);

        try
        {
            AreaBLL.DeleteArea(areaId);
        }
        catch (Exception ex)
        {
            SystemMessages.DisplaySystemErrorMessage(ex.Message);
            return;
        }

        AreasGridView.DataBind();

        SystemMessages.DisplaySystemMessage(Resources.Organization.MessageDeleteAreaOk);
    }
コード例 #3
0
    protected void ListaAreaGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int moduloId = Convert.ToInt32(e.CommandArgument);

        if (e.CommandName == "Eliminar")
        {
            try
            {
                AreaBLL.DeleteArea(moduloId);
                cargarListaAreas("");
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('No se puede eliminar por que esta Area esta siendo utilizado');", true);
                log.Error("Error al eliminar el usuario con el id '" + moduloId + "'", ex);
            }
        }
        if (e.CommandName == "Editar")
        {
            Session["AreaId"] = moduloId;
            Response.Redirect("~/Administracion/Area/RegistrarArea.aspx");
        }
    }
コード例 #4
0
    protected void AreasGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Actualizar")
        {
            int areaId = 0;
            try
            {
                areaId = Convert.ToInt32(e.CommandArgument);
            }
            catch (Exception ex)
            {
                log.Error("Error getting object id", ex);
            }

            if (areaId <= 0)
            {
                SystemMessages.DisplaySystemErrorMessage(Resources.Organization.MessageNoComplete);
                return;
            }

            GridViewRow oItem = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;

            if (oItem == null)
            {
                SystemMessages.DisplaySystemErrorMessage(Resources.Organization.MessageNoComplete);
                return;
            }

            TextBox nameTextBox = (TextBox)oItem.Cells[2].FindControl("NameTextBox");

            if (nameTextBox == null)
            {
                SystemMessages.DisplaySystemErrorMessage(Resources.Organization.MessageNoComplete);
                return;
            }

            try
            {
                AreaBLL.UpdateArea(areaId, nameTextBox.Text);
            }
            catch (Exception ex)
            {
                SystemMessages.DisplaySystemErrorMessage(ex.Message);
                return;
            }

            Session["OrganizationId"] = OrganizationIdHiddenField.Value;
            Response.Redirect("~/Organization/EditOrganization.aspx");
        }
        else if (e.CommandName == "Eliminar")
        {
            int areaId = 0;

            try
            {
                areaId = Convert.ToInt32(e.CommandArgument);
            }
            catch (Exception ex)
            {
                log.Error("Error getting object id", ex);
            }

            if (areaId <= 0)
            {
                SystemMessages.DisplaySystemErrorMessage(Resources.Organization.MessageNoComplete);
                return;
            }

            try
            {
                AreaBLL.DeleteArea(areaId);
            }
            catch (Exception ex)
            {
                SystemMessages.DisplaySystemErrorMessage(ex.Message);
                return;
            }

            Session["OrganizationId"] = OrganizationIdHiddenField.Value;
            Response.Redirect("~/Organization/EditOrganization.aspx");
        }
    }