Пример #1
0
        private void UpdatePasword(object sender, RoutedEventArgs e)
        {
            db = new FCS_DBModel();
            string password       = Password.Password.ToString();
            string verifiedPW     = VerifyPassword.Password.ToString();
            string hashedPassword = PasswordHashing.GetHashString(password);

            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
            {
                try {
                    var staff = (from p in db.Staff
                                 where p.StaffID == StaffID
                                 select p).First();
                    staff.StaffPassword = hashedPassword;
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("Something went wrong. Please try again.");
                }
                this.Close();
            }
        }
        private void Add_Contact(object sender, RoutedEventArgs e)
        {
            if (ContactFirstName != null && ContactFirstName != "" && ContactLastName != null && ContactLastName != "")
            {
                FCS_DBModel  db = new FCS_DBModel();
                DonorContact d  = new DonorContact();

                d.ContactFirstName = ContactFirstName;
                d.ContactLastName  = ContactLastName;
                d.ContactPhone     = ContactPhone;
                d.ContactEmail     = ContactEmail;
                d.DonorID          = DonorID;

                db.DonorContacts.Add(d);
                if (ContactPhone.Length < 11)
                {
                    db.SaveChanges();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("The phone number entered is invalid.");
                }
            }
            //add both patient and household
            else
            {
                MessageBox.Show("Please check the data entered.");
            }
        }
Пример #3
0
        private void Refresh_InKindServiceGrid(object sender, RoutedEventArgs e)
        {
            var db    = new 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 == null
                         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
            });

            Service_DataGrid.ItemsSource = join1.ToList();
        }
Пример #4
0
        private void EditGrant(object sender, MouseButtonEventArgs e)
        {
            var db = new FCS_DBModel();

            try
            {
                DataGrid dg = sender as DataGrid;

                GrantsDataGrid p  = (GrantsDataGrid)dg.SelectedItems[0];                // OR:  Patient p = (Patient)dg.SelectedItem;
                UpdateGrant    up = new UpdateGrant(p);
                //Grant prop ID & donation ID with expense
                //p.DonationID
                var expenseTotal = (from ex in db.Expenses
                                    where ex.DonationID == p.DonationID
                                    select ex).Count();
                if (expenseTotal > 0)
                {
                    up.DonAmount.IsEnabled = false; up.AmountRem.IsEnabled = false;
                }
                up.DonationDate.SelectedDate       = p.DonationDate;
                up.DonationExpiration.SelectedDate = p.ExpirationDate;
                up.ShowDialog();
            }
            catch (Exception error)
            {
            }

            Refresh_GrantGrid(sender, e);
        }
Пример #5
0
        private void Refresh_GrantGrid(object sender, RoutedEventArgs e)
        {
            var db    = new FCS_DBModel();
            var join1 = from d in db.Donations
                        join dr in db.Donors on d.DonorID equals dr.DonorID
                        join gp in db.GrantProposals on dr.DonorID equals gp.DonorID
                        join dp in db.DonationPurposes on d.DonationID equals dp.DonationID
                        join p in db.Purposes on dp.PurposeID equals p.PurposeID
                        where gp.GrantStatus == "Accepted" && d.GrantProposalID == gp.GrantProposalID
                        select new GrantsDataGrid
            {
                GrantName               = gp.GrantName,
                DonationAmount          = d.DonationAmount,
                DonationAmountRemaining = d.DonationAmountRemaining,
                DonationDate            = d.DonationDate,
                ExpirationDate          = d.DonationExpirationDate,
                DonationID              = d.DonationID,
                DonorID            = dr.DonorID,
                GrantProposalID    = gp.GrantProposalID,
                PurposeName        = p.PurposeName,
                PurposeDescription = p.PurposeDescription
            };

            // ... Assign ItemsSource of DataGrid.
            Grant_DataGrid.ItemsSource = join1.ToList();
        }
