Example #1
0
        public void LoadData()
        {
            SerializeFileHandler sr = new SerializeFileHandler();

            fitnessClassList = sr.ReadFitnessClassListFromFile("data.dat");
            UpdateListbox();
        }
        private void ReadReport(String filePath, FitnessClassList fitnessClassList)
        {
            //FileStream inFile;
            //StreamReader reader;
            //String fileRecord;
            //String[] fileFields;

            //// open file and attach to streamreader
            //inFile = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            //reader = new StreamReader(inFile);
            //List<String> reportItem = new List<String>();
            //string DELIM = Environment.NewLine;

            //// get first record from stream
            //fileRecord = reader.ReadLine();

            //for (int i = 0; fileRecord != null; i++)
            //{
            //    //while (fileRecord != null)
            //    //{

            //    // split record into fields
            //    fileFields[i] = fileRecord.Split(DELIM);

            //   // FitnessClassOpportunity FCO = (FitnessClassOpportunity)fileFields;

            //    // set form properties
            //    fitnessClassList.addFitnessClass((FitnessClassOpportunity)fileFields[i]);
            //}

            //// close streamreader and file
            //reader.Close();
            //inFile.Close();
        }
Example #3
0
        private void UpdateListBox(ListBox listBox, FitnessClassList reportList)
        {
            listBox.Items.Clear();

            for (int i = 0; i < reportList.Count(); i++)
            {
                listBox.Items.Add(reportList.getFitnessClass(i).ToString());
            }
        }
Example #4
0
        private void LoadReports(FitnessClassList reportList, String file, ListBox listBox)
        {
            SerializeFileHandler sfh = new SerializeFileHandler();

            reportList = sfh.ReadFitnessClassListFromFile(Server.MapPath(file));


            //UpdateListBox();
            UpdateListBox(listBox, reportList);
        }
        public static FitnessClassList SortById(FitnessClassList fitnessClassList)
        {
            FitnessClassList sortedFitnessClassList = new FitnessClassList();

            for (int i = 0; i < fitnessClassList.Count(); i++)
            {
                sortedFitnessClassList.addFitnessClass(fitnessClassList.getFitnessClass(i));
            }

            sortedFitnessClassList.Sort();

            return(sortedFitnessClassList);
        }
        public static FitnessClassList FilterLocation(FitnessClassList fitnessClassList, String selectedLocation)
        {
            FitnessClassList filteredFitnessClassList = new FitnessClassList();

            for (int i = 0; i < fitnessClassList.Count(); i++)
            {
                if (fitnessClassList.getFitnessClass(i).Location == selectedLocation)
                {
                    filteredFitnessClassList.addFitnessClass(fitnessClassList.getFitnessClass(i));
                }
            }

            return(filteredFitnessClassList);
        }
Example #7
0
        public void WriteFitnessClassListToFile(FitnessClassList fitnessClassList, String filePath)
        {
            FileStream      outFile;
            BinaryFormatter bFormatter = new BinaryFormatter();

            // open file for output
            outFile = new FileStream(filePath, FileMode.Create, FileAccess.Write);

            // output object to file via serialization
            bFormatter.Serialize(outFile, fitnessClassList);

            // close file
            outFile.Close();
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            fitnessClassList = (FitnessClassList)Session["FitnessClassList"];

            //checks tat the fitness class opportunity coming from the add form isn't null
            //so that it dosent run into a null refernce exepton
            if (Session["FitnessClassOpportunity"] != null)
            {
                if (Session["FitnessClassList"] != null)
                {
                    AddFitnessClass();
                }

                //sets the clas that is being handed over to be null
                //allows another to be added
                Session["FitnessClassOpportunity"] = null;
            }
        }
Example #9
0
        public FitnessClassList ReadFitnessClassListFromFile(String filePath)
        {
            FileStream       inFile;
            FitnessClassList fitnessClassList = null;
            BinaryFormatter  bFormatter       = new BinaryFormatter();

            // open file for input
            inFile = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            // keep going while there are still records to read
            while (inFile.Position < inFile.Length)
            {
                // obtain object from file via serialization
                fitnessClassList = (FitnessClassList)bFormatter.Deserialize(inFile);
            }

            // close file
            inFile.Close();

            return(fitnessClassList);
        }
        private void CreateReport(String filePath, FitnessClassList fitnessClassList)
        {
            FileStream   outFile;
            StreamWriter writer;

            outFile = new FileStream(filePath, FileMode.Create,
                                     FileAccess.Write);
            writer = new StreamWriter(outFile);

            for (int i = 0; i < fitnessClassList.Count(); i++)
            {
                FitnessClassOpportunity f = fitnessClassList.getFitnessClass(i);

                // output fitness class opportunity details
                writer.WriteLine(f.ToString());
            }

            // close writer
            writer.Close();

            // close file
            outFile.Close();
        }
 public TextReportGenerator(FitnessClassList fitnessClassList)
 {
     this.fitnessClassList = fitnessClassList;
 }
Example #12
0
 private void Form1_Load(object sender, EventArgs e)
 {
     fitnessClassList     = new FitnessClassList();
     cboDay.SelectedIndex = 0;
 }