コード例 #1
0
        private void MemberAssignmentsButton_Click(object sender, EventArgs e)
        {
            List <MemberAssignment> ma = manager.MemberAssignmentsByMemberId(SelectedMember.Id);

            foreach (DataGridViewRow r in MemberAssignmentsGridBox.Rows)
            {
                if (Convert.ToBoolean(r.Cells["IsAssigned"].Value) == true)
                {
                    if (ma.All(z => z.AssignmentId != Convert.ToInt32(r.Cells["AssignementId"].Value)))
                    {
                        MemberAssignment newMa = manager.CreateMemberAssignment(SelectedMember.Id, Convert.ToInt32(r.Cells["AssignementId"].Value), SelectedMember.CongregationId);
                    }
                }
                if (Convert.ToBoolean(r.Cells["IsAssigned"].Value) == false)
                {
                    List <MemberAssignment> toBeRemoved = (from remove in ma
                                                           where remove.AssignmentId == Convert.ToInt32(r.Cells["AssignementId"].Value)
                                                           select remove).ToList();
                    if (toBeRemoved.Count != 0)
                    {
                        manager.DeleteMemberAssignement(toBeRemoved[0].Id);
                    }
                }
            }
            MemberAssignmentsGridBox = cc.MemberAssignmentBox(MemberAssignmentsGridBox, SelectedMember);
            MessageBox.Show("Member Assignments Updated.");
        }
コード例 #2
0
        private void AddUpdateMember_Click(object sender, EventArgs e)
        {
            Member newMember = new Member();

            if (neccessaryFieldsOnly == false) //check to see if username and password are not duplicated
            {
                int count = manager.MemberByUsername(UserNameTextBox.Text.Replace(" ", ""));
                if (count == 0)
                {
                    newMember = manager.CreateMember(FirstName.Text, MiddleName.Text, LastName.Text, PreferredName.Text, DateOfBirthPicker.Value, BaptismDatePicker.Value, Email.Text,
                                                     ContactNumber.Text.Replace("-", ""), UserNameTextBox.Text, PasswordTextBox.Text, congo.Id);
                }
                else
                {
                    MessageBox.Show("Username is already taken.");
                    return;
                }
            }
            else if (update == false)
            {
                newMember = manager.CreateMember(FirstName.Text, PreferredName.Text, LastName.Text, Email.Text, ContactNumber.Text, congo.Id);
                emf.CurrentMembersGridBox = cc.CurrentMembersBox(emf.CurrentMembersGridBox, congo.Id);
            }
            else
            {
                newMember.Id              = emf.SelectedMember.Id;
                newMember.FirstName       = FirstName.Text;
                newMember.LastName        = LastName.Text;
                newMember.PreferredName   = PreferredName.Text;
                newMember.ContactNumber   = ContactNumber.Text;
                newMember.Email           = Email.Text;
                emf.SelectedMember        = manager.UpdateMember(newMember, true);
                emf.CurrentMembersGridBox = cc.CurrentMembersBox(emf.CurrentMembersGridBox, congo.Id);
                this.Close();
                if (emf.SelectedMember.PreferredName == null || emf.SelectedMember.PreferredName == "")
                {
                    MessageBox.Show(emf.SelectedMember.FirstName + " " + emf.SelectedMember.LastName + " profile has been updated.");
                }
                else
                {
                    MessageBox.Show(emf.SelectedMember.PreferredName + " profile has been update.");
                }
                return;
            }

            if (firstMember == true)
            {
                Assignment scheduler = manager.CreateAssignment("Assignment Scheduler", "Creates and schedules assignments for the meetings.", congo.Id, null, null, newMember.Id);
                manager.CreateAssignment("Sound Box", "Handles sound duties for meeting.", congo.Id, 1, 1, newMember.Id);
                manager.CreateAssignment("Stage", "Handles stage duties for meeting.", congo.Id, 1, 2, newMember.Id);
                manager.CreateAssignment("Microphone", "Handles microphone for meeting.", congo.Id, 2, 3, newMember.Id);
                manager.CreateAssignment("Attendant", "Greets, sits, and takes count of congregation for meetings.", congo.Id, 2, 4, newMember.Id);
                manager.CreateAssignment("Elder", "Elder in congregation.", congo.Id, null, null, newMember.Id);
                manager.CreateAssignment("Ministerial Servant", "Ministerial Servant in congregation.", congo.Id, null, null, newMember.Id);
                MemberAssignment schedulermember = manager.CreateMemberAssignment(newMember.Id, scheduler.Id, newMember.CongregationId);
            }
            this.Close();
            if (newMember.PreferredName == null || newMember.PreferredName == "")
            {
                MessageBox.Show(newMember.FirstName + " " + newMember.LastName + " have been added to Members.");
            }
            else
            {
                MessageBox.Show(newMember.PreferredName + " have been added to Members.");
            }
        }