コード例 #1
0
ファイル: Main.cs プロジェクト: AlexRod97/RBProyects
        public void Update(Swine updatedData)
        {
            string       oldName  = MainfileDirectory + fileName;
            StreamReader sr       = new StreamReader(oldName);
            string       tempName = MainfileDirectory + "\\temp.txt";
            StreamWriter sw       = new StreamWriter(tempName);

            newSwine = updatedData;

            while (!sr.EndOfStream)
            {
                string old = sr.ReadLine();
                oldSwine = swineFabric.Distribute(old);

                if (newSwine.getArete() != oldSwine.getArete())
                {
                    sw.WriteLine(old);
                }
                else if (newSwine.getArete() == oldSwine.getArete())
                {
                    sw.WriteLine(newSwine.ConvertString());
                }
            }
            sr.Close();
            sw.Close();
            File.Delete(oldName);
            File.Move(tempName, oldName);
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: AlexRod97/RBProyects
        //Verifica que el arete exista con EQUALS
        public Swine ExisteArete(string item)
        {
            StreamReader sr     = new StreamReader(MainfileDirectory + fileName);
            Swine        result = new Swine();

            try
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();
                    oldSwine = swineFabric.Distribute(line);

                    if (oldSwine.getArete().Equals(item))
                    {
                        result = oldSwine;
                        break;
                    }
                    else
                    {
                        result = null;
                    }
                }
                sr.Close();
            }
            catch (Exception)
            {
                result = null;
            }

            return(result);
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: AlexRod97/RBProyects
        /*----------------------------------BUSCADORES POR CADA PARAMETRO NECESARIO----------------------------------*/

        //Diferente a "ExisteArete" porque este busca con 'parecidos'
        public List <Swine> BuscarPorArete(string item)
        {
            StreamReader sr      = new StreamReader(MainfileDirectory + fileName);
            List <Swine> results = new List <Swine>();

            while (!sr.EndOfStream)
            {
                string old = sr.ReadLine();
                oldSwine = swineFabric.Distribute(old);

                if (oldSwine.getArete().Contains(item))
                {
                    results.Add(oldSwine);
                }
            }
            sr.Close();

            return(results);
        }