コード例 #1
0
        public DataGridView DatesAvailableBox(DataGridView data, Member selectedMember)
        {
            data.Rows.Clear();
            data.Refresh();
            data.Columns["Date"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            List<UnavailableDate> udates = manager.UnavailableDateByMemberId(selectedMember.Id);
            TimeSpan startSpan = new TimeSpan(21, 0, 0, 0);
            TimeSpan endSpan = new TimeSpan(120, 0, 0, 0);
            DateTime start = DateTime.Now - startSpan;
            DateTime end = DateTime.Now + endSpan;
            string dayOfWeekMeeting = selectedMember.Congregation.WeekMeetingDay;
            string dayOfPublicMeeting = selectedMember.Congregation.PublicMeetingDay;
            bool available = true;
            foreach (DateTime day in manager.EachDayLoop(start, end))
            {
                available = true;
                if (udates.Any(z => z.DateUnavailable == day) ||
                    (selectedMember.IsAvailablePublicMeeting == false && day.DayOfWeek.ToString() == dayOfPublicMeeting) ||
                    (selectedMember.IsAvailableWeekMeeting == false && day.DayOfWeek.ToString() == dayOfWeekMeeting))
                {
                    available = false;
                }
                if (Convert.ToString(day.DayOfWeek) == dayOfWeekMeeting || Convert.ToString(day.DayOfWeek) == dayOfPublicMeeting)
                {
                    string dd = day.DayOfWeek + ", " + day.ToShortDateString();
                    data.Rows.Add(null, available, dd);
                }

            }

            return data;
        }
コード例 #2
0
ファイル: HomePage.cs プロジェクト: inguscrowe/MeetingManager
        public HomePage(Member member, bool isScheduler)
        {
            InitializeComponent();
            ThisMember = member;
            MemberNameLabel.Text = ThisMember.PreferredName ?? ThisMember.FirstName + " " + ThisMember.LastName;
            if (member.LastLoginTime == null)
            {
                LastLoginLabel.Text = "Last Login: First Login TODAY!";
                ThisMember.LastLoginTime = DateTime.Now;
                manager.UpdateMember(ThisMember, false);
            }
            else
            {

                LastLoginLabel.Text = "Last Login: "******"g");
                ThisMember.LastLoginTime = DateTime.Now;
                manager.UpdateMember(ThisMember, false);
            }

            CurrentSelectedSchedule = manager.CurrentScheduleDate();
            if (CurrentSelectedSchedule != null)
            {
                CurrentScheduleGridView = cc.Schedule(CurrentScheduleGridView, CurrentSelectedSchedule);
                StartDateLabel.Text = CurrentSelectedSchedule.StartDate.ToShortDateString();
                EndDateLabel.Text = CurrentSelectedSchedule.EndDate.ToShortDateString();
            }
        }
コード例 #3
0
 public EditScheduleForm(Member thismember, HomePage hp)
 {
     InitializeComponent();
     RefreshScheduleBox();
     hopa = hp;
     scheduler = thismember;
     RefreshEventsBox();
 }
コード例 #4
0
 private void CurrentMembersGridBox_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     int rowsindex = e.RowIndex;
     SelectedMember = manager.MemberByMemberId(Convert.ToInt32(CurrentMembersGridBox.Rows[rowsindex].Cells["Id"].Value));
     SelectedMemberLabel.Text = "Member currently selected: "+(SelectedMember.PreferredName??SelectedMember.FirstName + " " + SelectedMember.LastName);
     MemberAssignmentsGridBox = cc.MemberAssignmentBox(MemberAssignmentsGridBox, SelectedMember);
     DatesAvailableGridBox = cc.DatesAvailableBox(DatesAvailableGridBox, SelectedMember);
     PublicMeetingAvailableCheckBox.Checked = Convert.ToBoolean(SelectedMember.IsAvailablePublicMeeting);
     WeekdayMeetingAvailableCheckBox.Checked = Convert.ToBoolean(SelectedMember.IsAvailableWeekMeeting);
 }
