none
Confusing code RRS feed

  • Question

  • call.CallCategory = (CallCategory)Enum.Parse(typeof(CallCategory),callDetails[4]);

    cbxCategories.ItemsSource = 
                    Enum.GetValues(typeof(CallCategory)).Cast<CallCategory>();

    calls = new ObservableCollection<Call>();
                string[] listOfCalls = File.ReadAllLines("calls.txt");
                string[] callDetails = new string[5];

                for (int i = 0; i < listOfCalls.Length; i++)
                {
                    Call call = new Call();
                    callDetails = listOfCalls[i].Split(',');
                    call.Date = Convert.ToDateTime(callDetails[0]);
                    call.CallerName = callDetails[1];
                    call.CallerPhone = callDetails[2];
                    call.CallDetails = callDetails[3];
                    call.CallCategory = (CallCategory)Enum.Parse(typeof(CallCategory),callDetails[4]);
                    calls.Add(call);

                

    string[] allCalls = new string[calls.Count];

                for (int i = 0; i < calls.Count; i++)
    {
       allCalls[i] = calls[i].CallDetailsToFile();
    }

                //save to file
                File.WriteAllLines(Directory.GetCurrentDirectory() + "\\calls.txt", 
                    allCalls);

    Album removedAlbum = (Album)lbxDisplay.SelectedItem;
                lbxDisplay.Items.Remove(lbxDisplay.SelectedItem);
                decimal newTotal = Convert.ToDecimal(tblkTotal.Text) - removedAlbum.Price;
                tblkTotal.Text = newTotal.ToString();

    Text="{Binding ElementName=lbxCallSummary, Path=Items.Count}"

    public Album(string artist, string title, decimal price)
            {
                this.Artist = artist;
                this.Title = title;
                this.Price = price;
            }

    public override string ToString()
            {
                return Date.ToShortDateString() + " " + CallerName + " " + CallCategory;
            }

            public string GetCallDetail()
            {
                return Date + "\n" + CallerName + "\n" + CallCategory + "\n" + CallerPhone + "\n" + CallDetails; 
            }

            public string CallDetailsToFile()
            {
                return Date + ","
                    + CallerName + ","
                    + CallerPhone + ","
                    + CallDetails + ","
                    + CallCategory;
            }

                
    • Edited by beeftweet Friday, January 10, 2014 8:30 AM
    Thursday, January 9, 2014 4:36 PM

All replies

  • Hi Beeftweet,

    Please tell us what’s wrong with your code so that we can help you?

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 10, 2014 5:53 AM
    Moderator