コード例 #1
0
 private void Grant_Proposal_Grid(object sender, RoutedEventArgs e)
 {
     Models.FCS_DBModel db = new Models.FCS_DBModel();
     var query = from g in db.GrantProposals
                 join d in db.Donors on g.DonorID equals d.DonorID
                 select new GrantProposalGrid
                 {
                     GrantName = g.GrantName,
                     OrganizationName = d.OrganizationName,
                     SubmissionDueDate = g.SubmissionDueDate,
                     GrantStatus = g.GrantStatus,
                     GrantProposalID = g.GrantProposalID,
                     DonorID = g.DonorID
                 };
     // ... Assign ItemsSource of DataGrid. 
     var grid = sender as DataGrid;
     if (grid == null)
     {
         GrantProposals.ItemsSource = query.ToList();
     }
     else
     {
         grid.ItemsSource = query.ToList();
     }
 }
コード例 #2
0
        private void Create_Grant_Proposal(object sender, RoutedEventArgs e)
        {
            if (SubmissionDueDate.ToString() != "" && Organization.SelectedValue != null && GrantName != null && GrantName != "")
            {
                string   organiz = Organization.SelectedValue.ToString();
                DateTime datet   = Convert.ToDateTime(SubmissionDueDate.ToString());

                //MessageBox.Show(organiz + "\n" + datet + "\n" + GrantName + "\n" + "Status is Pending");
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                int DonorID           = (from d in db.Donors
                                         where d.OrganizationName == organiz
                                         select d.DonorID).Distinct().First();

                Models.GrantProposal gp = new Models.GrantProposal();

                gp.DonorID           = DonorID;
                gp.GrantName         = GrantName;
                gp.SubmissionDueDate = datet;
                gp.GrantStatus       = "Pending";

                db.GrantProposals.Add(gp);
                db.SaveChanges();

                this.Close();
            }
            else
            {
                MessageBox.Show("Select a date");
            }
        }
コード例 #3
0
        public EditGrantProposals(GrantProposalGrid p)
        {
            GrantName       = p.GrantName;
            GrantProposalID = p.GrantProposalID;
            DonorID         = p.DonorID;

            InitializeComponent();

            IEnumerable <string> statusItems = new List <string>()
            {
                "Pending", "Accepted", "Not Accepted"
            };

            combobox_Status.ItemsSource = statusItems;

            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query             = (from o in db.Donors
                                     where o.DonorType == "Organization" || o.DonorType == "Government"
                                     orderby o.OrganizationName
                                     select o.OrganizationName).ToList();

            combobox_Organization.ItemsSource = query;

            combobox_Status.Text       = p.GrantStatus;
            combobox_Organization.Text = p.OrganizationName;
            text_GrantName.Focus();
        }
コード例 #4
0
        private void Grant_Proposal_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query             = from g in db.GrantProposals
                                    join d in db.Donors on g.DonorID equals d.DonorID
                                    select new GrantProposalGrid
            {
                GrantName         = g.GrantName,
                OrganizationName  = d.OrganizationName,
                SubmissionDueDate = g.SubmissionDueDate,
                GrantStatus       = g.GrantStatus,
                GrantProposalID   = g.GrantProposalID,
                DonorID           = g.DonorID
            };
            // ... Assign ItemsSource of DataGrid.
            var grid = sender as DataGrid;

            if (grid == null)
            {
                GrantProposals.ItemsSource = query.ToList();
            }
            else
            {
                grid.ItemsSource = query.ToList();
            }
        }
コード例 #5
0
        private void Load_Contacts_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var join1             = from c in db.DonorContacts
                                    where c.DonorID == DonorID
                                    select new DonorContactGrid
            {
                ContactFirstName = c.ContactFirstName,
                ContactLastName  = c.ContactLastName,
                ContactPhone     = c.ContactPhone,
                ContactEmail     = c.ContactEmail,
                DonorID          = c.DonorID,
                ContactID        = c.ContactID
            };
            var grid = sender as DataGrid;

            if (grid == null)
            {
                ContactsGrid.ItemsSource = join1.ToList();
            }
            else
            {
                ContactsGrid.ItemsSource = join1.ToList();
            }
        }
コード例 #6
0
        private void EditGrantProposal(object sender, MouseButtonEventArgs e)
        {
            int      index;
            DataGrid dg = sender as DataGrid;

            if (dg.SelectedIndex != -1)
            {
                GrantProposalGrid p = (GrantProposalGrid)dg.SelectedItems[0]; // OR:  Patient p = (Patient)dg.SelectedItem;
                if (p.GrantStatus == "Accepted")
                {
                    index = 1;
                }
                else if (p.GrantStatus == "Not Accepted")
                {
                    index = 2;
                }
                else
                {
                    index = 0;
                }

                Models.FCS_DBModel db  = new Models.FCS_DBModel();
                EditGrantProposals dgp = new EditGrantProposals(p);
                dgp.ShowDialog();
                dgp.text_GrantName.IsEnabled = false;
                if (index == 1 || index == 2)
                {
                    dgp.combobox_Status.IsEnabled = false;
                }
                dgp.combobox_Status.SelectedIndex = index;
            }
            Refresh_Grant_Proposal(sender, e);
        }
コード例 #7
0
        private void Delete_InKind_Service(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this In-Kind Service?",
                                                                                            "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                try {
                    Models.FCS_DBModel db = new Models.FCS_DBModel();
                    var inkindservice     = (from p in db.In_Kind_Service
                                             where p.ServiceID == ServiceID
                                             select p).First();

                    var donation = (from d in db.Donations
                                    where d.DonationID == DonationID
                                    select d).First();
                    db.In_Kind_Service.Remove(inkindservice);
                    db.Donations.Remove(donation);
                    db.SaveChanges();
                    this.Close();
                }
                catch
                {
                    MessageBox.Show("Something went wrong. Please try again.");
                }
            }
        }
コード例 #8
0
        private void InKindServiceGrid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var join1             = (from p in db.Donors
                                     join dc in db.DonorContacts on p.DonorID equals dc.DonorID
                                     join d in db.Donations on p.DonorID equals d.DonorID
                                     join ki in db.In_Kind_Service on d.DonationID equals ki.DonationID
                                     where (p.DonorType == "Anonymous" || p.DonorType == "Individual") &&
                                     d.EventID == EventID
                                     select new InKindService
            {
                DonorID = p.DonorID,
                DonationID = d.DonationID,
                ServiceID = ki.ServiceID,
                DonorFirstName = dc.ContactFirstName,
                DonorLastName = dc.ContactLastName,
                StartDateTime = ki.StartDateTime,
                EndDateTime = ki.EndDateTime,
                RatePerHour = ki.RatePerHour,
                ServiceDescription = ki.ServiceDescription,
                Length = ki.ServiceLength,
                Value = ki.ServiceValue
            });
            var grid = sender as DataGrid;

            grid.ItemsSource = join1.ToList();
        }
コード例 #9
0
        private void Create_Grant_Proposal(object sender, RoutedEventArgs e)
        {
            if (SubmissionDueDate.ToString() != "" && Organization.SelectedValue != null && GrantName != null && GrantName != "")
            {
                string organiz = Organization.SelectedValue.ToString();
                DateTime datet = Convert.ToDateTime(SubmissionDueDate.ToString());

                //MessageBox.Show(organiz + "\n" + datet + "\n" + GrantName + "\n" + "Status is Pending");
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                int DonorID = (from d in db.Donors
                               where d.OrganizationName == organiz
                               select d.DonorID).Distinct().First();

                Models.GrantProposal gp = new Models.GrantProposal();

                gp.DonorID = DonorID;
                gp.GrantName = GrantName;
                gp.SubmissionDueDate = datet;
                gp.GrantStatus = "Pending";

                db.GrantProposals.Add(gp);
                db.SaveChanges();
                
                this.Close();
            }
            else
            {
                MessageBox.Show("Select a date");
            }

        }
コード例 #10
0
        private void Patient_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var join1             = from patient in db.Patients
                                    join patienthouse in db.PatientHouseholds on patient.HouseholdID equals patienthouse.HouseholdID
                                    select new PatientGrid
            {
                PatientOQ      = patient.PatientOQ,
                PatientID      = patient.PatientID,
                FirstName      = patient.PatientFirstName,
                LastName       = patient.PatientLastName,
                Gender         = patient.PatientGender,
                AgeGroup       = patient.PatientAgeGroup,
                Ethnicity      = patient.PatientEthnicity,
                Time           = patient.NewClientIntakeHour,
                IsHead         = patient.IsHead,
                RelationToHead = patient.RelationToHead
            };

            // ... Assign ItemsSource of DataGrid.
            var grid = sender as DataGrid;

            Patients.AddRange(join1.ToList());
            PatientGrid.ItemsSource = Patients;
        }
コード例 #11
0
        private void SessionsGrid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var join1             = from s in db.Staff
                                    join a in db.Appointments on s.StaffID equals a.StaffID
                                    join ex in db.Expenses on a.AppointmentID equals ex.AppointmentID
                                    join et in db.ExpenseTypes on ex.ExpenseTypeID equals et.ExpenseTypeID
                                    where ex.PatientID == PatientID
                                    select new SessionsGrid
            {
                StaffFirstName     = s.StaffFirstName,
                StaffLastName      = s.StaffLastName,
                AppointmentStart   = a.AppointmentStartDate,
                AppointmentEnd     = a.AppointmentEndDate,
                ExpenseDueDate     = ex.ExpenseDueDate,
                ExpensePaidDate    = ex.ExpensePaidDate,
                DonorBill          = ex.DonorBill,
                PatientBill        = ex.PatientBill,
                TotalExpense       = ex.TotalExpenseAmount,
                ExpenseType        = et.ExpenseType1,
                ExpenseDescription = et.ExpenseDescription
            };
            // ... Assign ItemsSource of DataGrid.
            var grid = sender as DataGrid;

            grid.ItemsSource = join1.ToList();
        }
コード例 #12
0
        private void Staff_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query             = (from o in db.Staff
                                     select o.StaffFirstName + ", " + o.StaffLastName + ", " + o.StaffUserName).ToList();

            var box = sender as ComboBox;

            box.ItemsSource = query;
        }
コード例 #13
0
        private void Organization_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query = (from o in db.Donors
                         where o.DonorType == "Organization"
                         orderby o.OrganizationName
                         select o.OrganizationName).ToList();

            var box = sender as ComboBox;
            box.ItemsSource = query;
        }