コード例 #5
0
 public AssignmentForm(Member scheduler,AssignmentsProfileForm apf,int? assignmentId)
 {
     InitializeComponent();
     Scheduler = scheduler;
     assignmentProfileForm = apf;
     if(assignmentId!=null)
     {
         int ai=Convert.ToInt32(assignmentId);
         AssignmentUpdate = manager.AssignmentByAssignmentId(ai);
         this.AssignmentNameTextBox.Text = AssignmentUpdate.Label;
         this.DescriptionTextBox.Text = AssignmentUpdate.Description;
         this.AmountPerMeetingPicker.Value = Convert.ToDecimal(AssignmentUpdate.AmountPerMeeting);
         this.schedulePositionPicker.Value = Convert.ToDecimal(AssignmentUpdate.PositionOnSchedule);
         this.CreateUpdateAssignmentButton.Text = "Update Assignment";
     }
 }
コード例 #6
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.");
            }
        }
コード例 #7
0
 public AssignmentsProfileForm(Member member)
 {
     InitializeComponent();
     AssignmentsGridBox = cc.MemberAssignmentBox(AssignmentsGridBox, member);
     Scheduler = member;
 }
コード例 #8
0
        //public Member UpdateMember(int memberId, string firstName, string middleName, string lastName, string preferredName, DateTime dateOfBirth, DateTime baptismDate, string email, string contactNumber,string username,string password)
        //{
        //    Member member = MemberByMemberId(memberId);
        //    member.FirstName = firstName;
        //    member.MiddleName = middleName;
        //    member.LastName = lastName;
        //    member.PreferredName = preferredName;
        //    member.DateOfBirth = dateOfBirth;
        //    member.BaptismDate = baptismDate;
        //    member.Email = email;
        //    member.ContactNumber = contactNumber;
        //    member.UserName = username;
        //    member.Password = password;
        //    member.UpdateDate = DateTime.Now;
        //    member.CongregationId = member.CongregationId;
        //    repository.SaveChanges();
        //    return member;
        //}
        public Member UpdateMember(Member member, bool essentialFields)
        {
            Member memberUpdate = MemberByMemberId(member.Id);
            memberUpdate.FirstName = member.FirstName;
            memberUpdate.LastName = member.LastName;
            memberUpdate.PreferredName = member.PreferredName;
            memberUpdate.Email = member.Email;
            memberUpdate.ContactNumber = member.ContactNumber;
            memberUpdate.IsAvailablePublicMeeting = member.IsAvailablePublicMeeting;
            memberUpdate.IsAvailableWeekMeeting = member.IsAvailableWeekMeeting;
            if (essentialFields == false)
            {
                memberUpdate.MiddleName = member.MiddleName;
                memberUpdate.DateOfBirth = member.DateOfBirth;
                memberUpdate.BaptismDate = member.BaptismDate;
                memberUpdate.UserName = member.UserName;
                memberUpdate.Password = member.Password;
                memberUpdate.IsDeleted = member.IsDeleted;
                memberUpdate.LastLoginTime = DateTime.Now;
                memberUpdate.UpdateDate = DateTime.Now;
                memberUpdate.CongregationId = member.CongregationId;
            }

            repository.SaveChanges();
            return memberUpdate;
        }
