/// <summary> /// This method logs you into the system /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { Models.FCS_DBModel db = new Models.FCS_DBModel(); string pw = Password.Password.ToString(); string us = Username.Text; string hashedPassword = FCS_DataTesting.PasswordHashing.GetHashString(pw); try { var query = (from p in db.Staff where p.StaffUserName == us && p.StaffPassword == hashedPassword select p).Distinct().First(); MainWindow mw = new MainWindow(query.StaffDBRole, query.StaffFirstName + " " + query.StaffLastName); if(query.StaffDBRole == Definition.NoAccess) { MessageBox.Show("You are not allowed to access this program. Please contact your manager if you feel this is in error."); mw.Close(); return; } mw.Show(); this.Close(); } catch { MessageBox.Show("The credentials used are either invalid,or\nsomeone else is currently logged in."); } }
/// <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 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(); }
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(); }
/// <summary> /// This method logs you into the system /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { Models.FCS_DBModel db = new Models.FCS_DBModel(); string pw = Password.Password.ToString(); string us = Username.Text; string hashedPassword = FCS_DataTesting.PasswordHashing.GetHashString(pw); try { var query = (from p in db.Staff where p.StaffUserName == us && p.StaffPassword == hashedPassword select p).Distinct().First(); MainWindow mw = new MainWindow(query.StaffDBRole, query.StaffFirstName + " " + query.StaffLastName); if (query.StaffDBRole == Definition.NoAccess) { MessageBox.Show("You are not allowed to access this program. Please contact your manager if you feel this is in error."); mw.Close(); return; } mw.Show(); this.Close(); } catch { MessageBox.Show("The credentials used are either invalid,or\nsomeone else is currently logged in."); } }
private void DeleteDonation(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Delete this Donation?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); 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(); //db.Purposes.Remove(purpose); db.Donations.Remove(donation); db.SaveChanges(); MessageBox.Show("Donation Deleted."); this.Close(); } }
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); }
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."); } }
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."); } }
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()); } }
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); }
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(); } }
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(); } }
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(); }
// ----------------------------------------------------------------------------- /// <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(); }
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(); }
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(); }
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(); }
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); } }
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"); } }
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."); } }
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 { } }
private void Refresh_InKindGrid(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_Item on d.DonationID equals ki.DonationID where (p.DonorType == "Anonymous" || p.DonorType == "Individual") && d.EventID == null select new InKindItem { 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 == null select new InKindItem { DonorID = p.DonorID, ItemID = ki.ItemID, DonationID = d.DonationID, ItemName = ki.ItemName, DonorFirstName = "", DonorLastName = "", OrganizationName = p.OrganizationName, DateRecieved = d.DonationDate, Description = ki.ItemDescription }); InKind_DataGrid.ItemsSource = join1.ToList(); }
private void Update_Account(object sender, RoutedEventArgs e) { db = new FCS_DBModel(); try { string Role = UserRole.SelectedValue.ToString(); int usernameVerify = (from uv in db.Staff where uv.StaffUserName == UserName select uv).Count(); if (usernameVerify != 0 && UserName != helperUserName) { MessageBox.Show("The username selected is already taken"); } else { try { var staff = (from p in db.Staff where p.StaffID == StaffID select p).First(); staff.StaffFirstName = FirstName; staff.StaffLastName = LastName; staff.StaffTitle = StaffTitle; staff.StaffUserName = UserName; staff.StaffDBRole = Role; db.SaveChanges(); this.Close(); } catch { MessageBox.Show("Please check the data entered."); } } } catch { MessageBox.Show("Please check the data entered."); } }
private void Add_Household(object sender, RoutedEventArgs e) { Determine_County(this.HouseholdCounty.SelectedIndex); Determine_Income(this.HouseholdIncomeBracket.SelectedIndex); if (Income != null && HouseholdPopulation > 0 && County != null && County != "") { date = DateTime.Now; //MessageBox.Show(firstName + "\n" + lastName + "\n" + patientOQ + "\n" + gender + "\n" + headOfHouse + "\n" + ageGroup + "\n" + ethnicGroup // + "\n" + "\n" + date + "\n" + HouseholdPopulation + "\n" + County + "\n" + Income); FCS_DBModel db = new FCS_DBModel(); PatientHousehold p = new PatientHousehold(); p.HouseholdCounty = County; p.HouseholdPopulation = HouseholdPopulation; p.HouseholdIncomeBracket = Income; Patient pat = new Patient(); pat.PatientOQ = patientOQ; pat.HouseholdID = p.HouseholdID; pat.PatientFirstName = firstName; pat.PatientLastName = lastName; pat.PatientGender = gender; pat.PatientAgeGroup = ageGroup; pat.PatientEthnicity = ethnicGroup; pat.NewClientIntakeHour = date; pat.IsHead = headOfHouse; pat.RelationToHead = relationToHead; db.PatientHouseholds.Add(p); db.Patients.Add(pat); db.SaveChanges(); Determine_Problems(patientOQ, togglePatientProblems); MessageBox.Show("Successfully added Client and Household."); this.Close(); } //add both patient and household else { MessageBox.Show("Make sure to select an income, a household population, and input a county."); } }
private void Update_Patient(object sender, RoutedEventArgs e) { FCS_DBModel db = new FCS_DBModel(); try { int patID = db.Patients.Where(x => x.PatientOQ == pOQ).Select(x => x.PatientID).Distinct().First(); Determine_AgeGroup(this.AgeGroup.SelectedIndex); Determine_EthnicGroup(this.Ethnicity.SelectedIndex); Determine_Gender(this.Gender.SelectedIndex); var patient = (from p in db.Patients where p.PatientID == patID select p).First(); patient.PatientOQ = patientOQ; patient.PatientFirstName = firstName; patient.PatientLastName = lastName; patient.RelationToHead = relationToHead; patient.PatientGender = PatientGender; patient.PatientAgeGroup = ageGroup; patient.PatientEthnicity = ethnicGroup; patient.IsHead = TheHead.IsChecked.Value; UpdateProblems(); db.SaveChanges(); MessageBox.Show("Successfully Updated Client"); this.Close(); } catch { MessageBox.Show("Please make sure all fields are correct"); } //int householdID = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.HouseholdID).Distinct().First(); //FCS_Funding.Models.Patient update = new FCS_Funding.Models.Patient(patientOQ, householdID, firstName, lastName, PatientGender, // ageGroup, ethnicGroup, date, TheHead.IsChecked.Value, relationToHead); //db.Patients.Attach(update); //var entry = db.Entry(update); }
private void button_GetPatient_Click(object sender, RoutedEventArgs e) { string patientOQ = text_PatientOQ.Text; try { FCS_DBModel db = new FCS_DBModel(); var patient = (from p in db.Patients where p.PatientOQ == patientOQ select p).First(); var householdID = (from p in db.Patients where p.PatientOQ == patientOQ select p.HouseholdID).First(); var household = (from h in db.PatientHouseholds where h.HouseholdID == householdID select h).First(); text_AgeGroup.Text = patient.PatientAgeGroup; text_Ethnicity.Text = patient.PatientEthnicity; text_FirstName.Text = patient.PatientFirstName; text_Gender.Text = patient.PatientGender; text_LastName.Text = patient.PatientLastName; text_RelationToHEad.Text = patient.RelationToHead; check_IsHead.IsChecked = patient.IsHead; text_HouseholdID.Text = household.HouseholdID.ToString(); text_HouseholdPop.Text = household.HouseholdPopulation.ToString(); text_Income.Text = household.HouseholdIncomeBracket.ToString(); text_county.Text = household.HouseholdCounty.ToString(); } catch { } }
private void DetermineProblems() { var toggle = PatientProblemsCheckBoxes.Children; List<string> currentProblems = new List<string>(); 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)) { switch (item) { case 1: currentProblems.Add("Depression"); break; case 2: currentProblems.Add("Bereavement/Loss"); break; case 3: currentProblems.Add("Communication"); break; case 4: currentProblems.Add("Domestic Violence"); break; case 5: currentProblems.Add("Hopelessness"); break; case 6: currentProblems.Add("Work Problems"); break; case 7: currentProblems.Add("Parent Problems"); break; case 8: currentProblems.Add("Substance Abuse"); break; case 9: currentProblems.Add("Problems w/ School"); break; case 10: currentProblems.Add("Marriage/Relationship/Family"); break; case 11: currentProblems.Add("Thoughts of Hurting Self"); break; case 12: currentProblems.Add("Angry Feelings"); break; case 13: currentProblems.Add("Sexual Abuse"); break; case 14: currentProblems.Add("Emotional Abuse"); break; case 15: currentProblems.Add("Physical Abuse"); break; case 16: currentProblems.Add("Problems with the Law"); break; case 17: currentProblems.Add("Unhappy with Life"); break; case 18: currentProblems.Add("Anxiety"); break; case 19: currentProblems.Add("Other"); break; } } foreach (var item in toggle) { foreach (var curProb in currentProblems) { if ((((ContentControl)item).Content).ToString() == curProb) { ((ToggleButton)item).IsChecked = true; } } } GC.Collect(); }
public void Determine_Problems(string OQ, UIElementCollection toggle) { PatientProblem patProb = new PatientProblem(); FCS_DBModel db = new FCS_DBModel(); string checkBoxContent = ""; int probID = 0; var problemTable = db.Problems; foreach (var item in toggle) { if (((ToggleButton)item).IsChecked == true) { int patID = db.Patients.Where(x => x.PatientOQ == OQ).Select(x => x.PatientID).Distinct().First(); checkBoxContent = ((((ContentControl)item).Content).ToString()); switch (checkBoxContent) { case "Depression": probID = 1; break; case "Bereavement/Loss": probID = 2; break; case "Communication": probID = 3; break; case "Domestic Violence": probID = 4; break; case "Hopelessness": probID = 5; break; case "Work Problems": probID = 6; break; case "Parent Problems": probID = 7; break; case "Substance Abuse": probID = 8; break; case "Problems w/ School": probID = 9; break; case "Marriage/Relationship/Family": probID = 10; break; case "Thoughts of Hurting Self": probID = 11; break; case "Angry Feelings": probID = 12; break; case "Sexual Abuse": probID = 13; break; case "Emotional Abuse": probID = 14; break; case "Physical Abuse": probID = 15; break; case "Problems with the Law": probID = 16; break; case "Unhappy with Life": probID = 17; break; case "Anxiety": probID = 18; break; case "Other": probID = 19; break; } patProb.PatientID = patID; patProb.ProblemID = probID; db.PatientProblems.Add(patProb); db.SaveChanges(); } } }
private void Update_Grant(object sender, RoutedEventArgs e) { FCS_Funding.Models.FCS_DBModel db = new FCS_Funding.Models.FCS_DBModel(); //var purpose = (from p in db.Purposes // where p.PurposeID == PurposeID // select p).First(); //purpose.PurposeName = PurposeName; //purpose.PurposeDescription = PurposeDescription; var donation = (from d in db.Donations where d.DonationID == DonationID select d).First(); donation.DonationDate = Convert.ToDateTime(DonationDate.ToString()); if (DonationAmount - donation.DonationAmount < 0) { MessageBox.Show("This change would result in a\nnegative balance for this donation"); } else { if (restrictedCheckBox.IsChecked == true) { if (PurposeComboBox.Text != "" && PurposeComboBox.Text != null) { DeletePurposes delPurp = new DeletePurposes(); delPurp.deletePurpose(DonationID); 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(); donation.Restricted = true; if (DonationExpiration != null && DonationExpiration.ToString() != "") { donation.DonationExpirationDate = Convert.ToDateTime(DonationExpiration.ToString()); } else { donation.DonationExpirationDate = null; } dp.DonationID = donation.DonationID; dp.PurposeID = PurposeID; dp.DonationPurposeAmount = DonationAmount; db.DonationPurposes.Add(dp); decimal donationDiff = donation.DonationAmount - DonationAmount; donation.GrantProposalID = GrantProposalID; donation.DonationAmount = DonationAmount; donation.DonationAmountRemaining = donation.DonationAmountRemaining - donationDiff; db.Entry(donation); db.SaveChanges(); db.Entry(dp); db.SaveChanges(); } else { MessageBox.Show("Please enter a purpose if the donation is restrcted"); } } else { DeletePurposes delPurp = new DeletePurposes(); delPurp.deletePurpose(DonationID); donation.Restricted = false; donation.DonationExpirationDate = null; donation.GrantProposalID = GrantProposalID; decimal donationDiff = donation.DonationAmount - DonationAmount; donation.DonationAmount = DonationAmount; donation.DonationAmountRemaining = donation.DonationAmountRemaining - donationDiff; db.Entry(donation); db.SaveChanges(); } this.Close(); } }
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(); }
private void UpdateProblems() { FCS_DBModel db = new FCS_DBModel(); int patID = db.Patients.Where(x => x.PatientOQ == pOQ).Select(x => x.PatientID).Distinct().First(); var toggle = PatientProblemsCheckBoxes.Children; var patProblems = (from p in db.PatientProblems where p.PatientID == patID select p); //CreateNewPatient cnp = new CreateNewPatient(); PatientProblem patProb = new PatientProblem(); string checkBoxContent = ""; int probID = 0; var problemTable = db.Problems; foreach (var item in toggle) { checkBoxContent = ((((ContentControl)item).Content).ToString()); //var distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID select p); if (((ToggleButton)item).IsChecked == true) { switch (checkBoxContent) { case "Depression": probID = 1; break; case "Bereavement/Loss": probID = 2; break; case "Communication": probID = 3; break; case "Domestic Violence": probID = 4; break; case "Hopelessness": probID = 5; break; case "Work Problems": probID = 6; break; case "Parent Problems": probID = 7; break; case "Substance Abuse": probID = 8; break; case "Problems w/ School": probID = 9; break; case "Marriage/Relationship/Family": probID = 10; break; case "Thoughts of Hurting Self": probID = 11; break; case "Angry Feelings": probID = 12; break; case "Sexual Abuse": probID = 13; break; case "Emotional Abuse": probID = 14; break; case "Physical Abuse": probID = 15; break; case "Problems with the Law": probID = 16; break; case "Unhappy with Life": probID = 17; break; case "Anxiety": probID = 18; break; case "Other": probID = 19; break; } patProb.PatientID = patID; patProb.ProblemID = probID; db.PatientProblems.Add(patProb); db.SaveChanges(); patProb = new PatientProblem(); } else { var distinctPatProblems = new List<PatientProblem>().AsQueryable(); switch (checkBoxContent) { case "Depression": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 1 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Bereavement/Loss": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 2 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Communication": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 3 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Domestic Violence": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 4 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Hopelessness": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 5 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Work Problems": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 6 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Parent Problems": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 7 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Substance Abuse": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 8 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Problems w/ School": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 9 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Marriage/Relationship/Family": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 10 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Thoughts of Hurting Self": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 11 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Angry Feelings": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 12 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Sexual Abuse": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 13 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Emotional Abuse": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 14 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Physical Abuse": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 15 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Problems with the Law": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 16 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Unhappy with Life": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 17 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Anxiety": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 18 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; case "Other": try { distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 19 select p); foreach (var thing in distinctPatProblems) { db.PatientProblems.Remove(thing); } db.SaveChanges(); } catch { } distinctPatProblems = new List<PatientProblem>().AsQueryable(); break; } } } GC.Collect(); }