//Method that receive the provinceCode and check if its in the file
        public DAProvince DAGetByProvinceCode(string provinceCode)
        {
            DAProvince province = null;

            sr = new StreamReader(Path);
            while (!sr.EndOfStream)
            {
                string[] provinceArr = sr.ReadLine().Split(';');

                if (provinceCode == provinceArr[0])
                {
                    province = new DAProvince();

                    province.ProvinceCode       = provinceArr[0];
                    province.Name               = provinceArr[1];
                    province.CountryCode        = provinceArr[2];
                    province.TaxCode            = provinceArr[3];
                    province.TaxRate            = Convert.ToDouble(provinceArr[4]);
                    province.IncludesFederalTax =
                        Convert.ToBoolean(provinceArr[5]);
                }
            }
            sr.Close();
            return(province);
        }
        //Method to delete a province from file
        public void DADelete()
        {
            List <DAProvince> provinceList = new List <DAProvince>();
            DAProvince        province     = new DAProvince();

            sr = new StreamReader(Path);
            while (!sr.EndOfStream)
            {
                string[] provinceArr = sr.ReadLine().Split(';');
                province = new DAProvince();
                province.ProvinceCode       = provinceArr[0];
                province.Name               = provinceArr[1];
                province.CountryCode        = provinceArr[2];
                province.TaxCode            = provinceArr[3];
                province.TaxRate            = Convert.ToDouble(provinceArr[4]);
                province.IncludesFederalTax = Convert.ToBoolean(provinceArr[5]);

                if (this.ProvinceCode != province.ProvinceCode)
                {
                    //Add on the list all the provinces
                    //but not the one chosen to delete
                    provinceList.Add(province);
                }
            }
            sr.Close();
            //Delete the path
            DeleteFile(Path);
            //Create a new path and fill it with the
            // provinces but not the one deleted
            sw = new StreamWriter(Path, append: true);
            if (provinceList.Count == 0)
            {
                sw.Write("");
            }
            else
            {
                foreach (DAProvince item in provinceList)
                {
                    sw.WriteLine(
                        item.ProvinceCode + ";" +
                        item.Name + ";" +
                        item.CountryCode + ";" +
                        item.TaxCode + ";" +
                        item.TaxRate + ";" +
                        item.IncludesFederalTax
                        );
                }
            }
            sw.Flush();
            sw.Close();
        }
        //Mehod that returns a list with all province files from Province.txt
        public List <DAProvince> DAGetProvinces()
        {
            List <DAProvince> provinceList = new List <DAProvince>();
            DAProvince        province;

            sr = new StreamReader(Path);
            while (!sr.EndOfStream)
            {
                string[] provinceArr = sr.ReadLine().Split(';');
                province = new DAProvince();
                province.ProvinceCode       = provinceArr[0];
                province.Name               = provinceArr[1];
                province.CountryCode        = provinceArr[2];
                province.TaxCode            = provinceArr[3];
                province.TaxRate            = Convert.ToDouble(provinceArr[4]);
                province.IncludesFederalTax = Convert.ToBoolean(provinceArr[5]);
                provinceList.Add(province);
            }
            sr.Close();
            return(provinceList);
        }
        //Creates a Province object from a record read in from the file
        public DAProvince DAParseProvince(string parameter)
        {
            DAProvince province = new DAProvince();

            try
            {
                string[] provinceArr = parameter.Split(';');

                province.ProvinceCode       = provinceArr[0];
                province.Name               = provinceArr[1];
                province.CountryCode        = provinceArr[2];
                province.TaxCode            = provinceArr[3];
                province.TaxRate            = Convert.ToDouble(provinceArr[4]);
                province.IncludesFederalTax =
                    Convert.ToBoolean(provinceArr[5]);

                return(province);
            }
            catch (Exception ex)
            {
                throw new Exception("Not a province record\n");
            }
        }