コード例 #14
0
        private void Grants_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query             = (from o in db.GrantProposals
                                     where o.GrantStatus == "Accepted"
                                     select o.GrantName).ToList();

            var box = sender as ComboBox;

            box.ItemsSource = query;
        }
コード例 #15
0
        private void Individual_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query = (from o in db.Donors
                         join c in db.DonorContacts on o.DonorID equals c.DonorID
                         where o.DonorType == "Individual" || o.DonorType == "Anonymous"
                         orderby c.ContactLastName
                         select c.ContactFirstName + ", " + c.ContactLastName + ", " + c.ContactPhone).ToList();

            var box = sender as ComboBox;
            box.ItemsSource = query;
        }
コード例 #16
0
        private void Update_InKind_Service(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }

            DateTime help          = Convert.ToDateTime(DateRecieved.ToString());
            DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
            DateTime endDateTime   = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
            decimal  timeDiff      = (decimal)(endDateTime - startDateTime).TotalHours;

            try
            {
                Models.FCS_DBModel db = new Models.FCS_DBModel();

                var inkindservice = (from p in db.In_Kind_Service
                                     where p.ServiceID == ServiceID
                                     select p).FirstOrDefault();
                inkindservice.ServiceDescription = ServiceDescription;
                inkindservice.RatePerHour        = RatePerHour;
                inkindservice.StartDateTime      = startDateTime;
                inkindservice.EndDateTime        = endDateTime;
                inkindservice.ServiceValue       = Math.Round(RatePerHour * timeDiff, 2);
                inkindservice.ServiceLength      = (double)Math.Round(timeDiff, 2);


                var donation2 = (from d in db.Donations
                                 where d.DonationID == DonationID
                                 select d).FirstOrDefault();
                donation2.DonationDate = Convert.ToDateTime(DateRecieved.ToString());

                db.SaveChanges();

                this.Close();
            }
            catch
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
コード例 #17
0
        private void Organization_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query             = (from o in db.Donors
                                     where o.OrganizationName != null && o.OrganizationName != ""
                                     orderby o.OrganizationName
                                     select o.OrganizationName).ToList();

            var box = sender as ComboBox;

            box.ItemsSource = query;
        }
コード例 #18
0
        private void Add_Event(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }
            try
            {
                DateTime help          = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime   = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                decimal  timeDiff      = (decimal)(endDateTime - startDateTime).TotalHours;

                if (EventName != null && EventName != "" && timeDiff > 0)
                {
                    Models.FCS_DBModel db = new Models.FCS_DBModel();
                    //MessageBox.Show(EventName + "\n" + EventDescription + "\n" + startDateTime + "\n" + endDateTime + "\n" + timeDiff );

                    Models.FundRaisingEvent event1 = new Models.FundRaisingEvent();

                    event1.EventStartDateTime = startDateTime;
                    event1.EventEndDateTime   = endDateTime;
                    event1.EventName          = EventName;
                    event1.EventDescription   = EventDescription;

                    db.FundRaisingEvents.Add(event1);
                    db.SaveChanges();

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Please check the data entered.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
コード例 #19
0
        private void Add_Event(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }
            try
            {
                DateTime help = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                decimal timeDiff = (decimal)(endDateTime - startDateTime).TotalHours;

                if (EventName != null && EventName != "" && timeDiff > 0)
                {
                    Models.FCS_DBModel db = new Models.FCS_DBModel();
                    //MessageBox.Show(EventName + "\n" + EventDescription + "\n" + startDateTime + "\n" + endDateTime + "\n" + timeDiff );

                    Models.FundRaisingEvent event1 = new Models.FundRaisingEvent();

                    event1.EventStartDateTime = startDateTime;
                    event1.EventEndDateTime = endDateTime;
                    event1.EventName = EventName;
                    event1.EventDescription = EventDescription;

                    db.FundRaisingEvents.Add(event1);
                    db.SaveChanges();
                    
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Please check the data entered.");
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
コード例 #20
0
        private void Individual_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query             = (from o in db.Donors
                                     join c in db.DonorContacts on o.DonorID equals c.DonorID
                                     where o.DonorType == "Individual" || o.DonorType == "Anonymous"
                                     orderby c.ContactLastName
                                     select c.ContactFirstName + ", " + c.ContactLastName + ", " + c.ContactPhone).ToList();

            var box = sender as ComboBox;

            box.ItemsSource = query;
        }
コード例 #21
0
        /// <summary>
        /// This method logs you into the system
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Organization_DropDown(object sender, RoutedEventArgs e)
        {
            List<string> p = new List<string>()
            {
                "HAFB", "Weber", "Clearfield"
            };
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query = (from o in db.Donors
                         where o.DonorType == "Organization" || o.DonorType == "Government" 
                         orderby o.OrganizationName
                         select o.OrganizationName).ToList();

            var box = sender as ComboBox;
            box.ItemsSource = query;
        }
コード例 #22
0
        /// <summary>
        /// This method logs you into the system
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Organization_DropDown(object sender, RoutedEventArgs e)
        {
            List <string> p = new List <string>()
            {
                "HAFB", "Weber", "Clearfield"
            };

            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query             = (from o in db.Donors
                                     where o.DonorType == "Organization" || o.DonorType == "Government"
                                     orderby o.OrganizationName
                                     select o.OrganizationName).ToList();

            var box = sender as ComboBox;

            box.ItemsSource = query;
        }
コード例 #23
0
        private void Update_InKind_Item(object sender, RoutedEventArgs e)
        {

            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var inkinditem = (from p in db.In_Kind_Item
                           where p.ItemID == ItemID
                           select p).First();
            inkinditem.ItemName = ItemName;
            inkinditem.ItemDescription = ItemDescription;

            var donation = (from d in db.Donations
                            where d.DonationID == DonationID
                            select d).First();
            donation.DonationDate = Convert.ToDateTime(DateRecieved.ToString());
            db.SaveChanges();
            
            this.Close();
        }
コード例 #24
0
        private void InKindItemGrid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var join1             = (from p in db.Donors
                                     join dc in db.DonorContacts on p.DonorID equals dc.DonorID
                                     join d in db.Donations on p.DonorID equals d.DonorID
                                     join ki in db.In_Kind_Item on d.DonationID equals ki.DonationID
                                     where (p.DonorType == "Anonymous" || p.DonorType == "Individual") &&
                                     d.EventID == EventID && d.EventID != null
                                     select new InKindItem
            {
                EventID = d.EventID,
                DonorID = p.DonorID,
                ItemID = ki.ItemID,
                DonationID = d.DonationID,
                ItemName = ki.ItemName,
                DonorFirstName = dc.ContactFirstName,
                DonorLastName = dc.ContactLastName,
                OrganizationName = "",
                DateRecieved = d.DonationDate,
                Description = ki.ItemDescription
            }).Union(
                from p in db.Donors
                join d in db.Donations on p.DonorID equals d.DonorID
                join ki in db.In_Kind_Item on d.DonationID equals ki.DonationID
                where (p.DonorType == "Organization" || p.DonorType == "Government") &&
                d.EventID == EventID && d.EventID != null
                select new InKindItem
            {
                EventID          = d.EventID,
                DonorID          = p.DonorID,
                ItemID           = ki.ItemID,
                DonationID       = d.DonationID,
                ItemName         = ki.ItemName,
                DonorFirstName   = "",
                DonorLastName    = "",
                OrganizationName = p.OrganizationName,
                DateRecieved     = d.DonationDate,
                Description      = ki.ItemDescription
            });
            var grid = sender as DataGrid;

            grid.ItemsSource = join1.ToList();
        }
コード例 #25
0
        private void Update_InKind_Item(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var inkinditem        = (from p in db.In_Kind_Item
                                     where p.ItemID == ItemID
                                     select p).First();

            inkinditem.ItemName        = ItemName;
            inkinditem.ItemDescription = ItemDescription;

            var donation = (from d in db.Donations
                            where d.DonationID == DonationID
                            select d).First();

            donation.DonationDate = Convert.ToDateTime(DateRecieved.ToString());
            db.SaveChanges();

            this.Close();
        }
コード例 #26
0
        private void Update_Donor(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var donor             = (from p in db.Donors
                                     where p.DonorID == DonorID
                                     select p).First();

            donor.DonorAddress1    = DonorAddress1;
            donor.DonorAddress2    = DonorAddress2;
            donor.DonorCity        = DonorCity;
            donor.DonorState       = DonorState;
            donor.DonorZip         = DonorZip;
            donor.OrganizationName = OrganizationName;
            donor.DonorType        = DonorType;
            int changes = db.SaveChanges();


            this.Close();
        }
コード例 #27
0
        private void Update_Donor(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var donor = (from p in db.Donors
                           where p.DonorID == DonorID
                           select p).First();
            
            donor.DonorAddress1 = DonorAddress1;
            donor.DonorAddress2 = DonorAddress2;
            donor.DonorCity = DonorCity;
            donor.DonorState = DonorState;
            donor.DonorZip = DonorZip;
            donor.OrganizationName = OrganizationName;
            donor.DonorType = DonorType;
            int changes = db.SaveChanges();
            

            this.Close();
        }
コード例 #28
0
        private void Donations_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();

            var join1 = from d in db.Donations
                        where d.DonorID == DonorID
                        select new DonationsGrid
            {
                DonationAmount          = d.DonationAmount,
                DonationAmountRemaining = d.DonationAmountRemaining,
                DonationDate            = d.DonationDate,
                DonorID    = d.DonorID,
                DonationID = d.DonationID
            };

            // ... Assign ItemsSource of DataGrid.
            var grid = sender as DataGrid;

            grid.ItemsSource = join1.ToList();
        }
コード例 #29
0
        private void Delete_InKind_Item(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this In-Kind Item?",
                                                                                            "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                var inkinditem        = (from p in db.In_Kind_Item
                                         where p.ItemID == ItemID
                                         select p).First();

                var donation = (from d in db.Donations
                                where d.DonationID == DonationID
                                select d).First();
                db.In_Kind_Item.Remove(inkinditem);
                db.Donations.Remove(donation);
                db.SaveChanges();
                this.Close();
            }
        }
コード例 #30
0
        private void Delete_InKind_Item(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this In-Kind Item?",
               "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                var inkinditem = (from p in db.In_Kind_Item
                                        where p.ItemID == ItemID
                                        select p).First();

                var donation = (from d in db.Donations
                                where d.DonationID == DonationID
                                select d).First();
                db.In_Kind_Item.Remove(inkinditem);
                db.Donations.Remove(donation);
                db.SaveChanges();
                this.Close();
            }
        }
