コード例 #1
0
ファイル: group.cs プロジェクト: AlexanderJW97/the-S.A.L.A.H.
        public static string getGroupLocation(string groupId)
        {
            string groupLocation;

            try
            {
                int   intGroupId = int.Parse(groupId);
                group groupQuery = new group();

                using (var ctx = new SALAHContext())
                {
                    groupQuery = ctx.Groups.FirstOrDefault(m => m.groupID == intGroupId);

                    groupLocation = location.getLocationWId(groupQuery.location_ID).locationName;
                    return(groupLocation);
                }
            }
            catch (Exception e)
            {
                groupLocation = null;
                return(groupLocation);
            }
        }
コード例 #2
0
        public static location getLocationWId(string locationID)
        {
            location location = new location();

            if (locationID != null && locationID != "")
            {
                int locationIDInt = int.Parse(locationID);
                using (var ctx = new SALAHContext())
                {
                    var query = from data in ctx.Locations //create a query to find the groupIDs of the logged in user
                                where data.locationID == locationIDInt
                                select new { data.locationName, data.Address, data.resourceIDs };

                    foreach (var result in query)
                    {
                        location.locationName = result.locationName;
                        location.Address      = result.Address;
                        location.resourceIDs  = result.resourceIDs;
                    }
                }
            }
            return(location);
        }
コード例 #3
0
        public static string[] getMeetingNames(string[] meetingIDs)
        {
            string[] meetingNames = new string[meetingIDs.Length];

            int i = 0;

            using (var ctx = new SALAHContext())
            {
                foreach (string s in meetingIDs)
                {
                    int idInt = 0;
                    if (s != null && s != "")
                    {
                        idInt = int.Parse(s);
                    }
                    var query = from data in ctx.Meetings //create a query to find the groupIDs of the logged in user
                                where data.meetingID == idInt
                                select new { data.meetingTitle };

                    foreach (var result in query)
                    {
                        string title = result.meetingTitle;
                        if (title != "" && title != null)
                        {
                            meetingNames[i] = result.meetingTitle;
                        }
                        else if (title == "" || title == null)
                        {
                            meetingNames[i] = "No title given";
                        }
                    }
                    i++;
                }
            }

            return(meetingNames);
        }
コード例 #4
0
ファイル: group.cs プロジェクト: AlexanderJW97/the-S.A.L.A.H.
        public static string[] getGroupNames(user user)
        {
            string[] userGroups         = user.groupIDs.Split(',');
            string[] existingGroupNames = new string[userGroups.Length - 1];
            int      i = 0;

            try
            {
                using (var ctx = new SALAHContext())
                {
                    foreach (string s in userGroups)
                    {
                        int groupID;
                        if (s != "")
                        {
                            groupID = int.Parse(s);

                            group groupNamesQuery = ctx.Groups.FirstOrDefault(g => g.groupID == groupID);
                            if (groupNamesQuery != null)
                            {
                                existingGroupNames[i] = groupNamesQuery.group_name;
                                i++;
                            }
                            if (groupNamesQuery == null)
                            {
                                user.groupRemovedFromUser(groupID, user);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("New group could not be created. Please try again with a different group name");
            }
            return(existingGroupNames);
        }
コード例 #5
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("Are you sure you want to save your changes?",
                                                "Save changes",
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                if (newGroup.group_name == currentGroup.group_name || newGroup.group_name == null)
                {
                    moveGroup = false;
                }

                location.changeLocationsGroup(currentLocation, currentGroup, newGroup, moveGroup);

                int locationId = currentLocation.locationID;

                using (var ctx = new SALAHContext())
                {
                    var result = ctx.Locations.SingleOrDefault(l => l.locationID == locationId);
                    if (result != null)
                    {
                        result.locationName = locationNameTxtBx.Text;
                        result.venueNotes   = venueNotesTxtBx.Text;
                        result.Address      = CreateAddress();
                    }

                    ctx.SaveChanges();
                    ctx.Dispose();
                }

                main_screen open_screen = new main_screen(currentUser);
                this.Close();
                open_screen.Show();
            }
        }
コード例 #6
0
ファイル: user.cs プロジェクト: AlexanderJW97/the-S.A.L.A.H.
        /// <summary>
        /// adds the users groups into the combobox for selection
        /// </summary>
        /// <param name="comboBox">target combo box</param>
        /// <param name="groups">string array of groups to be added</param>
        public static void AddGroupsToComboBox(ComboBox comboBox, string[] groups)
        {
            int length = groups.Length; //get length of the groupID array

            int groupID = 0;

            string[] groupNames = new string[length]; //new array to hold the names of the groups

            using (var ctx = new SALAHContext())
            {
                for (int i = 0; i < length; i++)
                {
                    if (groups[i] != "")
                    {
                        groupID = int.Parse(groups[i]);     //parse the groupID from the groupID string array into a int variable

                        var query = from data in ctx.Groups //create a query to find the name of the group from the groupID
                                    where data.groupID == groupID
                                    select new { data.group_name };

                        foreach (var result in query)
                        {
                            if (result.group_name != null && result.group_name != "")
                            {
                                groupNames[i] = result.group_name; //add the group name into the groupnames array
                            }
                        }

                        if (groupNames[i] != null && groupNames[i] != "")
                        {
                            comboBox.Items.Add(groupNames[i]); //add the latest array entry into the combobox
                        }
                    }
                }
            }
        }
コード例 #7
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("Are you sure you want to save your changes to this resource?",
                                                "Save Changes",
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                if (newLocation.locationID == currentLocation.locationID)
                {
                    moveLocation = false;
                }

                resource.ChangeLocationOfResource(currentResource.resourceID, currentLocation.locationID, newLocation.locationID, moveLocation);

                int resourceId = currentResource.resourceID;

                using (var ctx = new SALAHContext())
                {
                    var result = ctx.Resources.SingleOrDefault(r => r.resourceID == resourceId);
                    if (result != null)
                    {
                        result.name     = resourceNameTxtBx.Text;
                        result.notes    = resourceNotesTxtBx.Text;
                        result.quantity = int.Parse(quantityUpDown.Text);
                    }

                    ctx.SaveChanges();
                    ctx.Dispose();
                }

                main_screen open_screen = new main_screen(currentUser);
                this.Close();
                open_screen.Show();
            }
        }