public MembershipSignUp() { InitializeComponent(); //1. Clear Contents and set invisibility of credit card picture Clear(); imgCard.Visibility = Visibility.Hidden; lblCreditType.Content = ""; //2. Initialize list memberlist = new List <Member>(); Files calFiles = new Files(); //3. Set file location and timestamp for method string strFilePath = @"..\..\..\Data\Members"; string isTimestamp = DateTime.Now.Ticks.ToString(); //4. Grab file location with extension string LoadedFilePath = calFiles.GetFilePath(strFilePath, "json", false); //5. Read in data System.IO.StreamReader reader = new System.IO.StreamReader(LoadedFilePath); string jsonData = reader.ReadToEnd(); reader.Close(); //6. Deseralize it to a list memberlist = JsonConvert.DeserializeObject <List <Member> >(jsonData); //7. default blank member info for the default constructor InfoFromPrevWindow = new CustomerPaymentInfo(); }
public MembershipSignUp(CustomerPaymentInfo info) { //8. don't forget this line when overriding the constructor for a window InitializeComponent(); //9. assigning the property from the member info class that was passed into this overridden constructor InfoFromPrevWindow = info; }
public void btnSaveQuota_Click(object sender, RoutedEventArgs e) { //7. Initalize variables that must be prefaced before further validation DatePicker dtStartDate = dtStart; //8. Validate that a combobox item was selected if (cboMembershipType.SelectedIndex == -1) { MessageBox.Show("Please select a Membership Plan."); return; } //9. Grab the boolean to see if a date has been selected bool isDateNull = isStartDateSelect(dtStartDate); //10. Check if a date has been select if (isDateNull == false) { MessageBox.Show("Please select a valid start date."); return; } //11. Once date is selected, declare variables that will calculate the end date DateTime dtToday = DateTime.Today; DateTime dtConvertStartDate = ConvertPickerToDate(dtStartDate); DateTime dtConvertedEndDate = dtToday; //12. Determine if a user picked an date in the past if (dtConvertStartDate < dtToday) { MessageBox.Show("Please select a valid start date."); return; } //13. Determine the end date based on the drop down selected if ((cboMembershipType.SelectedIndex == 1 || cboMembershipType.SelectedIndex == 3 || cboMembershipType.SelectedIndex == 5)) { dtConvertedEndDate = dtConvertStartDate.AddYears(1); } else { dtConvertedEndDate = dtConvertStartDate.AddMonths(1); } //14. Set selected item to string for query string strMembershipSelection = cboMembershipType.SelectedItem.ToString(); //15. Query corresponding price from drop down menu var priceQuery = from p in priceList where (p.Membership.Trim() == strMembershipSelection.Trim()) select p.Price; //16. Convert list to string string strMembershipPrice = String.Join(",", priceQuery); //17. Convert price to double for subtotal calculation double dblMembershipPrice = Convert.ToDouble(strMembershipPrice); double dblSubCost = GetAdditionalFeatureCost(lstFeatures, cboMembershipType); double dblTotalCost = dblSubCost + dblMembershipPrice; //18. String formula for output text box string strOutput = Environment.NewLine + "Membership Price:".PadRight(30) + dblMembershipPrice.ToString("C2") + Environment.NewLine + Environment.NewLine + "Addtional Feature Costs:".PadRight(30) + dblSubCost.ToString("C2") + Environment.NewLine + "________________________________________" + Environment.NewLine + "Total Cost:".PadRight(30) + dblTotalCost.ToString("C2"); //19. Split datetime for enddate string strConvertedEndDate = dtConvertedEndDate.ToString(); int strSpace = strConvertedEndDate.IndexOf(" "); string strSubConvertedEndDate = strConvertedEndDate.Substring(0, strSpace); //20. Set additional features to string StringBuilder strFeatures = new StringBuilder(); foreach (ListBoxItem selectedItem in lstFeatures.SelectedItems) { strFeatures.AppendLine(selectedItem.Content.ToString()); } //21. Set output to corresponding text boxes txtFeatures.Text = strFeatures.ToString(); txtPrice.Text = dblMembershipPrice.ToString("C2"); txtMemberQuotaOutput.Text = strOutput; txtEndDate.Text = strSubConvertedEndDate; txtMemberQuotaOutput.Text = strOutput; txtTotalPrice.Text = dblTotalCost.ToString("C2"); //22. create some info to send to the next window CustomerPaymentInfo info = new CustomerPaymentInfo(cboMembershipType.Text.Trim(), dtStart.Text.Trim(), txtEndDate.Text.Trim(), txtFeatures.Text.Trim(), txtPrice.Text.Trim(), txtTotalPrice.Text.Trim()); MessageBoxResult messageBoxResult = MessageBox.Show("Create new member?" + Environment.NewLine + Environment.NewLine + info , "Membership Quote" , MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { //instantiate the next window and use the overridden constructor that allows sending information in as an argument MembershipSignUp next = new MembershipSignUp(info); next.Show(); this.Close(); } }