Exemple #1
0
 private void CreateUpdateAssignmentButton_Click(object sender, EventArgs e)
 {
     if (this.CreateUpdateAssignmentButton.Text != "Update Assignment")
     {
         Assignment a = manager.CreateAssignment(AssignmentNameTextBox.Text, DescriptionTextBox.Text, Scheduler.CongregationId, Convert.ToInt32(AmountPerMeetingPicker.Value), Convert.ToInt32(schedulePositionPicker.Value), Scheduler.Id);
         assignmentProfileForm.AssignmentsGridBox = cc.MemberAssignmentBox(assignmentProfileForm.AssignmentsGridBox, Scheduler);
         MessageBox.Show("Assignment " + a.Label + " created.");
         this.Close();
     }
     else
     {
         AssignmentUpdate.Label              = this.AssignmentNameTextBox.Text;
         AssignmentUpdate.Description        = this.DescriptionTextBox.Text;
         AssignmentUpdate.AmountPerMeeting   = Convert.ToInt32(this.AmountPerMeetingPicker.Value);
         AssignmentUpdate.PositionOnSchedule = Convert.ToInt32(this.schedulePositionPicker.Value);
         Assignment ua = manager.UpdateAssignment(AssignmentUpdate);
         MessageBox.Show(ua.Label + " assignment updated.");
         assignmentProfileForm.AssignmentsGridBox = cc.MemberAssignmentBox(assignmentProfileForm.AssignmentsGridBox, Scheduler);
         this.Close();
     }
 }
        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.");
            }
        }