コード例 #31
0
        private void MoneyDonation_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var join2             = (from d in db.Donations
                                     join dn in db.Donors on d.DonorID equals dn.DonorID
                                     where (dn.DonorType == "Organization" || dn.DonorType == "Government" || dn.DonorType == "Insurance")
                                     select d.DonationID.ToString() + ", " + dn.OrganizationName + ", " + d.DonationAmountRemaining.ToString()).Union
                                        (from d in db.Donations
                                        join dn in db.Donors on d.DonorID equals dn.DonorID
                                        join c in db.DonorContacts on dn.DonorID equals c.DonorID
                                        where (dn.DonorType == "Anonymous" || dn.DonorType == "Individual") &&
                                        d.GrantProposalID == null
                                        select d.DonationID + ", " + d.DonationAmountRemaining + ", " + c.ContactFirstName + ", " + c.ContactLastName).ToList();
            //var query = (from d in db.Donations
            //             where d.GrantProposalID == null
            //             select d.DonationID.ToString() + d.DonationPurposes).ToList();

            var box = sender as ComboBox;

            box.ItemsSource = join2;
        }
コード例 #32
0
        private void Continue(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            //Then its an organization
            if (OrgOrIndividual.IsChecked.Value && Organization.SelectedIndex != -1)
            {
                string Organiz = Organization.SelectedValue.ToString();
                var donorID = (from d in db.Donors
                                where d.OrganizationName == Organiz
                                select d.DonorID).Distinct().First();

                CreateMoneyDonation cmd = new CreateMoneyDonation(donorID, true, EventID);
                cmd.ShowDialog();
                this.Close();

            }
            //then its an individual
            else if (Individual.SelectedIndex != -1)
            {
                string[] separators = new string[] { ", " };
                string Indiv = Individual.SelectedValue.ToString();
                string[] words = Indiv.Split(separators, StringSplitOptions.None);
                string FName = words[0]; string LName = words[1]; string FNumber = words[2];
                var donorID = (from dc in db.DonorContacts
                               join d in db.Donors on dc.DonorID equals d.DonorID
                               where dc.ContactFirstName == FName && dc.ContactLastName == LName && dc.ContactPhone == FNumber
                               && (d.DonorType == "Individual" || d.DonorType == "Anonymous")
                               select dc.DonorID).Distinct().FirstOrDefault();

                CreateMoneyDonation cmd = new CreateMoneyDonation(donorID, true, EventID);
                cmd.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Make sure to select an organization or an individual");
                return;
            }

		}
コード例 #33
0
        private void Update_Grant_Proposal(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(text_GrantName.Text))
            {
                MessageBox.Show("Please enter a name for the grant.");
                return;
            }

            if (combobox_Organization.Text == "")
            {
                MessageBox.Show("Please select an organization.");
            }

            string GrantStatus = combobox_Status.SelectedValue.ToString();

            //MessageBox.Show(GrantStatus + "\n" + "\n" + GrantName + "\n" + OrganizationName);

            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var grantproposal     = (from p in db.GrantProposals
                                     where p.GrantProposalID == GrantProposalID
                                     select p).First();

            grantproposal.GrantName = GrantName;
            if (combobox_Status.IsEnabled == true)
            {
                grantproposal.GrantStatus = GrantStatus;
                db.SaveChanges();
                if (GrantStatus == "Accepted")
                {
                    ///OPEN ANOTHER WINDOW TO ADD THIS PROPOSAL TO DONATION & PURPOSE TABLE
                    AddNewGrant adg = new AddNewGrant(DonorID, GrantProposalID);
                    adg.ShowDialog();
                }
                this.Close();
            }
            else
            {
                db.SaveChanges();
            }
        }
コード例 #34
0
        public EditGrantProposals(GrantProposalGrid p)
        {
            GrantName = p.GrantName;
            GrantProposalID = p.GrantProposalID;
            DonorID = p.DonorID;

			InitializeComponent();

			IEnumerable<string> statusItems = new List<string>() { "Pending", "Accepted", "Not Accepted" };
			combobox_Status.ItemsSource = statusItems;

			Models.FCS_DBModel db = new Models.FCS_DBModel();
			var query = (from o in db.Donors
						 where o.DonorType == "Organization" || o.DonorType == "Government"
						 orderby o.OrganizationName
						 select o.OrganizationName).ToList();
			combobox_Organization.ItemsSource = query;

			combobox_Status.Text = p.GrantStatus;
			combobox_Organization.Text = p.OrganizationName;
			text_GrantName.Focus();
        }
コード例 #35
0
		private void Update_Grant_Proposal(object sender, RoutedEventArgs e)
        {
			if (string.IsNullOrEmpty(text_GrantName.Text))
			{
				MessageBox.Show("Please enter a name for the grant.");
				return;
			}

			if (combobox_Organization.Text == "")
			{
				MessageBox.Show("Please select an organization.");
			}

            string GrantStatus = combobox_Status.SelectedValue.ToString();
            //MessageBox.Show(GrantStatus + "\n" + "\n" + GrantName + "\n" + OrganizationName);

            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var grantproposal = (from p in db.GrantProposals
                                    where p.GrantProposalID == GrantProposalID
                                    select p).First();
            grantproposal.GrantName = GrantName;
            if (combobox_Status.IsEnabled == true)
            {

                grantproposal.GrantStatus = GrantStatus;
                db.SaveChanges();
                if (GrantStatus == "Accepted")
                {
                    ///OPEN ANOTHER WINDOW TO ADD THIS PROPOSAL TO DONATION & PURPOSE TABLE
                    AddNewGrant adg = new AddNewGrant(DonorID, GrantProposalID);
                    adg.ShowDialog();
                }
                this.Close();
            }
            else
            {
                db.SaveChanges();
            }
        }
コード例 #36
0
        private void Continue(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            //Then its an organization
            if (OrgOrIndividual.IsChecked.Value && Organization.SelectedIndex != -1)
            {
                string Organiz = Organization.SelectedValue.ToString();
                var    donorID = (from d in db.Donors
                                  where d.OrganizationName == Organiz
                                  select d.DonorID).Distinct().First();

                CreateMoneyDonation cmd = new CreateMoneyDonation(donorID, true, EventID);
                cmd.ShowDialog();
                this.Close();
            }
            //then its an individual
            else if (Individual.SelectedIndex != -1)
            {
                string[] separators = new string[] { ", " };
                string   Indiv = Individual.SelectedValue.ToString();
                string[] words = Indiv.Split(separators, StringSplitOptions.None);
                string   FName = words[0]; string LName = words[1]; string FNumber = words[2];
                var      donorID = (from dc in db.DonorContacts
                                    join d in db.Donors on dc.DonorID equals d.DonorID
                                    where dc.ContactFirstName == FName && dc.ContactLastName == LName && dc.ContactPhone == FNumber &&
                                    (d.DonorType == "Individual" || d.DonorType == "Anonymous")
                                    select dc.DonorID).Distinct().FirstOrDefault();

                CreateMoneyDonation cmd = new CreateMoneyDonation(donorID, true, EventID);
                cmd.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Make sure to select an organization or an individual");
                return;
            }
        }
コード例 #37
0
        private void Delete_Donor(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Donor?" , "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                var donorContact = (from p in db.DonorContacts
                                    where p.DonorID == DonorID
                                    select p);
                foreach(Models.DonorContact contact in donorContact)
                {
                    db.DonorContacts.Remove(contact);
                }
                var donor = (from p in db.Donors
                               where p.DonorID == DonorID
                               select p).First();

                db.Donors.Remove(donor);
                db.SaveChanges();
                
                this.Close();
            }
        }
コード例 #38
0
        private void EditGrantProposal(object sender, MouseButtonEventArgs e)
        {
            int index;
            DataGrid dg = sender as DataGrid;
            if (dg.SelectedIndex != -1)
            {
                GrantProposalGrid p = (GrantProposalGrid)dg.SelectedItems[0]; // OR:  Patient p = (Patient)dg.SelectedItem;
                if (p.GrantStatus == "Accepted") { index = 1; }
                else if (p.GrantStatus == "Not Accepted") { index = 2; }
                else { index = 0; }

                Models.FCS_DBModel db = new Models.FCS_DBModel();
                EditGrantProposals dgp = new EditGrantProposals(p);
                dgp.ShowDialog();
                dgp.text_GrantName.IsEnabled = false;
                if (index == 1 || index == 2)
                {
                    dgp.combobox_Status.IsEnabled = false;
                }
                dgp.combobox_Status.SelectedIndex = index;
            }
            Refresh_Grant_Proposal(sender, e);
        }
コード例 #39
0
        private void Delete_Donor(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Donor?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                var donorContact      = (from p in db.DonorContacts
                                         where p.DonorID == DonorID
                                         select p);
                foreach (Models.DonorContact contact in donorContact)
                {
                    db.DonorContacts.Remove(contact);
                }
                var donor = (from p in db.Donors
                             where p.DonorID == DonorID
                             select p).First();

                db.Donors.Remove(donor);
                db.SaveChanges();

                this.Close();
            }
        }
コード例 #40
0
        private void Donations_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var join1             = (from d in db.Donations
                                     join dr in db.Donors on d.DonorID equals dr.DonorID
                                     join dc in db.DonorContacts on dr.DonorID equals dc.DonorID
                                     where d.EventID == EventID &&
                                     (dr.DonorType == "Anonymous" || dr.DonorType == "Individual")
                                     select new DonationsGrid
            {
                DonorFirstName = dc.ContactFirstName,
                DonorLastName = dc.ContactLastName,
                OrganizationName = "",
                DonationAmount = d.DonationAmount,
                DonationDate = d.DonationDate,
                DonorID = d.DonorID,
                DonationID = d.DonationID
            }).Union(
                from d in db.Donations
                join dr in db.Donors on d.DonorID equals dr.DonorID
                where d.EventID == EventID &&
                (dr.DonorType == "Organization" || dr.DonorType == "Government")
                select new DonationsGrid
            {
                DonorFirstName   = "",
                DonorLastName    = "",
                OrganizationName = dr.OrganizationName,
                DonationAmount   = d.DonationAmount,
                DonationDate     = d.DonationDate,
                DonorID          = d.DonorID,
                DonationID       = d.DonationID
            });
            // ... Assign ItemsSource of DataGrid.
            var grid = sender as DataGrid;

            grid.ItemsSource = join1.ToList();
        }
