Ejemplo n.º 1
0
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (this.CboRoles.SelectedValue != null && this.GridView1.SelectedValue != null)
        {
            ConosudDataContext dc = new ConosudDataContext();

            if ((from ur in dc.SegUsuarioRols
                 where ur.Rol == long.Parse(this.CboRoles.SelectedValue) &&
                 ur.Usuario == long.Parse(this.GridView1.SelectedValue.ToString())
                 select ur).Count() == 0)
            {
                SegRol rol = (from u in dc.SegRols
                              where u.IdSegRol == long.Parse(this.CboRoles.SelectedValue)
                              select u).First();

                SegUsuario usu = (from u in dc.SegUsuarios
                                  where u.IdSegUsuario == long.Parse(this.GridView1.SelectedValue.ToString())
                                  select u).First();

                SegUsuarioRol ConfRol = new SegUsuarioRol();
                ConfRol.ObjSegRol     = rol;
                ConfRol.ObjSegUsuario = usu;

                dc.SegUsuarioRols.InsertOnSubmit(ConfRol);
                dc.SubmitChanges();

                this.GridView2.DataBind();
            }
            else
            {
                string alert = "alert('Ya existe este rol para este usuario');";
                System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "click", alert, true);
            }
        }
    }
Ejemplo n.º 2
0
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (this.CboMenus.SelectedValue != null && this.GridView1.SelectedValue != null)
        {
            ConosudDataContext dc = new ConosudDataContext();

            if ((from rm in dc.SegRolMenus
                 where rm.Menu == long.Parse(this.CboMenus.SelectedValue) &&
                 rm.Rol == long.Parse(this.GridView1.SelectedValue.ToString())
                 select rm).Count() == 0)
            {
                SegMenu menu = (from u in dc.SegMenus
                                where u.IdSegMenu == long.Parse(this.CboMenus.SelectedValue)
                                select u).First();

                SegRol rol = (from u in dc.SegRols
                              where u.IdSegRol == long.Parse(this.GridView1.SelectedValue.ToString())
                              select u).First();

                SegRolMenu Confseg = new SegRolMenu();
                Confseg.ObjSegRol  = rol;
                Confseg.ObjSegMenu = menu;

                dc.SegRolMenus.InsertOnSubmit(Confseg);
                dc.SubmitChanges();

                this.GridView2.DataBind();
            }
            else
            {
                string alert = "alert('Ya existe este menu para este rol');";
                System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "click", alert, true);
            }
        }
    }
Ejemplo n.º 3
0
    protected void DeleteRoles()
    {
        long   idRol = Convert.ToInt64(ViewState["idsel"]);
        SegRol _Rol  = (from c in Contexto.SegRol where c.IdSegRol == idRol select c).FirstOrDefault();

        if (_Rol != null)
        {
            try
            {
                Contexto.DeleteObject(_Rol);
                Contexto.SaveChanges();
                this.grillaRoles.Rebind();
            }
            catch (Exception e)
            {
                ScriptManager.RegisterStartupScript(UpdPnlGrilla, typeof(UpdatePanel), "Error Grabacion", "alert(" + e.Message + ")", true);
            }
        }
    }
Ejemplo n.º 4
0
    protected void InsertRoles(GridEditableItem editedItem)
    {
        long            idPlanilla = Convert.ToInt64(ViewState["idsel"]);
        GridEditManager editMan    = editedItem.EditManager;
        string          Login      = (editedItem.FindControl("LoginTextBox") as TextBox).Text;

        try
        {
            SegRol _Rol = new SegRol();
            _Rol.Descripcion = Login;

            Contexto.AddToSegRol(_Rol);
            Contexto.SaveChanges();
            this.grillaRoles.Rebind();
        }
        catch (Exception e)
        {
            ScriptManager.RegisterStartupScript(this.UpdPnlGrilla, typeof(UpdatePanel), "Error Grabacion", "alert(" + e.Message + ")", true);
        }
    }
Ejemplo n.º 5
0
    protected void UpdateRoles(GridEditableItem editedItem)
    {
        long   idRol = Convert.ToInt64(ViewState["idsel"]);
        SegRol _Rol  = (from c in Contexto.SegRol where c.IdSegRol == idRol select c).FirstOrDefault();

        if (_Rol != null)
        {
            GridEditManager editMan = editedItem.EditManager;
            string          Login   = (editedItem.FindControl("LoginTextBox") as TextBox).Text;

            try
            {
                _Rol.Descripcion = Login;
                Contexto.SaveChanges();
                this.grillaRoles.Rebind();
            }
            catch (Exception e)
            {
                ScriptManager.RegisterStartupScript(UpdPnlGrilla, typeof(UpdatePanel), "Error Grabacion", "alert(" + e.Message + ")", true);
            }
        }
    }