Пример #6
0
        private void ShowProblems()
        {
            var        toggle          = PatientProblemsCheckBoxes.Children;
            List <int> currentProblems = new List <int>();

            FCS_DBModel    db      = new FCS_DBModel();
            PatientProblem patProb = new PatientProblem();
            int            patID   = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientID).Distinct().First();

            foreach (var item in db.PatientProblems.Where(x => x.PatientID == patID).Select(x => x.ProblemID))
            {
                currentProblems.Add(item);
            }

            foreach (var item in toggle)
            {
                foreach (var curProb in currentProblems)
                {
                    if (curProb == GetProblemID(((ContentControl)item).Content.ToString()))
                    {
                        ((ToggleButton)item).IsChecked = true;
                    }
                }
            }
        }
Пример #7
0
        public void Determine_Problems(string OQ)
        {
            FCS_DBModel db           = new FCS_DBModel();
            var         toggle       = PatientProblemsCheckBoxes.Children;
            var         problemTable = db.Problems;

            foreach (var item in toggle)
            {
                string checkboxProblemName = (((ContentControl)item).Content).ToString();
                if (((ToggleButton)item).IsChecked == true)
                {
                    try
                    {
                        PatientProblem patProb = new PatientProblem();
                        int            patID   = db.Patients.Where(x => x.PatientOQ == OQ).Select(x => x.PatientID).Distinct().First();
                        patProb.PatientID = patID;
                        patProb.ProblemID = GetProblemID(checkboxProblemName);
                        db.PatientProblems.Add(patProb);
                        db.SaveChanges();

                        //var problem =
                    }
                    catch (Exception error) { }
                }
            }
        }
Пример #8
0
 private void Refresh_SessionsGrid(object sender, RoutedEventArgs e)
 {
     try
     {
         FCS_DBModel db        = new FCS_DBModel();
         int         patientID = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientID).Distinct().First();
         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();
     }
     catch { }
 }
Пример #9
0
        /// <summary>
        /// This function refreshes the grid for the Sessions tab with data from the database
        /// </summary>
        private void Refresh_SessionGrid()
        {
            var db    = new 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
                        join p in db.Patients on ex.PatientID equals p.PatientID
                        select new SessionsGrid
            {
                StaffFirstName     = s.StaffFirstName,
                StaffLastName      = s.StaffLastName,
                ClientFirstName    = p.PatientFirstName,
                ClientLastName     = p.PatientLastName,
                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,
                ExpenseID          = ex.ExpenseID,
                CancellationType   = a.AppointmentCancelationType
            };

            //	Set the data to the grid
            Session_DataGrid.ItemsSource = join1.ToList();
        }
        private void Add_Client(object sender, RoutedEventArgs e)
        {
            Patient     tempPatient = new Patient();
            Problem     tempProblem = new Problem();
            FCS_DBModel db          = new FCS_DBModel();


            Determine_AgeGroup(combobox_AgeGroup.SelectedIndex);
            Determine_EthnicGroup(combobox_ethnicity.SelectedIndex);
            Determine_Gender(combobox_Gender.SelectedIndex);
            var togglePatientProblems = PatientProblemsCheckBoxes.Children;

            try
            {
                //	Check to see if there needs to be a new household made first
                if ((bool)check_FirstHouseholdMember.IsChecked)
                {
                    Determine_Income(combobox_IncomeBracket.SelectedIndex);
                    Determine_County(combobox_County.SelectedIndex);

                    PatientHousehold household = new PatientHousehold();
                    household.HouseholdCounty        = County;
                    household.HouseholdIncomeBracket = Income;
                    household.HouseholdPopulation    = HouseholdPopulation;
                    db.PatientHouseholds.Add(household);
                    db.SaveChanges();

                    tempPatient.HouseholdID = household.HouseholdID;
                }
                else
                {
                    tempPatient.HouseholdID = db.Patients.Where(x => x.PatientOQ == familyOQNumber).Select(x => x.HouseholdID).Distinct().First();
                }

                bool isHeadOfHouse = (bool)check_HeadOfHousehold.IsChecked;

                tempPatient.PatientOQ           = patientOQ;
                tempPatient.PatientFirstName    = firstName;
                tempPatient.PatientLastName     = lastName;
                tempPatient.PatientAgeGroup     = ageGroup;
                tempPatient.PatientEthnicity    = ethnicGroup;
                tempPatient.PatientGender       = PatientGender;
                tempPatient.NewClientIntakeHour = DateTime.Now;
                tempPatient.IsHead         = headOfHouse;
                tempPatient.RelationToHead = (headOfHouse) ? "Head" : relationToHead;
                db.Patients.Add(tempPatient);
                db.SaveChanges();
                Determine_Problems(patientOQ, togglePatientProblems);

                this.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show("Something went wrong, please double check your entry values.\n\n");
                MessageBox.Show("Error: " + error.ToString());
            }
        }