コード例 #9
0
        public Member NextMemberToAssign(List<Member> membersAvailable, Meeting currentMeeting, Assignment currentAssignment)
        {
            List<Member> newMembers = (from mem in membersAvailable
                                       where mem.MeetingAssignments.Count == 0
                                       select mem).ToList();

            if (newMembers.Count != 0)
            {
                newMembers = newMembers.OrderBy(z => z.FirstName).ToList();
                return newMembers[0];
            }

            int meetingCountToBeat = new int();
            int meetingCounter = 0;
            Member currentlySelected = new Member();
            MeetingAssignment mLastMeetingAssignment = new MeetingAssignment();
            List<Member> alreadyAssigned = (from l in currentMeeting.MeetingAssignments
                                            select l.Member).ToList();
            List<Meeting> allMeeting = (from v in repository.Meetings
                                        where v.CongregationId == currentMeeting.CongregationId
                                        select v).ToList();
            allMeeting = allMeeting.OrderByDescending(o => o.MeetingDate).ToList();
            int index = allMeeting.IndexOf(currentMeeting);
            List<Member> go = (from goat in allMeeting[index + 1].MeetingAssignments
                               select goat.Member).ToList();

            foreach (Member m in membersAvailable)
            {
                List<MeetingAssignment> selectedMAssignments = (from d in repository.MeetingAssignments
                                                                where d.MemberId == m.Id
                                                                select d).ToList();
                selectedMAssignments = selectedMAssignments.OrderByDescending(o => o.Meeting.MeetingDate).ToList();
                if (alreadyAssigned.Any(p => p.Id == m.Id))//skips if they are already assigned or previous assignment was same assignment.
                {
                    continue;
                }
                if (selectedMAssignments[0].AssignmentId == currentAssignment.Id && m.MemberAssignments.Count > 2)
                {
                    continue;
                }

                foreach (DateTime d in EachDayLoop(selectedMAssignments[0].Meeting.MeetingDate.AddDays(1), currentMeeting.MeetingDate.AddDays(-1)))
                {
                    if (Convert.ToString(d.DayOfWeek) == m.Congregation.PublicMeetingDay || Convert.ToString(d.DayOfWeek) == m.Congregation.WeekMeetingDay)
                    {
                        meetingCounter++;
                    }
                }
                if (currentlySelected.Id == 0)
                {
                    meetingCountToBeat = meetingCounter;
                    currentlySelected = m;
                    mLastMeetingAssignment = selectedMAssignments[0];
                    meetingCounter = 0;
                    continue;
                }
                if (meetingCounter > meetingCountToBeat)
                {
                    meetingCountToBeat = meetingCounter;
                    currentlySelected = m;
                    mLastMeetingAssignment = selectedMAssignments[0];
                    meetingCounter = 0;
                }

                if (meetingCounter == meetingCountToBeat)
                {
                    if (selectedMAssignments[0].Assignment.Label != currentAssignment.Label && mLastMeetingAssignment.Assignment.Label == currentAssignment.Label)
                    {
                        currentlySelected = m;
                        mLastMeetingAssignment = selectedMAssignments[0];
                    }

                }
                meetingCounter = 0;
                continue;

            }
            return currentlySelected;
        }
コード例 #10
0
        public Member CreateMember(string firstName, string middleName, string lastName, string preferredName, DateTime? dateOfBirth, DateTime? baptismDate, string email, string contactNumber, string userName, string password, int congregationId)
        {
            Member member = new Member();
            member.FirstName = firstName;
            member.MiddleName = middleName;
            member.LastName = lastName;
            if (preferredName != "")
            {
                member.PreferredName = preferredName;
            }
            if (email != "")
            {
                member.Email = email;
            }
            if (contactNumber != "")
            {
                member.ContactNumber = contactNumber;
            }
            member.DateOfBirth = dateOfBirth;
            member.BaptismDate = baptismDate;
            member.UserName = userName;
            member.Password = password;
            member.CongregationId = congregationId;
            member.IsAvailablePublicMeeting = true;
            member.IsAvailableWeekMeeting = true;
            member.CreateDate = DateTime.Now;

            repository.Members.Add(member);
            repository.SaveChanges();

            return member;
        }
コード例 #11
0
        public Member CreateMember(string firstName, string preferredName, string lastName, string email, string contactNumber, int congregationId)
        {
            Member member = new Member();
            member.FirstName = firstName;
            if (preferredName != "")
            {
                member.PreferredName = preferredName;
            }
            if (email != "")
            {
                member.Email = email;
            }
            if (contactNumber != "")
            {
                member.ContactNumber = contactNumber;
            }
            member.LastName = lastName;
            member.CongregationId = congregationId;

            repository.Members.Add(member);
            repository.SaveChanges();
            return member;
        }
コード例 #12
0
 public CreateScheduleForm(Member scheduler,HomePage hp)
 {
     InitializeComponent();
     Scheduler = scheduler;
     currentHp = hp;
 }
コード例 #13
0
        public DataGridView MemberAssignmentBox(DataGridView data, Member selectedMember)
        {
            List<Assignment> assignments = manager.AssignmentsByCongregationId(selectedMember.CongregationId);
            List<MemberAssignment> ma = manager.MemberAssignmentsByMemberId(selectedMember.Id);
            data.Rows.Clear();
            data.Refresh();

            foreach (Assignment a in assignments)
            {
                bool isAssigned;
                if (ma.Any(z => z.AssignmentId == a.Id))
                {
                    isAssigned = true;
                }
                else
                {
                    isAssigned = false;
                }
                data.Rows.Add(a.Id.ToString(), a.PositionOnSchedule, isAssigned, a.Label, a.Description, a.AmountPerMeeting);
            }
            data.Sort(data.Columns["SchedulePosition"], System.ComponentModel.ListSortDirection.Ascending);
            return data;
        }