コード例 #41
0
        private void Donations_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();

            var join1 = (from d in db.Donations
                         where d.DonorID == DonorID
                         select new DonationsGrid
            {
                DonationAmount = d.DonationAmount,
                DonationAmountRemaining = d.DonationAmountRemaining,
                DonationDate = d.DonationDate,
                PurposeName = (from p in db.Purposes
                               join dp in db.DonationPurposes on p.PurposeID equals dp.PurposeID
                               where dp.DonationID == d.DonationID
                               select p.PurposeName).FirstOrDefault(),
                PurposeDescription = (from p in db.Purposes
                                      join dp in db.DonationPurposes on p.PurposeID equals dp.PurposeID
                                      where dp.DonationID == d.DonationID
                                      select p.PurposeDescription).FirstOrDefault(),
                DonorID = d.DonorID,
                DonationPurposeID = (from p in db.Purposes
                                     join dp in db.DonationPurposes on p.PurposeID equals dp.PurposeID
                                     where dp.DonationID == d.DonationID
                                     select dp.DonationPurposeID).FirstOrDefault(),
                PurposeID = (from p in db.Purposes
                             join dp in db.DonationPurposes on p.PurposeID equals dp.PurposeID
                             where dp.DonationID == d.DonationID
                             select dp.PurposeID).FirstOrDefault(),
                DonationID = d.DonationID
            }).ToList();

            // ... Assign ItemsSource of DataGrid.
            var grid = sender as DataGrid;

            grid.ItemsSource = join1.ToList();
        }
コード例 #42
0
        private void Patient_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var join1 = from patient in db.Patients
                        join patienthouse in db.PatientHouseholds on patient.HouseholdID equals patienthouse.HouseholdID
                        select new PatientGrid
                        {
                            PatientOQ = patient.PatientOQ,
                            PatientID = patient.PatientID,
                            FirstName = patient.PatientFirstName,
                            LastName = patient.PatientLastName,
                            Gender = patient.PatientGender,
                            AgeGroup = patient.PatientAgeGroup,
                            Ethnicity = patient.PatientEthnicity,
                            Time = patient.NewClientIntakeHour,
                            IsHead = patient.IsHead,
                            RelationToHead = patient.RelationToHead
                        };

            // ... Assign ItemsSource of DataGrid. 
            var grid = sender as DataGrid;
            Patients.AddRange(join1.ToList());
            PatientGrid.ItemsSource = Patients;

        }
コード例 #43
0
        private void Donations_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();

            var join1 = from d in db.Donations
                        where d.DonorID == DonorID                                                
                        select new DonationsGrid
                        {
                            DonationAmount = d.DonationAmount,
                            DonationAmountRemaining = d.DonationAmountRemaining,
                            DonationDate = d.DonationDate,
                            DonorID = d.DonorID,
                            DonationID = d.DonationID
                        };

            // ... Assign ItemsSource of DataGrid.
            var grid = sender as DataGrid;
            grid.ItemsSource = join1.ToList();
        }
コード例 #44
0
        private void Select_AppointmentType(object sender, RoutedEventArgs e)
        {
            try
            {
                if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
                {
                    BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
                }
                if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
                {
                    EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
                }
                if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
                {
                    BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
                }
                if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
                {
                    EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
                }

                DateTime help = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                DateTime expenseDueDate = startDateTime.AddDays(30);
                string[] separators = new string[] { ", " };
                string staff = Staff.SelectedValue.ToString();
                string cancellationType = "Not Cxl";
                switch (CancellationType.SelectedIndex)
                {
                    case 0:
                        cancellationType = "Not Cxl";
                        break;
                    case 1:
                        cancellationType = "No Show";
                        break;
                    case 2:
                        cancellationType = "Late Cxl";
                        break;                 
                    case 3:
                        cancellationType = "Cxl";
                        break;
                    default:
                        cancellationType = "Not Cxl";
                        break;
                }
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                string[] words = staff.Split(separators, StringSplitOptions.None);
                string FName = words[0]; string LName = words[1]; string usertitle = words[2];  string username = words[3];
                var staffID = (from dc in db.Staff
                               where dc.StaffFirstName == FName && dc.StaffLastName == LName && dc.StaffUserName == username
                               select dc.StaffID).Distinct().FirstOrDefault();
                if (TotalGroup.Count == 0) { MessageBox.Show("Please add at least one client."); return; }
                if (TotalGroup.Count > 1 && (String)ApptType.SelectedItem == "Individual") { MessageBox.Show("Individual appointment may only have one client."); return; }
                //individual (1st option) (ExpenseTypeID = 1 in database)
                //group (3rd option) (ExpenseTypeID = 2 in database)
                if (ApptType.SelectedIndex == 0 || ApptType.SelectedIndex == 2)
                {
                    if (ApptType.SelectedIndex == 0) { ExpenseTypeID = 1; }
                    else { ExpenseTypeID = 2; }
                    Models.Appointment a = new Models.Appointment();
                    a.StaffID = staffID;
                    a.AppointmentStartDate = startDateTime;
                    a.AppointmentEndDate = endDateTime;
                    a.AppointmentCancelationType = cancellationType;
                    db.Appointments.Add(a);
                    db.SaveChanges();

                    foreach (var item in TotalGroup)
                    {
                        AddGroupSession ags = new AddGroupSession(ExpenseTypeID, item, staffID, expenseDueDate, startDateTime, endDateTime, a.AppointmentID);
                        ags.ShowDialog();
                        ags.ExpensePaidDate.IsEnabled = false;
                        ags.FN.IsEnabled = false;
                        ags.LN.IsEnabled = false;
                        ags.OQ.IsEnabled = false;
                        ags.MoneyDonation.IsEnabled = true;
                        ags.Grant.IsEnabled = false;
                    }
                    this.Close();
                }
                //family (2nd option) (ExpenseTypeID = 3 in database)
                else if (ApptType.SelectedIndex == 1)
                {
                    ExpenseTypeID = 3;
                    foreach (var item in TotalGroup)
                    {
                        Models.Appointment a = new Models.Appointment();
                        a.StaffID = staffID;
                        a.AppointmentStartDate = startDateTime;
                        a.AppointmentEndDate = endDateTime;
                        a.AppointmentCancelationType = cancellationType;
                        db.Appointments.Add(a);
                        db.SaveChanges();

                        AddGroupSession ags = new AddGroupSession(ExpenseTypeID, item, staffID, expenseDueDate, startDateTime, endDateTime, a.AppointmentID);
                        ags.Show();
                        ags.ExpensePaidDate.IsEnabled = false;
                        ags.FN.IsEnabled = false;
                        ags.LN.IsEnabled = false;
                        ags.OQ.IsEnabled = false;
                        ags.MoneyDonation.IsEnabled = true;
                        ags.Grant.IsEnabled = false;
                    }
                    this.Close();
                }
                
            }
            catch
            {
                
                if (GroupGrid.Items.Count == 0)
                {
                    MessageBox.Show("Please select atleast one client prior to clicking on Select Appointment Type");
                }
                else if (Staff.SelectedIndex == -1)
                {
                    MessageBox.Show("Please select a Therapist prior to clicking Select on Appointment Type");
                }
                else if (DateRecieved.Text.Equals("") || DateRecieved == null)
                {
                    MessageBox.Show("Please select a Date prior to clicking Select Appointment Type");
                }
                else
                {
                    MessageBox.Show("Something went wrong. Please check the fields and try again.");
                }
            }

        }
コード例 #45
0
 private void Load_Contacts_Grid(object sender, RoutedEventArgs e)
 {
     Models.FCS_DBModel db = new Models.FCS_DBModel();
     var join1 = from c in db.DonorContacts
                 where c.DonorID == DonorID
                 select new DonorContactGrid
                 {
                     ContactFirstName = c.ContactFirstName,
                     ContactLastName = c.ContactLastName,
                     ContactPhone = c.ContactPhone,
                     ContactEmail = c.ContactEmail,
                     DonorID = c.DonorID,
                     ContactID = c.ContactID
                 };
     var grid = sender as DataGrid;
     if (grid == null)
     {
         ContactsGrid.ItemsSource = join1.ToList();
     }
     else
     {
         ContactsGrid.ItemsSource = join1.ToList();
     }
 }
コード例 #46
0
        private void Add_Expense(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            try
            {
                //Taking the money from a grant
                if (DonorDeduction.IsChecked.Value)
                {
                    string grant           = Grant.SelectedValue.ToString();
                    var    grantproposalID = (from g in db.GrantProposals
                                              where g.GrantName == grant
                                              select g.GrantProposalID).Distinct().FirstOrDefault();
                    var grantDonation = (from d in db.Donations
                                         where d.GrantProposalID == grantproposalID
                                         select d).First();
                    if (grantDonation.DonationAmountRemaining >= DonorBill)
                    {
                        Models.Expense expense = new Models.Expense();

                        var donationID = (from d in db.Donations
                                          where d.GrantProposalID == grantproposalID
                                          select d.DonationID).Distinct().FirstOrDefault();
                        expense.DonationID = donationID;

                        expense.ExpenseTypeID      = ExpenseTypeID;
                        expense.PatientID          = Individual.PatientID;
                        expense.AppointmentID      = AppointmentID;
                        expense.ExpenseDueDate     = ExpenseDueDate;
                        expense.DonorBill          = DonorBill;
                        expense.PatientBill        = PatientBill;
                        expense.TotalExpenseAmount = DonorBill + PatientBill;
                        if (IsPaid.IsChecked.Value == true)
                        {
                            expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString());
                        }

                        db.Expenses.Add(expense);
                        db.SaveChanges();
                        grantDonation.DonationAmountRemaining = grantDonation.DonationAmountRemaining - DonorBill;
                        db.SaveChanges();

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("That grant does not have enough money.");
                    }
                }
                //taking the money from a money donation.
                else
                {
                    string[] separators = new string[] { ", " };
                    string   Don        = MoneyDonation.SelectedValue.ToString();
                    //MessageBox.Show(ItemName + "\n" + ItemDescription + "\n" + DateRecieved + "\n" + Indiv);
                    string[] words      = Don.Split(separators, StringSplitOptions.None);
                    int      donationID = Convert.ToInt32(words[0]);

                    var donation = (from d in db.Donations
                                    where d.DonationID == donationID
                                    select d).First();
                    if (donation.DonationAmountRemaining >= DonorBill)
                    {
                        Models.Expense expense = new Models.Expense();

                        expense.ExpenseTypeID      = ExpenseTypeID;
                        expense.DonationID         = donationID;
                        expense.PatientID          = Individual.PatientID;
                        expense.AppointmentID      = AppointmentID;
                        expense.ExpenseDueDate     = ExpenseDueDate;
                        expense.DonorBill          = DonorBill;
                        expense.PatientBill        = PatientBill;
                        expense.TotalExpenseAmount = DonorBill + PatientBill;
                        if (IsPaid.IsChecked.Value == true)
                        {
                            expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString());
                        }

                        db.Expenses.Add(expense);
                        db.SaveChanges();
                        var donor = (from d in db.Donors
                                     where d.DonorID == donation.DonorID
                                     select d).First();
                        if (donor.DonorType != "Insurance")
                        {
                            donation.DonationAmountRemaining = donation.DonationAmountRemaining - DonorBill;
                        }
                        db.SaveChanges();

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("That donation does not have enough money.");
                    }
                }
            }
            catch
            {
                //MessageBox.Show(DonorBill.ToString());
                if (DonorBill == 0)
                {
                    try
                    {
                        Models.Expense expense = new Models.Expense();

                        expense.ExpenseTypeID      = ExpenseTypeID;
                        expense.PatientID          = Individual.PatientID;
                        expense.AppointmentID      = AppointmentID;
                        expense.ExpenseDueDate     = ExpenseDueDate;
                        expense.DonorBill          = DonorBill;
                        expense.PatientBill        = PatientBill;
                        expense.TotalExpenseAmount = DonorBill + PatientBill;
                        if (IsPaid.IsChecked.Value == true)
                        {
                            expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString());
                        }

                        db.Expenses.Add(expense);
                        db.SaveChanges();

                        this.Close();
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show("Please make sure all fields are correct: " + exc);
                    }
                }
                else
                {
                    MessageBox.Show("Make sure to select a grant");
                }
            }
        }