Пример #11
0
        private void EditDonor(object sender, MouseButtonEventArgs e)
        {
            try
            {
                DataGrid       dg = sender as DataGrid;
                DonorsDataGrid p  = (DonorsDataGrid)dg.SelectedItems[0];                // OR:  Patient p = (Patient)dg.SelectedItem;
                var            db = new FCS_DBModel();

                if (p.DonorType == "Individual")
                {
                    //Open in individual view
                    Models.DonorContact query = (from doncontacts in db.DonorContacts
                                                 where doncontacts.DonorID == p.DonorID
                                                 select doncontacts).First();
                    UpdateIndividualDonor id = new UpdateIndividualDonor(p, query, StaffRole);
                    id.dType.SelectedIndex = 1;
                    id.oName.IsEnabled     = false;
                    id.ShowDialog();
                }
                else if (p.DonorType == "Anonymous")
                {
                    Models.DonorContact query = (from doncontacts in db.DonorContacts
                                                 where doncontacts.DonorID == p.DonorID
                                                 select doncontacts).First();
                    UpdateIndividualDonor id = new UpdateIndividualDonor(p, query, StaffRole);

                    id.ShowDialog();
                    id.UpdateIndDonor.IsEnabled = false;
                    id.dType.SelectedIndex      = 2;
                    id.fName.IsEnabled          = false;
                    id.lName.IsEnabled          = false;
                    id.oName.IsEnabled          = false;
                    id.donA1.IsEnabled          = false;
                    id.donA2.IsEnabled          = false;
                    id.cPhone.IsEnabled         = false;
                    id.dCity.IsEnabled          = false;
                    id.cPhone.IsEnabled         = false;
                    id.dState.IsEnabled         = false;
                    id.dZip.IsEnabled           = false;
                    id.cEmail.IsEnabled         = false;
                }
                else
                {
                    UpdateDonor up = new UpdateDonor(p, StaffRole);

                    up.ShowDialog();
                }
            }
            catch
            {
            }

            //	Refresh the grid after editing
            Refresh_DonorGrid(sender, e);
        }
Пример #12
0
        //	-----------------------------------------------------------------------------

        /// <summary>
        /// This is to handle the refreshing AND filtering of the Client Page
        /// </summary>
        private void Refresh_ClientGrid(object sender, RoutedEventArgs e)
        {
            string filterText   = textbox_Search.Text;
            string selectedItem = combobox_Search.Text;

            var db      = new FCS_DBModel();
            var clients = 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
            };

            switch (selectedItem)
            {
            case Definition.Filter_AgeGroup:
                clients = clients.Where(x => x.AgeGroup.Contains(filterText));
                break;

            case Definition.Filter_ClientOQ:
                clients = clients.Where(x => x.PatientOQ.Contains(filterText));
                break;

            case Definition.Filter_Ethnicity:
                clients = clients.Where(x => x.Ethnicity.Contains(filterText));
                break;

            case Definition.Filter_FirstName:
                clients = clients.Where(x => x.FirstName.Contains(filterText));
                break;

            case Definition.Filter_LastName:
                clients = clients.Where(x => x.LastName.Contains(filterText));
                break;

            default:
                break;
            }

            //	Set the patient grid to have the (possibly limited) items
            PatientGrid.ItemsSource = clients.ToList();

            GC.Collect();
        }
