/// <summary> /// Author: Ameet Toor /// Gets the checkbox that is checked, and assigns the DonationType to myDonationType. /// </summary> private void checkWhichButtonChecked() { DonationTypes result = DonationTypes.Other; if ((bool)ToysRadioButton.IsChecked) { result = DonationTypes.Toys; } else if ((bool)ClothesRadioButton.IsChecked) { result = DonationTypes.Clothes; } else if ((bool)TechRadioButton.IsChecked) { result = DonationTypes.Tech; } else if ((bool)FirstAidGoodsButton.IsChecked) { result = DonationTypes.FirstAid; } else if ((bool)FoodRadioButton.IsChecked) { result = DonationTypes.Food; } else if ((bool)HygieneProductsRadioButton.IsChecked) { result = DonationTypes.Hygene; } else if ((bool)OtherRadioButton.IsChecked) { result = DonationTypes.Other; } myDonationType = result; }
/// <summary> /// Author: Ameet Toor /// Changes myDonationType depending on which subject was chosen. And changes the secondary combobox content depending on the subject chosen. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SubjectComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var subject = SubjectComboBox.SelectedItem.ToString(); if (subject.Equals("Writing")) { myDonationType = DonationTypes.Writing; SetSpecificSubjectComboBox("Writing"); } else if (subject.Equals("Reading")) { SetSpecificSubjectComboBox("Reading"); myDonationType = DonationTypes.Reading; } else { SetSpecificSubjectComboBox("Math"); myDonationType = DonationTypes.Math; } }
/// <summary> /// Creates a Service ID, updates the serial number file, adds the new Service object to it's respective dictionary, and updates the Service Dictionary's file. /// </summary> /// <param name="sType">The Service Type Enum.</param> /// <param name="dType">The Donation Type Enum.</param> /// <param name="theUser">The User object.</param> /// <param name="theService">The Service object.</param> public void createService(ServiceTypes sType, DonationTypes dType, User theUser, Service theService) { String serial; switch (sType) { case ServiceTypes.Donate: switch (dType) { case DonationTypes.Toys: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myToys.Add(theService.getServiceID(), theService); serial = serializeDictionary(myToys); writeFile(myDictionaryFileStrings[0], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.Clothes: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myClothes.Add(theService.getServiceID(), theService); serial = serializeDictionary(myClothes); writeFile(myDictionaryFileStrings[1], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.Tech: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myTech.Add(theService.getServiceID(), theService); serial = serializeDictionary(myTech); writeFile(myDictionaryFileStrings[2], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.FirstAid: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myFirstAid.Add(theService.getServiceID(), theService); serial = serializeDictionary(myFirstAid); writeFile(myDictionaryFileStrings[3], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.Food: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myFood.Add(theService.getServiceID(), theService); serial = serializeDictionary(myFood); writeFile(myDictionaryFileStrings[6], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.Hygene: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myHygene.Add(theService.getServiceID(), theService); serial = serializeDictionary(myHygene); writeFile(myDictionaryFileStrings[4], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.Tools: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myTools.Add(theService.getServiceID(), theService); serial = serializeDictionary(myTools); writeFile(myDictionaryFileStrings[5], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.Other: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); theService.setServiceType(sType); theService.setDonationRequest(dType); myOthers.Add(theService.getServiceID(), theService); serial = serializeDictionary(myOthers); writeFile(myDictionaryFileStrings[7], serial); myServiceIDs.Add(theService.getServiceID()); break; } break; case ServiceTypes.Drive: switch (dType) { case DonationTypes.Goods: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myGoodsDrives.Add(theService.getServiceID(), theService); serial = serializeDictionary(myGoodsDrives); writeFile(myDictionaryFileStrings[8], serial); myServiceIDs.Add(theService.getServiceID()); break; } break; case ServiceTypes.Educate: switch (dType) { case DonationTypes.Math: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myMathEducates.Add(theService.getServiceID(), theService); serial = serializeDictionary(myMathEducates); writeFile(myDictionaryFileStrings[9], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.Writing: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); myWritingEducates.Add(theService.getServiceID(), theService); serial = serializeDictionary(myWritingEducates); writeFile(myDictionaryFileStrings[11], serial); myServiceIDs.Add(theService.getServiceID()); break; case DonationTypes.Reading: theService.setServiceID(createServiceID(dType)); theService.setServiceType(sType); theService.setDonationRequest(dType); //if (theService.getServiceID() == null) myReadingEducates.Add(theService.getServiceID(), theService); serial = serializeDictionary(myReadingEducates); writeFile(myDictionaryFileStrings[10], serial); myServiceIDs.Add(theService.getServiceID()); break; } break; case ServiceTypes.Request: theService.setServiceID(createServiceID(DonationTypes.Donation)); theService.setServiceType(sType); theService.setDonationRequest(dType); //if (theService.getServiceID() == null) myDonationRequests.Add(theService.getServiceID(), theService); serial = serializeDictionary(myDonationRequests); writeFile(myDictionaryFileStrings[12], serial); myServiceIDs.Add(theService.getServiceID()); break; } }
/// <summary> /// Provides all of the Service object IDs in their respective dictionaries. /// </summary> /// <param name="sType">The Service type requested.</param> /// <param name="dType">The Donation type requested.</param> /// <returns></returns> public String printServices(ServiceTypes sType, DonationTypes dType) { StringBuilder print = new StringBuilder(); StringBuilder prefix = new StringBuilder(); switch (sType) { case ServiceTypes.Donate: switch (dType) { case DonationTypes.Toys: prefix.Append("11" + mySerialNumbers[myStrings[0]]); print.Append(getServices(prefix.ToString(), myToys)); break; case DonationTypes.Clothes: prefix.Append("12" + mySerialNumbers[myStrings[1]]); print.Append(getServices(prefix.ToString(), myClothes)); break; case DonationTypes.Tech: prefix.Append("13" + mySerialNumbers[myStrings[2]]); print.Append(getServices(prefix.ToString(), myTech)); break; case DonationTypes.FirstAid: prefix.Append("14" + mySerialNumbers[myStrings[3]]); print.Append(getServices(prefix.ToString(), myFirstAid)); break; case DonationTypes.Food: prefix.Append("16" + mySerialNumbers[myStrings[6]]); print.Append(getServices(prefix.ToString(), myFood)); break; case DonationTypes.Hygene: prefix.Append("15" + mySerialNumbers[myStrings[4]]); print.Append(getServices(prefix.ToString(), myHygene)); break; case DonationTypes.Other: prefix.Append("18" + mySerialNumbers[myStrings[7]]); print.Append(getServices(prefix.ToString(), myOthers)); break; } break; case ServiceTypes.Drive: switch (dType) { case DonationTypes.Goods: prefix.Append("21" + mySerialNumbers[myStrings[8]]); print.Append(getServices(prefix.ToString(), myGoodsDrives)); break; } break; case ServiceTypes.Educate: switch (dType) { case DonationTypes.Math: prefix.Append("31" + mySerialNumbers[myStrings[9]]); print.Append(getServices(prefix.ToString(), myMathEducates)); break; case DonationTypes.Writing: prefix.Append("33" + mySerialNumbers[myStrings[11]]); print.Append(getServices(prefix.ToString(), myWritingEducates)); break; case DonationTypes.Reading: prefix.Append("32" + mySerialNumbers[myStrings[10]]); print.Append(getServices(prefix.ToString(), myReadingEducates)); break; } break; case ServiceTypes.Request: prefix.Append("41" + mySerialNumbers[myStrings[12]]); print.Append(getServices(prefix.ToString(), myDonationRequests)); break; } return(print.ToString()); }
/// <summary> /// Helper method for the createService method that creates the Service ID for the Service object. /// </summary> /// <param name="theType">The Donation EnumType of the Service object.</param> /// <returns></returns> private String createServiceID(DonationTypes theType) { StringBuilder builder = new StringBuilder(); switch (theType) { case DonationTypes.Toys: builder.Append("11"); builder.Append(mySerialNumbers[myStrings[0]]); updateSerial(myStrings[0]); break; case DonationTypes.Clothes: builder.Append("12"); builder.Append(mySerialNumbers[myStrings[1]]); updateSerial(myStrings[1]); break; case DonationTypes.Tech: builder.Append("13"); builder.Append(mySerialNumbers[myStrings[2]]); updateSerial(myStrings[2]); break; case DonationTypes.FirstAid: builder.Append("14"); builder.Append(mySerialNumbers[myStrings[3]]); updateSerial(myStrings[3]); break; case DonationTypes.Hygene: builder.Append("15"); builder.Append(mySerialNumbers[myStrings[4]]); updateSerial(myStrings[4]); break; case DonationTypes.Food: builder.Append("16"); builder.Append(mySerialNumbers[myStrings[6]]); updateSerial(myStrings[6]); break; case DonationTypes.Tools: builder.Append("17"); builder.Append(mySerialNumbers[myStrings[5]]); updateSerial(myStrings[5]); break; case DonationTypes.Other: builder.Append("18"); builder.Append(mySerialNumbers[myStrings[7]]); updateSerial(myStrings[7]); break; case DonationTypes.Goods: builder.Append("21"); builder.Append(mySerialNumbers[myStrings[8]]); updateSerial(myStrings[8]); break; case DonationTypes.Math: builder.Append("31"); builder.Append(mySerialNumbers[myStrings[9]]); updateSerial(myStrings[9]); break; case DonationTypes.Reading: builder.Append("32"); builder.Append(mySerialNumbers[myStrings[10]]); updateSerial(myStrings[10]); break; case DonationTypes.Writing: builder.Append("33"); builder.Append(mySerialNumbers[myStrings[11]]); updateSerial(myStrings[11]); break; case DonationTypes.Donation: builder.Append("41"); builder.Append(mySerialNumbers[myStrings[12]]); updateSerial(myStrings[12]); break; } return(builder.ToString()); }
/// <summary> /// Sets the type of Donation of the Service Object. /// </summary> /// <param name="theType">The type of donation.</param> public void setDonationRequest(DonationTypes theType) //Changed this to DonationTypes { myDonationRequest = theType; }
/// <summary> /// Author: Ameet Toor /// Initializes fields. /// </summary> private void InitializeFields() { myDonationType = DonationTypes.Math; myDescription = string.Empty; }