コード例 #47
0
		public UpdateSession(SessionsGrid sg)
		{
			try
			{

				Session = sg;

				// Initialize the variables and such
				staffFirstName = sg.StaffFirstName;
				staffLastName = sg.StaffLastName;
				clientFirstName = sg.ClientFirstName;
				clientLastName = sg.ClientLastName;
				appointmentStart = sg.AppointmentStart;
				appointmentEnd = sg.AppointmentEnd;
				expenseDueDate = sg.ExpenseDueDate;
				expensePaidDate = sg.ExpensePaidDate;
				donorBill = sg.DonorBill;
				patientBill = sg.PatientBill;
				totalExpense = sg.TotalExpense;
				expenseType = sg.ExpenseType;
				expenseDescription = sg.ExpenseDescription;
				expenseID = sg.ExpenseID;
				cancellationType = sg.CancellationType;

				oldDonorBill = donorBill;
				newDonorBill = donorBill;

				// Initialize the UI
				InitializeComponent();

				// Disable the patient's first and last name fields
				FN.IsEnabled = false;
				LN.IsEnabled = false;

				//	Select the appointment type
				ApptType.SelectedItem = sg.ExpenseType;

				//	Fill out the information in the form
				FN.Text = sg.ClientFirstName;
				LN.Text = sg.ClientLastName;
				Copay.Text = Math.Round(sg.PatientBill, 2).ToString();
				Deduction.Text = Math.Round(sg.DonorBill, 2).ToString();


				Models.FCS_DBModel db = new Models.FCS_DBModel();
				oldDonationID = (from d in db.Expenses
								 where d.ExpenseID == expenseID
								 select d.DonationID).Distinct().FirstOrDefault();

				var oldDonation = (from d in db.Donations
								   where d.DonationID == oldDonationID
								   select d).FirstOrDefault();

				//	If there is a grant
				if (oldDonation != null)
				{
					if (oldDonation.GrantProposalID != null)
					{
						MoneyDonation.Visibility = Visibility.Hidden;

						var oldGrantName = (from d in db.GrantProposals
											where d.GrantProposalID == oldDonation.GrantProposalID
											select d.GrantName).Distinct().FirstOrDefault();

						DonorDeduction.IsChecked = true;
						Grant.SelectedItem = oldGrantName;
					}
					//	If it is a money donation
					else
					{
						//	UI Updates for the money donation
						DonorDeduction.IsChecked = false;
						Grant.Visibility = Visibility.Hidden;

						//	Get the money donation
						var oldDonorType = (from d in db.Donors
											where d.DonorID == oldDonation.DonorID
											select d.DonorType).Distinct().FirstOrDefault();


						if (oldDonorType == "Organization" || oldDonorType == "Government")
						{

							MoneyDonation.SelectedItem = (from d in db.Donations
														  join dn in db.Donors on d.DonorID equals dn.DonorID
														  where d.DonationID == oldDonationID
														  && dn.DonorID == oldDonation.DonorID
														  select d.DonationID.ToString() + ", " + dn.OrganizationName + ", " + d.DonationAmountRemaining.ToString()).Distinct().FirstOrDefault();
						}
						else if (oldDonorType == "Anonymous" || oldDonorType == "Individual")
						{
							MoneyDonation.SelectedItem = (from d in db.Donations
														  join dn in db.Donors on d.DonorID equals dn.DonorID
														  join c in db.DonorContacts on dn.DonorID equals c.DonorID
														  where d.DonationID == oldDonationID
														  && dn.DonorID == oldDonation.DonorID
														  select d.DonationID + ", " + d.DonationAmountRemaining + ", " + c.ContactFirstName + ", " + c.ContactLastName).Distinct().FirstOrDefault();
						}
					}
				}
				else
				{
					// Hide grant stuffz for consistency
					DonorDeduction.IsChecked = false;
					Grant.Visibility = Visibility.Hidden;
				}

				Staff.SelectedItem = (from o in db.Staff
									  where o.StaffFirstName == staffFirstName && o.StaffLastName == staffLastName
									  select o.StaffFirstName + " " + o.StaffLastName + ", " + o.StaffUserName).Distinct().FirstOrDefault();

				//	If the patient's due is paid
				if (expensePaidDate != null)
				{
					IsPaid.IsChecked = true;
					ExpensePaidDate.IsEnabled = true;
					ExpensePaidDate.Text = sg.ExpensePaidDate.ToString();
				}

				//	Set the date stuff
				DateRecieved.Text = sg.AppointmentStart.ToString();

				//	Start Hour Stuff
				if (sg.AppointmentStart.Hour >= 12)
				{
					if (sg.AppointmentStart.Hour % 12 != 0)
						StartHour.Text = (sg.AppointmentStart.Hour - 12).ToString();
					else
						StartHour.Text = sg.AppointmentStart.Hour.ToString();

					AMPM_Start.SelectedItem = "PM";
				}
				else
				{
					if (sg.AppointmentStart.Hour == 0)
						StartHour.Text = (sg.AppointmentStart.Hour + 12).ToString();
					else
						StartHour.Text = sg.AppointmentStart.Hour.ToString();

					AMPM_Start.SelectedItem = "AM";
				}

				//	End Hour Stuff
				if (sg.AppointmentEnd.Hour >= 12)
				{
					if (sg.AppointmentEnd.Hour % 12 != 0)
						End_Hour.Text = (sg.AppointmentEnd.Hour - 12).ToString();
					else
						End_Hour.Text = sg.AppointmentEnd.Hour.ToString();

					AMPM_End.SelectedItem = "PM";
				}
				else
				{
					if (sg.AppointmentEnd.Hour == 0)
						End_Hour.Text = (sg.AppointmentEnd.Hour + 12).ToString();
					else
						End_Hour.Text = sg.AppointmentEnd.Hour.ToString();

					AMPM_End.SelectedItem = "AM";
				}

				//	Setting the minutes
				StartMinute.Text = DisplayMinuteConversion(sg.AppointmentStart.Minute.ToString());
				End_Minute.Text = DisplayMinuteConversion(sg.AppointmentEnd.Minute.ToString());

				//	Setting the cancellation type
				switch (sg.CancellationType)
				{
					case "Not Cxl":
						CancellationType.SelectedIndex = 0;
						break;
					case "No Show":
						CancellationType.SelectedIndex = 1;
						break;
					case "Late Cxl":
						CancellationType.SelectedIndex = 2;
						break;
					case "Cxl":
						CancellationType.SelectedIndex = 3;
						break;
					default:
						CancellationType.SelectedIndex = 0;
						break;
				}
			}
			catch (Exception error)
			{
				MessageBox.Show("Something went wrong, please try again.");
			}
		}