Пример #13
0
        public UpdateGrant(GrantsDataGrid g)
        {
            FCS_DBModel db = new FCS_DBModel();
            Donation    d  = new Donation();

            foreach (var item in db.Purposes)
            {
                purpose.Add(item.PurposeName);
            }
            DataContext = purpose;

            GrantName               = g.GrantName;
            DonationAmount          = g.DonationAmount;
            DonationAmountRemaining = g.DonationAmountRemaining;
            PurposeName             = g.PurposeName;
            PurposeDescription      = g.PurposeDescription;
            PurposeID               = g.PurposeID;
            DonationID              = g.DonationID;
            DonorID         = g.DonorID;
            GrantProposalID = g.GrantProposalID;
            InitializeComponent();
            DonAmount.Focus();

            var restricted = (from item in db.Donations where item.DonationID == DonationID select item.Restricted).First();

            if (restricted == true)
            {
                var donationTable = (from don in db.Donations
                                     join dp in db.DonationPurposes
                                     on don.DonationID equals dp.DonationID
                                     join p in db.Purposes
                                     on dp.PurposeID equals p.PurposeID
                                     where don.DonationID == DonationID
                                     select new
                {
                    don.DonationID,
                    don.DonationExpirationDate,
                    don.Restricted,
                    dp.PurposeID
                }).First();
                DonationDate.IsEnabled          = false;
                DonationExpiration.SelectedDate = donationTable.DonationExpirationDate;
                restrictedCheckBox.IsChecked    = true;
                PurposeComboBox.SelectedItem    = (from p in db.Purposes
                                                   join dp in db.DonationPurposes
                                                   on p.PurposeID equals dp.PurposeID
                                                   join don in db.Donations
                                                   on dp.DonationID equals don.DonationID
                                                   where dp.PurposeID == donationTable.PurposeID
                                                   select p.PurposeName).First();
            }
        }
Пример #14
0
        private void AddGrant(object sender, RoutedEventArgs e)
        {
            try
            {
                FCS_DBModel db = new FCS_DBModel();
                Donation    d  = new Donation();
                if (IsEvent)
                {
                    d.DonorID                 = DonorID;
                    d.Restricted              = false;
                    d.InKind                  = false;
                    d.DonationAmount          = DonationAmount;
                    d.DonationDate            = Convert.ToDateTime(DonationDate.ToString());
                    d.EventID                 = EventID;
                    d.DonationAmountRemaining = DonationAmount;
                    db.Donations.Add(d);
                }
                else
                {
                    d.DonorID                 = DonorID;
                    d.Restricted              = false;
                    d.InKind                  = false;
                    d.DonationAmount          = DonationAmount;
                    d.DonationDate            = Convert.ToDateTime(DonationDate.ToString());
                    d.DonationAmountRemaining = DonationAmount;
                    db.Donations.Add(d);
                }
                if (restrictedCheckBox.IsChecked == true)
                {
                    Purpose         p           = new Purpose();
                    DonationPurpose dp          = new DonationPurpose();
                    string          purposeName = PurposeComboBox.SelectedItem.ToString();
                    int             PurposeID   = db.Purposes.Where(x => x.PurposeName == purposeName).Select(x => x.PurposeID).First();

                    d.Restricted             = true;
                    d.DonationExpirationDate = Convert.ToDateTime(DonationExpiration.ToString());
                    dp.DonationID            = d.DonationID;
                    dp.PurposeID             = PurposeID;
                    dp.DonationPurposeAmount = DonationAmount;
                    db.DonationPurposes.Add(dp);
                    db.Donations.Remove(d);
                    db.Donations.Add(d);
                }
                db.SaveChanges();

                this.Close();
            }
            catch
            {
                MessageBox.Show("Make sure to input all the correct data.");
            }
        }
