Exemplo n.º 1
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ctxmenu_Edit.SourceControl == olv_Groups && olv_Groups.SelectedObject != null)
     {
         var users = SynapseUser.LoadFromQuery("SELECT * FROM [SYNAPSE].[dbo].[V_Synapse_UserGroups] WHERE P_TECHNICALNAME = '" + ((SynapseProfile)olv_Groups.SelectedObject).TECHNICALNAME + "'");
         if (users.Count == 0)
         {
             ((SynapseProfile)olv_Groups.SelectedObject).delete();
             olv_Groups.RemoveObject(olv_Groups.SelectedObject);
         }
         else
         {
             string text = string.Empty;
             foreach (SynapseUser user in users)
             {
                 text += string.Format("{0} {1} ({2})\n", user.FIRSTNAME, user.LASTNAME, user.UserID);
             }
             MessageBox.Show("There are still some users assigned to this group please delete them first\n" + text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     if (ctxmenu_Edit.SourceControl == olv_Users && olv_Users.SelectedObject != null)
     {
         var usergroups = SynapseUser_Profile.Load("WHERE FK_SECURITY_USER = " + ((SynapseUser)olv_Users.SelectedObject).ID);
         foreach (SynapseUser_Profile sup in usergroups)
         {
             sup.delete();
         }
         ((SynapseUser)olv_Users.SelectedObject).delete();
         olv_Users.RemoveObject(olv_Users.SelectedObject);
         olv_GroupsOfUser.Clear();
     }
 }
Exemplo n.º 2
0
        private void DeleteGroup_Click(object sender, EventArgs e)
        {
            SynapseProfile _profile = new SynapseProfile();

            switch (tabControl1.SelectedIndex)
            {
            case 0:
                _profile = (SynapseProfile)olvGroups.SelectedObject;
                break;

            case 1:
                _profile = (SynapseProfile)olvGroups2.SelectedObject;
                break;
            }

            var users = SynapseUser.LoadFromQuery("SELECT * FROM [SYNAPSE].[dbo].[V_Synapse_UserGroups] WHERE P_TECHNICALNAME = '" + _profile.TECHNICALNAME + "'");

            if (users.Count == 0)
            {
                if (MessageBox.Show(GetLabel("Quest.0002"), GetLabel("Quest"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    SynapseCore.Database.DBFunction.StartTransaction();
                    try
                    {
                        foreach (SynapseLabel obj in _profile.Description.Labels)
                        {
                            obj.delete();
                        }
                        _profile.delete();

                        SynapseCore.Database.DBFunction.CommitTransaction();

                        olvGroups.RemoveObject(_profile);
                        olvGroups2.RemoveObject(_profile);
                    }
                    catch (Exception ex)
                    {
                        SynapseCore.Database.DBFunction.RollbackTransaction();
                        MessageBox.Show("Data not deleted from Database:" + ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                string text = string.Empty;
                foreach (SynapseUser user in users)
                {
                    text += string.Format("{0} {1} ({2})\n", user.FIRSTNAME, user.LASTNAME, user.UserID);
                }
                MessageBox.Show(GetLabel("Err.0003") + text, GetLabel("Err"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 3
0
 private void listUsersToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ctxmenu_Edit.SourceControl == olv_Groups && olv_Groups.SelectedObject != null)
     {
         var    users = SynapseUser.LoadFromQuery("SELECT * FROM [SYNAPSE].[dbo].[V_Synapse_UserGroups] WHERE P_TECHNICALNAME = '" + ((SynapseProfile)olv_Groups.SelectedObject).TECHNICALNAME + "'");
         string text  = string.Empty;
         foreach (SynapseUser user in users)
         {
             text += string.Format("{0} {1} ({2})\n", user.FIRSTNAME, user.LASTNAME, user.UserID);
         }
         MessageBox.Show(text, "List of users", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 4
0
        private List <SynapseUser> getUsers(Int64 profileID)
        {
            IList <SynapseUser> userList;

            if (profileID == 0)
            {
                userList = SynapseUser.Load();
            }
            else
            {
                userList = SynapseUser.LoadFromQuery("SELECT dbo.Synapse_Security_User.* FROM dbo.Synapse_Security_User INNER JOIN dbo.[Synapse_Security_User Profile] ON dbo.Synapse_Security_User.ID = dbo.[Synapse_Security_User Profile].FK_SECURITY_USER WHERE dbo.[Synapse_Security_User Profile].FK_SECURITY_PROFILE = " + profileID);
            }
            return(userList.OrderBy(n => n.UserID.ToString()).ToList());
        }
Exemplo n.º 5
0
 public IList <SynapseUser> GetOwners()
 {
     return(SynapseUser.LoadFromQuery("SELECT     DISTINCT dbo.Synapse_Security_User.* FROM         dbo.Synapse_Security_Profile INNER JOIN dbo.[Synapse_Security_User Profile] ON dbo.Synapse_Security_Profile.ID = dbo.[Synapse_Security_User Profile].FK_SECURITY_PROFILE INNER JOIN dbo.Synapse_Security_User ON dbo.[Synapse_Security_User Profile].FK_SECURITY_USER = dbo.Synapse_Security_User.ID WHERE     (dbo.Synapse_Security_Profile.IS_OWNER = 1) and dbo.Synapse_Security_Profile.FK_MODULEID=" + this.ID.ToString()));
 }