コード例 #48
0
		private void Update_Expense(object sender, RoutedEventArgs e)
		{
			try
			{
				//Database for use throughout Update_Expense
				Models.FCS_DBModel db = new Models.FCS_DBModel();

				//Update Appointment Type
				//individual (1st option) (ExpenseTypeID = 1 in database)
				//group (3rd option) (ExpenseTypeID = 2 in database)
				int newExpenseTypeID = 0;
				switch (ApptType.SelectedIndex)
				{
					case 0:
						newExpenseTypeID = 1;
						break;
					case 1:
						newExpenseTypeID = 3;
						break;
					case 2:
						newExpenseTypeID = 2;
						break;
				}

				if ((Grant.SelectedValue != null && (bool)DonorDeduction.IsChecked) || (MoneyDonation.SelectedValue != null && !(bool)DonorDeduction.IsChecked))
				{
					//Update Donor/Insurance Deduction
					newDonorBill = Decimal.Parse(Deduction.Text);

					//Update Client Copay in Update All
					//Update Grant/MoneyDonation and Donation
					var oldDonation = (from d in db.Donations
									   where d.DonationID == oldDonationID
									   select d).FirstOrDefault();

					var newDonationQuery = (from d in db.Donations
											select d);

					var expense = (from exp in db.Expenses
								   where exp.ExpenseID == Session.ExpenseID
								   select exp).FirstOrDefault();

					if ((bool)DonorDeduction.IsChecked)
					{
						string newGrant = Grant.SelectedValue.ToString();
						var newGrantproposalID = (from g in db.GrantProposals
												  where g.GrantName == newGrant
												  select g.GrantProposalID).Distinct().FirstOrDefault();

						newDonationQuery = newDonationQuery.Where(x => x.GrantProposalID == newGrantproposalID);
					}
					else
					{
						string[] monDonSeparators = new string[] { ", " };
						string monDon = MoneyDonation.SelectedValue.ToString();
						//MessageBox.Show(ItemName + "\n" + ItemDescription + "\n" + DateRecieved + "\n" + Indiv);
						string[] monDonWords = monDon.Split(monDonSeparators, StringSplitOptions.None);
						int newDonationID = Convert.ToInt32(monDonWords[0]);

						newDonationQuery = newDonationQuery.Where(x => x.DonationID == newDonationID);
					}

					var newDonation = newDonationQuery.FirstOrDefault();

					//	If the new donation is different, check to see if the amount is enough
					decimal amountRemaining = 0;

					if (newDonation.DonationID != oldDonation.DonationID)
					{
						amountRemaining = newDonation.DonationAmountRemaining;
					}
					else
					{
						amountRemaining = newDonation.DonationAmountRemaining + oldDonorBill;
					}

					if (amountRemaining < newDonorBill)
					{
						MessageBox.Show("That donation does not have enough money.");
						return;
					}

					oldDonation.DonationAmountRemaining += oldDonorBill;
					newDonation.DonationAmountRemaining -= newDonorBill;

					expense.DonationID = newDonation.DonationID;
				}

				//Update Therapist
				string[] therSeparators = new string[] { ", ", " " };
				string staff = Staff.SelectedValue.ToString();
				string[] therWords = staff.Split(therSeparators, StringSplitOptions.None);
				string FName = therWords[0];
				string LName = therWords[1];
				string username = therWords[2];
				var newStaffID = (from dc in db.Staff
								  where dc.StaffFirstName == FName && dc.StaffLastName == LName && dc.StaffUserName == username
								  select dc.StaffID).Distinct().FirstOrDefault();

				//Update PaidBill and Date is done when everything is updated

				//Update Appointment Time and Date
				BeginHour = StartHour.Text;
				EndHour = End_Hour.Text;
				BeginMinute = StartMinute.Text;
				EndMinute = End_Minute.Text;

				if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
				{
					BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
				}
				if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
				{
					EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
				}
				if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
				{
					BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
				}
				if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
				{
					EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
				}

				DateTime help = Convert.ToDateTime(DateRecieved.ToString());
				DateTime newStartDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
				DateTime newEndDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
				DateTime newExpenseDueDate = newStartDateTime.AddDays(30);

				//Update Cancellation Type
				string newCancellationType;
				switch (CancellationType.SelectedIndex)
				{
					case 0:
						newCancellationType = "Not Cxl";
						break;
					case 1:
						newCancellationType = "No Show";
						break;
					case 2:
						newCancellationType = "Late Cxl";
						break;
					case 3:
						newCancellationType = "Cxl";
						break;
					default:
						newCancellationType = "Not Cxl";
						break;
				}

				//Update All Changes
				var newExpense = (from exp in db.Expenses
								  where exp.ExpenseID == Session.ExpenseID
								  select exp).First();
				var newAppointmentID = newExpense.AppointmentID;
				newExpense.ExpenseTypeID = newExpenseTypeID;
				newExpense.ExpenseDueDate = newExpenseDueDate;
				decimal temp = 0;
				Decimal.TryParse(Copay.Text, out temp);
				newExpense.PatientBill = temp;
				decimal temp2 = 0;
				Decimal.TryParse(Deduction.Text, out temp2);
				newExpense.DonorBill = temp2;
				newExpense.TotalExpenseAmount = temp + temp2;
				if (IsPaid.IsChecked.Value == true)
				{
					newExpense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString());
				}
				else
				{
					newExpense.ExpensePaidDate = null;
				}
				var newAppointment = (from a in db.Appointments
									  where a.AppointmentID == newAppointmentID
									  select a).First();
				newAppointment.StaffID = newStaffID;
				newAppointment.AppointmentStartDate = newStartDateTime;
				newAppointment.AppointmentEndDate = newEndDateTime;
				newAppointment.AppointmentCancelationType = newCancellationType;
				db.SaveChanges();
				this.Close();
			}
			catch (Exception error)
			{
				MessageBox.Show("Something went wrong. Please check the fields and try again.");
			}
		}
コード例 #49
0
		private void MoneyDonation_DropDown(object sender, RoutedEventArgs e)
		{
			Models.FCS_DBModel db = new Models.FCS_DBModel();
			var join2 = (from d in db.Donations
						 join dn in db.Donors on d.DonorID equals dn.DonorID
						 where (dn.DonorType == "Organization" || dn.DonorType == "Government" || dn.DonorType == "Insurance")
						 select d.DonationID.ToString() + ", " + dn.OrganizationName + ", " + d.DonationAmountRemaining.ToString()).Union
						 (from d in db.Donations
						  join dn in db.Donors on d.DonorID equals dn.DonorID
						  join c in db.DonorContacts on dn.DonorID equals c.DonorID
						  where (dn.DonorType == "Anonymous" || dn.DonorType == "Individual")
						  && d.GrantProposalID == null
						  select d.DonationID + ", " + d.DonationAmountRemaining + ", " + c.ContactFirstName + ", " + c.ContactLastName).ToList();
			//var query = (from d in db.Donations
			//             where d.GrantProposalID == null
			//             select d.DonationID.ToString() + d.DonationPurposes).ToList();

			var box = sender as ComboBox;
			box.ItemsSource = join2;
		}
