Exemple #1
0
        private MembershipType ConvertToMembershipType(string strLine)
        {
            //Declare a helper function to convert the membership type data so that it can be put in an array format
            string[] rawData;
            //The Array is broken up by | so this is how the array will be handled
            rawData = strLine.Split('|');

            MembershipType membershiptypeNew = new MembershipType(rawData[0], rawData[1], rawData[2], rawData[3]);

            return(membershiptypeNew);
        }
Exemple #2
0
        private void AppendToFile(MembershipType membershiptypeNew)
        {
            //Declare the variables for the strLine as well as the file path for the Membership data
            string strFilePath = @"..\..\..\Data\MembershipType.txt";
            string strLine;

            try
            {
                //Utilize stream writer and define the array so that the strLine can be read and writen
                StreamWriter writer = new StreamWriter(strFilePath, true);
                strLine = String.Format("{0}|{1}|{2}|{3}", membershiptypeNew.MembershipName, membershiptypeNew.MembershipPrice, membershiptypeNew.MembershipAvailibility, membershiptypeNew.MembershipLength);
                writer.WriteLine(strLine);
                //Close out the writer
                writer.Close();
            }
            catch (Exception ex)
            {
                //If thee is an error display the error message
                MessageBox.Show("Error in append file: " + ex.Message);
                return;
            }
        }
Exemple #3
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            //Define new membership type data fields so that a new membership type field can be provided
            MembershipType membershiptypeNew = new MembershipType(txtMembershipNameCreateData.Text.Trim(), txtMembershipCostCreateData.Text.Trim()
                                                                  , txtMembershipAvailibilityCreateData.Text.Trim(), txtMembershipLengthCreateData.Text.Trim());

            //Provided a confirmation message when a new member is added so that action can be confirmed
            MessageBoxResult messageBoxResult = MessageBox.Show("Do you want to save the following contact?"
                                                                + Environment.NewLine + Environment.NewLine + membershiptypeNew.ToString()
                                                                , "Create New Contact"
                                                                , MessageBoxButton.YesNo);

            //Act upon selected value of the message box by adding new memeber if yes is selected and stoping if no
            if (messageBoxResult == MessageBoxResult.Yes)
            {
                membershiptypeList.Add(membershiptypeNew);
                dtgContact.Items.Refresh();

                AppendToFile(membershiptypeNew);

                ClearScreen();
                MessageBox.Show("New Contact Saved!");
            }
        }