Example #1
0
    protected void btUsersOK_Click(object sender, EventArgs e)
    {
        Guid groupID;

        if (!Guid.TryParse(hdUsersGroupID.Value, out groupID))
        {
            return;
        }

        Guid userID;

        if (!Guid.TryParse(lstUsers.SelectedValue, out userID))
        {
            return;
        }

        AccessLevelEnum accessLevel;

        if (!Enum.TryParse(ddlAccessLevels.SelectedItem.Value.ToString(), out accessLevel))
        {
            return;
        }

        var group = DataContext.UM_Groups.FirstOrDefault(n => n.ID == groupID);

        if (group == null)
        {
            return;
        }

        var user = DataContext.UM_Users.FirstOrDefault(n => n.ID == userID);

        if (user == null)
        {
            return;
        }

        var exists = DataContext.UM_GroupUsers.Count(n => n.DateDeleted == null && n.GroupID == groupID && n.UserID == userID) > 0;

        if (exists)
        {
            return;
        }

        var groupUser = new UM_GroupUser
        {
            ID          = Guid.NewGuid(),
            DateCreated = DateTime.Now,
            GroupID     = groupID,
            UserID      = userID,
            AccessLevel = (int)accessLevel
        };

        DataContext.UM_GroupUsers.InsertOnSubmit(groupUser);
        DataContext.SubmitChanges();

        CacheEntitiesUtil.ResetAll();
        tlGroups.RefreshVirtualTree();
    }
Example #2
0
    protected void lnkDelete_Click(object sender, EventArgs e)
    {
        var lnkBtn = sender as ImageLinkButton;

        if (lnkBtn == null)
        {
            return;
        }

        var nodeKeyObject = NodeKeyObject.Parse(lnkBtn.CommandArgument);

        if (nodeKeyObject == null)
        {
            return;
        }

        if (nodeKeyObject.IsProjectType())
        {
            return;
        }

        if (nodeKeyObject.IsGroupType() || nodeKeyObject.IsChildType())
        {
            var @group = DataContext.UM_Groups.FirstOrDefault(n => n.ID == nodeKeyObject.GroupID);
            if (@group != null)
            {
                foreach (var groupUser in @group.GroupUsers)
                {
                    groupUser.DateDeleted = DateTime.Now;
                }

                @group.DateDeleted = DateTime.Now;
            }

            DataContext.SubmitChanges();
        }
        else if (nodeKeyObject.IsUserType())
        {
            var groupUsers = (from n in DataContext.UM_GroupUsers
                              where n.DateDeleted == null &&
                              n.GroupID == nodeKeyObject.GroupID &&
                              n.UserID == nodeKeyObject.UserID
                              select n).ToList();

            foreach (var groupUser in groupUsers)
            {
                groupUser.DateDeleted = DateTime.Now;
            }

            DataContext.SubmitChanges();
        }

        CacheEntitiesUtil.ResetAll();
        tlGroups.RefreshVirtualTree();
    }
Example #3
0
    protected void lnkEdit_Click(object sender, EventArgs e)
    {
        var lnkBtn = sender as ImageLinkButton;

        if (lnkBtn == null)
        {
            return;
        }

        var nodeKeyObject = NodeKeyObject.Parse(lnkBtn.CommandArgument);

        if (nodeKeyObject == null)
        {
            return;
        }

        if (nodeKeyObject.IsProjectType())
        {
            return;
        }

        if (nodeKeyObject.IsGroupType() || nodeKeyObject.IsChildType())
        {
            ResetGroupForm();

            var group = DataContext.UM_Groups.FirstOrDefault(n => n.ID == nodeKeyObject.GroupID);
            if (group == null)
            {
                return;
            }

            FillGroupForm(group);

            context.Text = "ჯგუფის რედაქტირება";
            upnlGroup.Update();
            mpeGroup.Show();
        }
        else if (nodeKeyObject.IsUserType())
        {
            return;
        }

        CacheEntitiesUtil.ResetAll();
        // tlGroups.RefreshVirtualTree();
    }
Example #4
0
    protected void btGroupOK_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrWhiteSpace(tbGroupName.Text))
        {
            lblGroupError.Text = "შეიყვანეთ სახელი";

            upnlGroup.Update();
            mpeGroup.Show();

            return;
        }

        if (String.IsNullOrWhiteSpace(hdMainGroupParentID.Value))
        {
            lblGroupError.Text = "მონიშნეთ პროექტი";

            upnlGroup.Update();
            mpeGroup.Show();

            return;
        }

        var projectID = Guid.Parse(hdMainGroupParentID.Value);

        var project = DataContext.UM_Projects.FirstOrDefault(n => n.ID == projectID);

        if (project == null)
        {
            return;
        }

        UM_Group group;

        Guid groupID;

        if (Guid.TryParse(hdMainGroupID.Value, out groupID))
        {
            group = DataContext.UM_Groups.FirstOrDefault(n => n.ID == groupID);
            if (group == null)
            {
                return;
            }
        }
        else
        {
            group             = new UM_Group();
            group.ID          = Guid.NewGuid();
            group.DateCreated = DateTime.Now;
            DataContext.UM_Groups.InsertOnSubmit(group);
        }


        group.Name      = tbGroupName.Text;
        group.ProjectID = Guid.Parse(hdMainGroupParentID.Value);
        var parentID = hdParentID.Value;

        if (parentID == String.Empty)
        {
            group.ParentID = null;
        }
        else
        {
            group.ParentID = Guid.Parse(parentID);
        }

        DataContext.SubmitChanges();

        CacheEntitiesUtil.ResetAll();
        tlGroups.RefreshVirtualTree();
    }