コード例 #50
0
        private void Add_InKind_Service(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }
            try
            {
                DateTime help = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                decimal timeDiff = (decimal)(endDateTime - startDateTime).TotalHours;
                if (ServiceDescription != null && ServiceDescription != "" && RatePerHour > 0 && timeDiff > 0 && Individual.SelectedIndex != -1)
                {
                    string[] separators = new string[] { ", " };
                    string Indiv = Individual.SelectedValue.ToString();
                    Models.FCS_DBModel db = new Models.FCS_DBModel();
                    //MessageBox.Show(ServiceDescription + "\n" + RatePerHour + "\n" + startDateTime + "\n" + endDateTime + "\n" + timeDiff + "\n" + Indiv);
                    string[] words = Indiv.Split(separators, StringSplitOptions.None);
                    string FName = words[0]; string LName = words[1]; string FNumber = words[2];
                    var donorID = (from dc in db.DonorContacts
                                   join d in db.Donors on dc.DonorID equals d.DonorID
                                   where dc.ContactFirstName == FName && dc.ContactLastName == LName && dc.ContactPhone == FNumber
                                   && (d.DonorType == "Individual" || d.DonorType == "Anonymous")
                                   select dc.DonorID).Distinct().FirstOrDefault();

                    if (IsEvent)
                    {
                        Models.Donation donation = new Models.Donation();

                        donation.DonorID = donorID;
                        donation.Restricted = false;
                        donation.InKind = true;
                        donation.DonationAmount = 0M;
                        donation.DonationDate = Convert.ToDateTime(DateRecieved.ToString());
                        donation.EventID = EventID;

                        db.Donations.Add(donation);
                        db.SaveChanges();

                        Models.In_Kind_Service inKind = new Models.In_Kind_Service();

                        inKind.DonationID = donation.DonationID;
                        inKind.StartDateTime = startDateTime;
                        inKind.EndDateTime = endDateTime;
                        inKind.RatePerHour = RatePerHour;
                        inKind.ServiceDescription = ServiceDescription;
                        inKind.ServiceLength = (double)timeDiff;
                        inKind.ServiceValue = RatePerHour * timeDiff;

                        db.In_Kind_Service.Add(inKind);
                        db.SaveChanges();
                    }
                    else
                    {
                        Models.Donation donation = new Models.Donation();

                        donation.DonorID = donorID;
                        donation.InKind = false;
                        donation.Restricted = true;
                        donation.DonationAmount = 0M;
                        donation.DonationDate = Convert.ToDateTime(DateRecieved.ToString());

                        db.Donations.Add(donation);
                        db.SaveChanges();

                        Models.In_Kind_Service inKind = new Models.In_Kind_Service();

                        inKind.DonationID = donation.DonationID;
                        inKind.StartDateTime = startDateTime;
                        inKind.EndDateTime = endDateTime;
                        inKind.RatePerHour = RatePerHour;
                        inKind.ServiceDescription = ServiceDescription;
                        inKind.ServiceLength = (double)timeDiff;
                        inKind.ServiceValue = RatePerHour * timeDiff;

                        db.In_Kind_Service.Add(inKind);
                        db.SaveChanges();
                    }

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Please check the data entered.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
コード例 #51
0
        private void Donations_Grid(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();

            var join1 = (from d in db.Donations
                         where d.DonorID == DonorID
                         select new DonationsGrid
                         {
                             DonationAmount = d.DonationAmount,
                             DonationAmountRemaining = d.DonationAmountRemaining,
                             DonationDate = d.DonationDate,
                             PurposeName = (from p in db.Purposes
                                            join dp in db.DonationPurposes on p.PurposeID equals dp.PurposeID
                                            where dp.DonationID == d.DonationID
                                            select p.PurposeName).FirstOrDefault(),
                             PurposeDescription = (from p in db.Purposes
                                                   join dp in db.DonationPurposes on p.PurposeID equals dp.PurposeID
                                                   where dp.DonationID == d.DonationID
                                                   select p.PurposeDescription).FirstOrDefault(),
                             DonorID = d.DonorID,
                             DonationPurposeID = (from p in db.Purposes
                                                  join dp in db.DonationPurposes on p.PurposeID equals dp.PurposeID
                                                  where dp.DonationID == d.DonationID
                                                  select dp.DonationPurposeID).FirstOrDefault(),
                             PurposeID = (from p in db.Purposes
                                          join dp in db.DonationPurposes on p.PurposeID equals dp.PurposeID
                                          where dp.DonationID == d.DonationID
                                          select dp.PurposeID).FirstOrDefault(),
                             DonationID = d.DonationID
                         }).ToList();

            // ... Assign ItemsSource of DataGrid.
            var grid = sender as DataGrid;
            grid.ItemsSource = join1.ToList();
        }
コード例 #52
0
        private void Staff_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query = (from o in db.Staff
                         select o.StaffFirstName + ", " + o.StaffLastName + ", " + o.StaffUserName).ToList();

            var box = sender as ComboBox;
            box.ItemsSource = query;
        }
コード例 #53
0
        private void Add_InKind_Service(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }
            try
            {
                DateTime help          = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime   = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                decimal  timeDiff      = (decimal)(endDateTime - startDateTime).TotalHours;
                if (ServiceDescription != null && ServiceDescription != "" && RatePerHour > 0 && timeDiff > 0 && Individual.SelectedIndex != -1)
                {
                    string[]           separators = new string[] { ", " };
                    string             Indiv      = Individual.SelectedValue.ToString();
                    Models.FCS_DBModel db         = new Models.FCS_DBModel();
                    //MessageBox.Show(ServiceDescription + "\n" + RatePerHour + "\n" + startDateTime + "\n" + endDateTime + "\n" + timeDiff + "\n" + Indiv);
                    string[] words = Indiv.Split(separators, StringSplitOptions.None);
                    string   FName = words[0]; string LName = words[1]; string FNumber = words[2];
                    var      donorID = (from dc in db.DonorContacts
                                        join d in db.Donors on dc.DonorID equals d.DonorID
                                        where dc.ContactFirstName == FName && dc.ContactLastName == LName && dc.ContactPhone == FNumber &&
                                        (d.DonorType == "Individual" || d.DonorType == "Anonymous")
                                        select dc.DonorID).Distinct().FirstOrDefault();

                    if (IsEvent)
                    {
                        Models.Donation donation = new Models.Donation();

                        donation.DonorID        = donorID;
                        donation.Restricted     = false;
                        donation.InKind         = true;
                        donation.DonationAmount = 0M;
                        donation.DonationDate   = Convert.ToDateTime(DateRecieved.ToString());
                        donation.EventID        = EventID;

                        db.Donations.Add(donation);
                        db.SaveChanges();

                        Models.In_Kind_Service inKind = new Models.In_Kind_Service();

                        inKind.DonationID         = donation.DonationID;
                        inKind.StartDateTime      = startDateTime;
                        inKind.EndDateTime        = endDateTime;
                        inKind.RatePerHour        = RatePerHour;
                        inKind.ServiceDescription = ServiceDescription;
                        inKind.ServiceLength      = (double)timeDiff;
                        inKind.ServiceValue       = RatePerHour * timeDiff;

                        db.In_Kind_Service.Add(inKind);
                        db.SaveChanges();
                    }
                    else
                    {
                        Models.Donation donation = new Models.Donation();

                        donation.DonorID        = donorID;
                        donation.InKind         = false;
                        donation.Restricted     = true;
                        donation.DonationAmount = 0M;
                        donation.DonationDate   = Convert.ToDateTime(DateRecieved.ToString());

                        db.Donations.Add(donation);
                        db.SaveChanges();

                        Models.In_Kind_Service inKind = new Models.In_Kind_Service();

                        inKind.DonationID         = donation.DonationID;
                        inKind.StartDateTime      = startDateTime;
                        inKind.EndDateTime        = endDateTime;
                        inKind.RatePerHour        = RatePerHour;
                        inKind.ServiceDescription = ServiceDescription;
                        inKind.ServiceLength      = (double)timeDiff;
                        inKind.ServiceValue       = RatePerHour * timeDiff;

                        db.In_Kind_Service.Add(inKind);
                        db.SaveChanges();
                    }

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Please check the data entered.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
コード例 #54
0
        private void Add_InKind_Item(object sender, RoutedEventArgs e)
        {
            if (ItemName != null && ItemName != "" && ItemDescription != null && ItemDescription != "" && DateRecieved.ToString() != null && DateRecieved.ToString() != "")
            {
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                //Then its an organization
                if (OrgOrIndividual.IsChecked.Value && Organization.SelectedIndex != -1)
                {
                    string Organiz = Organization.SelectedValue.ToString();
                    //MessageBox.Show(ItemName + "\n" + ItemDescription + "\n" + DateRecieved + "\n" + Organiz + "\n" + "You got HERE");
                    var donorID = (from d in db.Donors
                                   where d.OrganizationName == Organiz
                                   select d.DonorID).Distinct().First();
                    //MessageBox.Show(donorID.ToString());

                    if (IsEvent)
                    {
                        Models.Donation donation = new Models.Donation();
                        donation.DonorID = donorID;
                        donation.Restricted = false;
                        donation.InKind = true;
                        donation.DonationAmount = 0M;
                        donation.DonationDate = Convert.ToDateTime(DateRecieved.ToString());
                        donation.EventID = EventID;
                        db.Donations.Add(donation);
                        db.SaveChanges();

                        Models.In_Kind_Item inKind = new Models.In_Kind_Item();
                        inKind.DonationID = donation.DonationID;
                        inKind.ItemName = ItemName;
                        inKind.ItemDescription = ItemDescription;
                        db.In_Kind_Item.Add(inKind);
                        db.SaveChanges();
                    }
                    else
                    {
                        
                        Models.Donation donation = new Models.Donation();
                        donation.DonorID = donorID;
                        donation.Restricted = false;
                        donation.InKind = true;
                        donation.DonationAmount = 0M;
                        donation.DonationDate = Convert.ToDateTime(DateRecieved.ToString());
                        db.Donations.Add(donation);
                        db.SaveChanges();

                        Models.In_Kind_Item inKind = new Models.In_Kind_Item();
                        inKind.DonationID = donation.DonationID;
                        inKind.ItemName = ItemName;
                        inKind.ItemDescription = ItemDescription;
                        db.In_Kind_Item.Add(inKind);
                        db.SaveChanges();
                    }
                }
                //then its an individual
                else if (Individual.SelectedIndex != -1)
                {
                    string[] separators = new string[] { ", " };
                    string Indiv = Individual.SelectedValue.ToString();
                    //MessageBox.Show(ItemName + "\n" + ItemDescription + "\n" + DateRecieved + "\n" + Indiv);
                    string[] words = Indiv.Split(separators, StringSplitOptions.None);
                    string FName = words[0]; string LName = words[1]; string FNumber = words[2];
                    var donorID = (from dc in db.DonorContacts
                                   join d in db.Donors on dc.DonorID equals d.DonorID
                                   where dc.ContactFirstName == FName && dc.ContactLastName == LName && dc.ContactPhone == FNumber
                                   && (d.DonorType == "Individual" || d.DonorType == "Anonymous")
                                   select dc.DonorID).Distinct().FirstOrDefault();

                    if (IsEvent)
                    {
                        Models.Donation donation = new Models.Donation();
                        donation.DonorID = donorID;
                        donation.Restricted = false;
                        donation.InKind = true;
                        donation.DonationAmount = 0M;
                        donation.DonationDate = Convert.ToDateTime(DateRecieved.ToString());
                        donation.EventID = EventID;
                        db.Donations.Add(donation);
                        db.SaveChanges();

                        Models.In_Kind_Item inKind = new Models.In_Kind_Item();
                        inKind.DonationID = donation.DonationID;
                        inKind.ItemName = ItemName;
                        inKind.ItemDescription = ItemDescription;
                        db.In_Kind_Item.Add(inKind);
                        db.SaveChanges();
                    }
                    else
                    {
                        Models.Donation donation = new Models.Donation();
                        donation.DonorID = donorID;
                        donation.Restricted = false;
                        donation.InKind = true;
                        donation.DonationAmount = 0M;
                        donation.DonationDate = Convert.ToDateTime(DateRecieved.ToString());
                        db.Donations.Add(donation);
                        db.SaveChanges();

                        Models.In_Kind_Item inKind = new Models.In_Kind_Item();
                        inKind.DonationID = donation.DonationID;
                        inKind.ItemName = ItemName;
                        inKind.ItemDescription = ItemDescription;
                        db.In_Kind_Item.Add(inKind);
                        db.SaveChanges();
                    }
                }
                else
                {
                    MessageBox.Show("Make sure to select an organization or an individual");
                    return;
                }
                
                this.Close();

            }
            //add both patient and household
            else
            {
                MessageBox.Show("Make sure the data is correct.");
            }
        }
コード例 #55
0
 private void SessionsGrid(object sender, RoutedEventArgs e)
 {
     Models.FCS_DBModel db = new Models.FCS_DBModel();
     var join1 = from s in db.Staff
                 join a in db.Appointments on s.StaffID equals a.StaffID
                 join ex in db.Expenses on a.AppointmentID equals ex.AppointmentID
                 join et in db.ExpenseTypes on ex.ExpenseTypeID equals et.ExpenseTypeID
                 where ex.PatientID == PatientID
                 select new SessionsGrid
                 {
                     StaffFirstName = s.StaffFirstName,
                     StaffLastName = s.StaffLastName,
                     AppointmentStart = a.AppointmentStartDate,
                     AppointmentEnd = a.AppointmentEndDate,
                     ExpenseDueDate = ex.ExpenseDueDate,
                     ExpensePaidDate = ex.ExpensePaidDate,
                     DonorBill = ex.DonorBill,
                     PatientBill = ex.PatientBill,
                     TotalExpense = ex.TotalExpenseAmount,
                     ExpenseType = et.ExpenseType1,
                     ExpenseDescription = et.ExpenseDescription
                 };
     // ... Assign ItemsSource of DataGrid.
     var grid = sender as DataGrid;
     grid.ItemsSource = join1.ToList();
 }
コード例 #56
0
        private void Add_Expense(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            try
            {
                //Taking the money from a grant
                if (DonorDeduction.IsChecked.Value)
                {
                    string grant = Grant.SelectedValue.ToString();
                    var grantproposalID = (from g in db.GrantProposals
                                           where g.GrantName == grant
                                           select g.GrantProposalID).Distinct().FirstOrDefault();
                    var grantDonation = (from d in db.Donations
                                         where d.GrantProposalID == grantproposalID
                                         select d).First();
                    if (grantDonation.DonationAmountRemaining >= DonorBill)
                    {
                        Models.Expense expense = new Models.Expense();

                        var donationID = (from d in db.Donations
                                          where d.GrantProposalID == grantproposalID
                                          select d.DonationID).Distinct().FirstOrDefault();
                        expense.DonationID = donationID;

                        expense.ExpenseTypeID = ExpenseTypeID;
                        expense.PatientID = Individual.PatientID;
                        expense.AppointmentID = AppointmentID;
                        expense.ExpenseDueDate = ExpenseDueDate;
                        expense.DonorBill = DonorBill;
                        expense.PatientBill = PatientBill;
                        expense.TotalExpenseAmount = DonorBill + PatientBill;
                        if (IsPaid.IsChecked.Value == true) { expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString()); }

                        db.Expenses.Add(expense);
                        db.SaveChanges();
                        grantDonation.DonationAmountRemaining = grantDonation.DonationAmountRemaining - DonorBill;
                        db.SaveChanges();

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("That grant does not have enough money.");
                    }
                }
                //taking the money from a money donation.
                else
                {
                    string[] separators = new string[] { ", " };
                    string Don = MoneyDonation.SelectedValue.ToString();
                    //MessageBox.Show(ItemName + "\n" + ItemDescription + "\n" + DateRecieved + "\n" + Indiv);
                    string[] words = Don.Split(separators, StringSplitOptions.None);
                    int donationID = Convert.ToInt32(words[0]);

                    var donation = (from d in db.Donations
                                    where d.DonationID == donationID
                                    select d).First();
                    if (donation.DonationAmountRemaining >= DonorBill)
                    {
                        Models.Expense expense = new Models.Expense();

                        expense.ExpenseTypeID = ExpenseTypeID;
                        expense.DonationID = donationID;
                        expense.PatientID = Individual.PatientID;
                        expense.AppointmentID = AppointmentID;
                        expense.ExpenseDueDate = ExpenseDueDate;
                        expense.DonorBill = DonorBill;
                        expense.PatientBill = PatientBill;
                        expense.TotalExpenseAmount = DonorBill + PatientBill;
                        if (IsPaid.IsChecked.Value == true) { expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString()); }

                        db.Expenses.Add(expense);
                        db.SaveChanges();
                        var donor = (from d in db.Donors
                                     where d.DonorID == donation.DonorID
                                     select d).First();
                        if (donor.DonorType != "Insurance")
                        {
                            donation.DonationAmountRemaining = donation.DonationAmountRemaining - DonorBill;
                        }
                        db.SaveChanges();

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("That donation does not have enough money.");
                    }
                }
            }
            catch
            {
                //MessageBox.Show(DonorBill.ToString());
                if (DonorBill == 0)
                {
                    try
                    {
                        Models.Expense expense = new Models.Expense();

                        expense.ExpenseTypeID = ExpenseTypeID;
                        expense.PatientID = Individual.PatientID;
                        expense.AppointmentID = AppointmentID;
                        expense.ExpenseDueDate = ExpenseDueDate;
                        expense.DonorBill = DonorBill;
                        expense.PatientBill = PatientBill;
                        expense.TotalExpenseAmount = DonorBill + PatientBill;
                        if (IsPaid.IsChecked.Value == true) { expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString()); }

                        db.Expenses.Add(expense);
                        db.SaveChanges();
                        
                        this.Close();
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show("Please make sure all fields are correct: " + exc);
                    }
                }
                else
                {
                    MessageBox.Show("Make sure to select a grant");
                }
            }
        }