Пример #15
0
        public void deletePurpose(int DonationID)
        {
            FCS_DBModel db      = new FCS_DBModel();
            var         donPurp = db.DonationPurposes.Where(x => x.DonationID == DonationID);

            if (donPurp != null)
            {
                foreach (var item in donPurp)
                {
                    db.DonationPurposes.Remove(item);
                }
                db.SaveChanges();
            }
        }
Пример #16
0
        private void AddNewSession(object sender, RoutedEventArgs e)
        {
            DataGrid    dg        = sender as DataGrid;
            FCS_DBModel db        = new FCS_DBModel();
            int         patientID = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientID).Distinct().First();

            AddSession ans = new AddSession(patientID);

            ans.AMPM_Start.SelectedIndex  = 0;
            ans.AMPM_End.SelectedIndex    = 0;
            ans.ExpensePaidDate.IsEnabled = false;
            ans.ShowDialog();
            Refresh_Sessions(sender, e);
        }
Пример #17
0
        private bool check_ValidFamilyOQNumber(string familyOQ)
        {
            FCS_DBModel db          = new FCS_DBModel();
            int         householdID = -1;

            householdID = db.Patients.Where(x => x.PatientOQ == familyOQ).Select(x => x.HouseholdID).Distinct().First();

            if (householdID == -1)
            {
                return(false);
            }

            return(true);
        }
Пример #18
0
        private void DeleteAccount(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Account?",
                                                                                            "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);

            db = new FCS_DBModel();
            var staff = (from s in db.Staff
                         where s.StaffID == StaffID
                         select s).First();

            db.Staff.Remove(staff);
            db.SaveChanges();

            this.Close();
        }
Пример #19
0
        public AddNewGrant(int dID, int gpID)
        {
            FCS_DBModel db = new FCS_DBModel();

            foreach (var item in db.Purposes)
            {
                purpose.Add(item.PurposeName);
            }
            DataContext     = purpose;
            DonorID         = dID;
            GrantProposalID = gpID;
            InitializeComponent();

            text_GrantAmount.Focus();
        }
Пример #20
0
        private void Delete_Grant(object sender, RoutedEventArgs e)
        {
            FCS_DBModel db = new FCS_DBModel();

            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Grant?",
                                                                                            "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                var donationPurposes = (from p in db.DonationPurposes
                                        where p.PurposeID == PurposeID
                                        select p);
                DeletePurposes delPurp = new DeletePurposes();

                delPurp.deletePurpose(DonationID);
            }
            //var purpose = (from p in db.Purposes
            //               where p.PurposeID == PurposeID
            //               select p).First();


            var donation = (from d in db.Donations
                            where d.DonationID == DonationID
                            select d).First();
            //try {
            //    var donationPurpose = (from dp in db.DonationPurposes
            //                           where dp.DonationID == donation.DonationID
            //                           select dp);
            //    foreach (var item in donationPurpose)
            //    {
            //        db.DonationPurposes.Remove(item);
            //        db.SaveChanges();
            //    }
            //}
            //catch
            //{

            //}
            var grantProposal = (from d in db.GrantProposals
                                 where d.GrantProposalID == GrantProposalID
                                 select d).First();

            grantProposal.GrantStatus = "Pending";

            db.Donations.Remove(donation);
            db.SaveChanges();
            MessageBox.Show("This grant has been deleted and its associated proposal has been set to Pending.");
            this.Close();
        }
Пример #21
0
        private void Refresh_AdminGrid(object sender, RoutedEventArgs e)
        {
            var db    = new FCS_DBModel();
            var join1 = (from p in db.Staff
                         select new AdminDataGrid
            {
                StaffID = p.StaffID,
                StaffUserName = p.StaffUserName,
                StaffFirstName = p.StaffFirstName,
                StaffLastName = p.StaffLastName,
                StaffTitle = p.StaffTitle,
                StaffDBRole = p.StaffDBRole
            });

            Admin_DataGrid.ItemsSource = join1.ToList();
        }
