Example #1
0
        // Displays full product information
        public static void FileDb(string query)
        {
            ClearScreen();
            Header();

            int    counter = 0;
            string line;

            //Hard code StreamReader
            //System.IO.StreamReader file = new System.IO.StreamReader("C:\\Users\\brett\\Downloads\\Project\\Project\\Products.txt");
            string filePath   = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string folderPath = System.IO.Path.GetDirectoryName(filePath);

            System.IO.StreamReader file = new System.IO.StreamReader(folderPath + "\\Products.txt");
            while ((line = file.ReadLine()) != null)
            {
                if (line.Contains(query))
                {
                    Product2 u = new Product2();
                    u.setString(line);
                    u.toString();
                }
                counter++;
            }
            file.Close();
        }
Example #2
0
        // Takes string to allow selection UI.
        public static string FileDbParse(string query)
        {
            query = query.ToLower();
            string itemNumber = "";
            string line;
            int    counter = 0;
            int    rows;
            string filePath   = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string folderPath = System.IO.Path.GetDirectoryName(filePath);


            using (StreamReader file = new StreamReader(folderPath + "\\Products.txt"))
            {
                while ((line = file.ReadLine()) != null)
                {
                    if (line.ToLower().Contains(query))
                    {
                        counter++;
                    }
                }
            }
            //file.Close();
            rows = counter / 17;
            if (rows == 0)
            {
                rows = 1;
            }
            else
            {
                rows += 2;
            }



            Product2[,] products = new Product2[rows, 17];
            counter = 0;
            rows    = 0;


            //TODO: Fix this
            using (StreamReader file = new StreamReader(folderPath + "\\Products.txt"))
            {
                while ((line = file.ReadLine()) != null)
                {
                    if (line.ToLower().Contains(query))
                    {
                        products[rows, counter] = new Product2();
                        products[rows, counter].setString(line);
                        counter++;
                        if (counter == 16)
                        {
                            counter = 0;
                            rows++;
                        }
                    }
                }
            }


            itemNumber = QuerySelection(products, query);
            return(itemNumber);
        }
Example #3
0
        // Takes in array of queries and parses them through.
        public static string FileDbParse(string[] queries, string queri)
        {
            string query;
            string line;
            int    counter = 0;
            int    rows;

            string filePath   = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string folderPath = System.IO.Path.GetDirectoryName(filePath);

            System.IO.StreamReader file = new System.IO.StreamReader(folderPath + "\\Products.txt");
            while ((line = file.ReadLine()) != null)
            {
                int checker = 0;
                foreach (string s in queries)
                {
                    if (line.ToLower().Contains(s.ToLower()))
                    {
                        checker++;
                    }
                }
                if (checker == queries.Length)
                {
                    counter++;
                }
            }
            file.Close();
            rows = counter / 17;
            if (rows == 0)
            {
                rows = 1;
            }
            else
            {
                rows += 2;
            }
            Product2[,] products = new Product2[rows, 17];
            counter = 0;
            rows    = 0;



            file = new System.IO.StreamReader(folderPath + "\\Products.txt");
            while ((line = file.ReadLine()) != null)
            {
                int checker = 0;
                foreach (string s in queries)
                {
                    if (line.ToLower().Contains(s.ToLower()))
                    {
                        checker++;
                    }
                }
                if (checker == queries.Length)
                {
                    products[rows, counter] = new Product2();
                    products[rows, counter].setString(line);
                    counter++;
                    if (counter == 17)
                    {
                        counter = 0;
                        rows++;
                    }
                }
            }
            file.Close();

            query = QuerySelection(products, queri);
            return(query);
        }