コード例 #57
0
        private void Grants_DropDown(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            var query = (from o in db.GrantProposals
                         where o.GrantStatus == "Accepted"
                         select o.GrantName).ToList();

            var box = sender as ComboBox;
            box.ItemsSource = query;
        }
コード例 #58
0
        private void Add_Appointment(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }
            try
            {
                DateTime           expenseDueDate = Convert.ToDateTime(ExpenseDueDate.ToString());
                DateTime           help           = Convert.ToDateTime(DateRecieved.ToString());
                DateTime           startDateTime  = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime           endDateTime    = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                string[]           separators     = new string[] { ", " };
                string             staff          = Staff.SelectedValue.ToString();
                string             grant          = Grant.SelectedValue.ToString();
                Models.FCS_DBModel db             = new Models.FCS_DBModel();
                //MessageBox.Show(PatientBill + "\n" + DonorBill + "\n" + startDateTime + "\n" + endDateTime + "\n" + expenseDueDate + "\n" + staff, grant);
                string[] words = staff.Split(separators, StringSplitOptions.None);
                string   FName = words[0]; string LName = words[1]; string username = words[2];
                var      staffID = (from dc in db.Staff
                                    where dc.StaffFirstName == FName && dc.StaffLastName == LName && dc.StaffUserName == username
                                    select dc.StaffID).Distinct().FirstOrDefault();
                var grantproposalID = (from g in db.GrantProposals
                                       where g.GrantName == grant
                                       select g.GrantProposalID).Distinct().FirstOrDefault();
                var donationID = (from d in db.Donations
                                  where d.GrantProposalID == grantproposalID
                                  select d.DonationID).Distinct().FirstOrDefault();
                var donation = (from d in db.Donations
                                where d.GrantProposalID == grantproposalID
                                select d).First();
                if (donation.DonationAmountRemaining >= DonorBill)
                {
                    Models.Appointment a = new Models.Appointment();
                    a.StaffID = staffID;
                    a.AppointmentStartDate = startDateTime;
                    a.AppointmentEndDate   = endDateTime;
                    db.Appointments.Add(a);
                    db.SaveChanges();

                    Models.Expense expense = new Models.Expense();

                    expense.ExpenseTypeID      = 1;
                    expense.DonationID         = donationID;
                    expense.PatientID          = PatientID;
                    expense.AppointmentID      = a.AppointmentID;
                    expense.ExpenseDueDate     = expenseDueDate;
                    expense.DonorBill          = DonorBill;
                    expense.PatientBill        = PatientBill;
                    expense.TotalExpenseAmount = DonorBill + PatientBill;
                    if (ExpensePaidDate.IsEnabled == true)
                    {
                        expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString());
                    }
                    db.Expenses.Add(expense);
                    db.SaveChanges();

                    donation.DonationAmountRemaining = donation.DonationAmountRemaining - DonorBill;
                    db.SaveChanges();


                    this.Close();
                }
                else
                {
                    MessageBox.Show("This would result in a negative balance.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
コード例 #59
0
        private void Add_Appointment(object sender, RoutedEventArgs e)
        {
            if (AMPM_Start.SelectedValue.ToString() == "PM" && Convert.ToInt32(BeginHour) != 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) + 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "PM" && Convert.ToInt32(EndHour) != 12)
            {
                EndHour = (Convert.ToInt32(EndHour) + 12).ToString();
            }
            if (AMPM_Start.SelectedValue.ToString() == "AM" && Convert.ToInt32(BeginHour) == 12)
            {
                BeginHour = (Convert.ToInt32(BeginHour) - 12).ToString();
            }
            if (AMPM_End.SelectedValue.ToString() == "AM" && Convert.ToInt32(EndHour) == 12)
            {
                EndHour = (Convert.ToInt32(EndHour) - 12).ToString();
            }
            try
            {
                DateTime expenseDueDate = Convert.ToDateTime(ExpenseDueDate.ToString());
                DateTime help = Convert.ToDateTime(DateRecieved.ToString());
                DateTime startDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(BeginHour), Convert.ToInt32(BeginMinute), 0);
                DateTime endDateTime = new DateTime(help.Year, help.Month, help.Day, Convert.ToInt32(EndHour), Convert.ToInt32(EndMinute), 0);
                string[] separators = new string[] { ", " };
                string staff = Staff.SelectedValue.ToString();
                string grant = Grant.SelectedValue.ToString();
                Models.FCS_DBModel db = new Models.FCS_DBModel();
                //MessageBox.Show(PatientBill + "\n" + DonorBill + "\n" + startDateTime + "\n" + endDateTime + "\n" + expenseDueDate + "\n" + staff, grant);
                string[] words = staff.Split(separators, StringSplitOptions.None);
                string FName = words[0]; string LName = words[1]; string username = words[2];
                var staffID = (from dc in db.Staff
                               where dc.StaffFirstName == FName && dc.StaffLastName == LName && dc.StaffUserName == username
                               select dc.StaffID).Distinct().FirstOrDefault();
                var grantproposalID = (from g in db.GrantProposals
                                       where g.GrantName == grant
                                       select g.GrantProposalID).Distinct().FirstOrDefault();
                var donationID = (from d in db.Donations
                                  where d.GrantProposalID == grantproposalID
                                  select d.DonationID).Distinct().FirstOrDefault();
                var donation = (from d in db.Donations
                                where d.GrantProposalID == grantproposalID
                                select d).First();
                if (donation.DonationAmountRemaining >= DonorBill)
                {
                    Models.Appointment a = new Models.Appointment();
                    a.StaffID = staffID;
                    a.AppointmentStartDate = startDateTime;
                    a.AppointmentEndDate = endDateTime;
                    db.Appointments.Add(a);
                    db.SaveChanges();

                    Models.Expense expense = new Models.Expense();

                    expense.ExpenseTypeID = 1;
                    expense.DonationID = donationID;
                    expense.PatientID = PatientID;
                    expense.AppointmentID = a.AppointmentID;
                    expense.ExpenseDueDate = expenseDueDate;
                    expense.DonorBill = DonorBill;
                    expense.PatientBill = PatientBill;
                    expense.TotalExpenseAmount = DonorBill + PatientBill;
                    if (ExpensePaidDate.IsEnabled == true) { expense.ExpensePaidDate = Convert.ToDateTime(ExpensePaidDate.ToString()); }
                    db.Expenses.Add(expense);
                    db.SaveChanges();

                    donation.DonationAmountRemaining = donation.DonationAmountRemaining - DonorBill;
                    db.SaveChanges();


                    this.Close();
                }
                else
                {
                    MessageBox.Show("This would result in a negative balance.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
コード例 #60
0
        private void CreateAccount(object sender, RoutedEventArgs e)
        {
            Models.FCS_DBModel db = new Models.FCS_DBModel();
            string Role = UserRole.SelectedValue.ToString();

            string password = Password.Password.ToString();
            string verifiedPW = VerifyPassword.Password.ToString();
            string hashedPassword = PasswordHashing.GetHashString(password);

            int usernameVerify = (from uv in db.Staff
                                  where uv.StaffUserName == UserName
                                  select uv).Count();
            if (Role == "No Access")
            {
                if (FirstName == null || FirstName == "" || LastName == null || LastName == "" || StaffTitle == null || StaffTitle == "")
                {
                    MessageBox.Show("Please check the data entered.");
                }
                else
                {
                    Models.Staff account = new Models.Staff();
                    account.StaffFirstName = FirstName;
                    account.StaffLastName = LastName;
                    account.StaffTitle = StaffTitle;
                    account.StaffUserName = UserName;
                    account.StaffPassword = hashedPassword;
                    account.StaffDBRole = Role;
                    db.Staff.Add(account);
                    db.SaveChanges();
                    this.Close();
                }
            }
            else
            {
                if (password.Length < 5)
                {
                    MessageBox.Show("Please pick a longer password (Minimum length of 5)");
                }
                else if (password != verifiedPW)
                {
                    MessageBox.Show("Passwords do not match!");
                }
                else if (UserName == null || UserName == "" || FirstName == null || FirstName == ""
                    || LastName == null || LastName == "" || StaffTitle == null || StaffTitle == "")
                {
                    MessageBox.Show("Please check the data entered. A required field is missing.");
                }
                else if (UserName.Contains(" "))
                {
                    MessageBox.Show("User name cannot contain spaces");
                }
                else if(usernameVerify != 0)
                {
                    MessageBox.Show("That username selected is already taken");
                }
                else
                {
                    Models.Staff account = new Models.Staff();
                    account.StaffFirstName = FirstName;
                    account.StaffLastName = LastName;
                    account.StaffTitle = StaffTitle;
                    account.StaffUserName = UserName;
                    account.StaffPassword = hashedPassword;
                    account.StaffDBRole = Role;
                    db.Staff.Add(account);
                    db.SaveChanges();
                    this.Close();
                }
            }
        }