Пример #22
0
        private void button_DeleteHousehold_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int         householdID = int.Parse(text_HouseholdID.Text);
                FCS_DBModel db          = new FCS_DBModel();

                var household = (from h in db.PatientHouseholds
                                 where h.HouseholdID == householdID
                                 select h).First();

                db.PatientHouseholds.Remove(household);
                db.SaveChanges();
            }
            catch { }
        }
Пример #23
0
        private void Events_Grid(object sender, RoutedEventArgs e)
        {
            var db    = new FCS_DBModel();
            var join1 = (from p in db.FundRaisingEvents
                         select new EventsDataGrid
            {
                EventID = p.EventID,
                EventStartDateTime = p.EventStartDateTime,
                EventEndDateTime = p.EventEndDateTime,
                EventName = p.EventName,
                EventDescription = p.EventDescription
            });

            var grid = sender as DataGrid;

            grid.ItemsSource = join1.ToList();
        }
Пример #24
0
        public CreateMoneyDonation(int donorID, bool isEvent, int eventID)
        {
            FCS_DBModel db = new FCS_DBModel();

            foreach (var item in db.Purposes)
            {
                purpose.Add(item.PurposeName);
            }
            DataContext = purpose;

            EventID = eventID;
            IsEvent = isEvent;
            DonorID = donorID;
            InitializeComponent();

            text_DonationAmount.Focus();
        }
Пример #25
0
        private void button_AddPatient_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Patient     tempPatient = new Patient();
                Problem     tempProblem = new Problem();
                FCS_DBModel db          = new FCS_DBModel();

                if ((bool)check_NewHousehold.IsChecked)
                {
                    int    HouseholdPopulation = int.Parse(text_HouseholdPop.Text);
                    string Income = text_Income.Text;
                    string County = text_county.Text;

                    PatientHousehold household = new PatientHousehold();
                    household.HouseholdCounty        = County;
                    household.HouseholdIncomeBracket = Income;
                    household.HouseholdPopulation    = HouseholdPopulation;
                    db.PatientHouseholds.Add(household);
                    db.SaveChanges();

                    tempPatient.HouseholdID = household.HouseholdID;
                }
                else
                {
                    tempPatient.HouseholdID = int.Parse(text_HouseholdID.Text);
                }

                tempPatient.PatientOQ           = text_PatientOQ.Text;
                tempPatient.PatientAgeGroup     = text_AgeGroup.Text;
                tempPatient.PatientEthnicity    = text_Ethnicity.Text;
                tempPatient.PatientFirstName    = text_FirstName.Text;
                tempPatient.PatientGender       = text_Gender.Text;
                tempPatient.PatientLastName     = text_LastName.Text;
                tempPatient.RelationToHead      = text_RelationToHEad.Text;
                tempPatient.IsHead              = (bool)check_IsHead.IsChecked;
                tempPatient.NewClientIntakeHour = DateTime.Now;

                db.Patients.Add(tempPatient);
                db.SaveChanges();
            }
            catch (Exception error)
            {
            }
        }
Пример #26
0
        private void AddPurposeButton_Click(object sender, RoutedEventArgs e)
        {
            FCS_DBModel db      = new FCS_DBModel();
            Purpose     purpose = db.Purposes.Create();

            purpose.PurposeName        = PurposeName.Text;
            purpose.PurposeDescription = PurposeDescription.Text;
            db.Purposes.Add(purpose);
            try {
                db.SaveChanges();

                this.Close();
            }
            catch
            {
                MessageBox.Show("Please make sure all fields are correct");
            }
        }
Пример #27
0
        private void AddGrant(object sender, RoutedEventArgs e)
        {
            try
            {
                //MessageBox.Show(DonationAmount.ToString() + "\n" + DonationDate + "\n" +
                //    PurposeName + "\n" + PurposeDescription);
                FCS_DBModel db = new FCS_DBModel();

                Donation d = new Donation();
                d.DonorID                 = DonorID;
                d.Restricted              = false;
                d.InKind                  = false;
                d.DonationAmount          = DonationAmount;
                d.DonationDate            = Convert.ToDateTime(DonationDate.ToString());
                d.DonationAmountRemaining = DonationAmount;
                d.GrantProposalID         = GrantProposalID;
                db.Donations.Add(d);

                if (restrictedCheckBox.IsChecked == true)
                {
                    Purpose         p           = new Purpose();
                    DonationPurpose dp          = new DonationPurpose();
                    string          purposeName = PurposeComboBox.SelectedValue.ToString();
                    int             PurposeID   = db.Purposes.Where(x => x.PurposeName == purposeName).Select(x => x.PurposeID).First();

                    d.Restricted             = true;
                    d.DonationExpirationDate = Convert.ToDateTime(DonationExpiration.ToString());
                    d.GrantProposalID        = GrantProposalID;
                    dp.DonationID            = d.DonationID;
                    dp.PurposeID             = PurposeID;
                    dp.DonationPurposeAmount = DonationAmount;
                    db.DonationPurposes.Add(dp);
                    db.Donations.Remove(d);
                    db.Donations.Add(d);
                }
                db.SaveChanges();

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cannot add Grant" + "\n" + ex);
            }
        }
Пример #28
0
        private void Add_Contact(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DonorFirstName != null && DonorFirstName != "" && DonorLastName != null && DonorLastName != "" && ContactPhone != null && ContactPhone != "" &&
                    ContactEmail != null && ContactEmail != "")
                {
                    FCS_DBModel db = new FCS_DBModel();
                    //MessageBox.Show(DonorFirstName + "\n" + DonorLastName + "\n" + ContactPhone + "\n" + ContactEmail + "\n" + DonorAddress1 + "\n" + DonorAddress2
                    //    + "\n" + DonorCity + "\n" + DonorState + "\n" + DonorZip + "\n" + DonorType + "\n" + OrganizationName);
                    Donor        d  = new Donor();
                    DonorContact dc = new DonorContact();

                    d.DonorType        = DonorType;
                    d.OrganizationName = OrganizationName;
                    d.DonorAddress1    = DonorAddress1;
                    d.DonorAddress2    = DonorAddress2;
                    d.DonorState       = DonorState;
                    d.DonorCity        = DonorCity;
                    d.DonorZip         = DonorZip;
                    db.Donors.Add(d);
                    db.SaveChanges();

                    dc.ContactFirstName = DonorFirstName;
                    dc.ContactLastName  = DonorLastName;
                    dc.ContactPhone     = ContactPhone;
                    dc.ContactEmail     = ContactEmail;
                    dc.DonorID          = d.DonorID;
                    db.DonorContacts.Add(dc);
                    db.SaveChanges();

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Add the correct fields.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Make sure your phone number is 10 digits or less.");
            }
        }
Пример #29
0
 private void Delete_Client(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Client?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);
     if (result == System.Windows.Forms.DialogResult.Yes)
     {
         FCS_DBModel db      = new FCS_DBModel();
         int         patID   = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientID).Distinct().First();
         var         patient = (from p in db.Patients
                                where p.PatientID == patID
                                select p).First();
         var patProblems = (from p in db.PatientProblems where p.PatientID == patID select p);
         db.Patients.Remove(patient);
         foreach (var item in patProblems)
         {
             db.PatientProblems.Remove(item);
         }
         db.SaveChanges();
         this.Close();
     }
 }
Пример #30
0
 private void button_DeletePatient_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string      patientOQ = text_PatientOQ.Text;
         FCS_DBModel db        = new FCS_DBModel();
         int         patID     = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientID).Distinct().First();
         var         patient   = (from p in db.Patients
                                  where p.PatientID == patID
                                  select p).First();
         var patProblems = (from p in db.PatientProblems where p.PatientID == patID select p);
         db.Patients.Remove(patient);
         foreach (var item in patProblems)
         {
             db.PatientProblems.Remove(item);
         }
         db.SaveChanges();
     }
     catch { }
 }