예제 #1
0
        public void ActualitzarDadesIngredient()
        {
            Recepta    recepta    = new Recepta("ProvaRecepta23e");
            Producte   producte   = new Producte("ProvaProducte2394");
            Ingredient ingredient = new Ingredient(producte, recepta, 100);

            control.Afegir((ObjecteSql)recepta);
            control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)ingredient.Producte);
            control.Afegir((ObjecteSql)ingredient);
            ingredient.Quantitat = 12344;
            control.ComprovaActualitzacions(ingredient);
            Ingredient ingredientDessat = null;
            SortedList <string, Ingredient> indexProductes = new SortedList <string, Ingredient>();

            foreach (Ingredient producteD in Ingredient.IngredientsDessats(bdProves))
            {
                indexProductes.Add(producteD.PrimaryKey, producteD);
            }
            try
            {
                ingredientDessat = indexProductes[ingredient.PrimaryKey];
            }
            catch { ingredientDessat = new Ingredient(producte, recepta, 100); }
            if (ingredientDessat != null)
            {
                Assert.AreEqual(ingredient.Quantitat, ingredientDessat.Quantitat);//si esta bien!!
            }
        }
예제 #2
0
        public void DonarDeAltaProducte()
        {
            Producte producte = new Producte("ProvaIDProducte234", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);

            control.Afegir((ObjecteSql)producte.ReceptaOriginal);                              //doy de alta la receta sinReceta
            control.Afegir((ObjecteSql)producte);
            Assert.AreEqual(true, bdProves.CompruebaSiFunciona(producte.StringConsultaSql())); //si esta bien!!
        }
예제 #3
0
		public UnitatProducte(Producte producte, decimal quantiat, DateTime dataCaducitat, DateTime dataObertura, Recepta recepta)
			: this(producte, quantiat, dataCaducitat, dataObertura)
		{
			if (recepta != null)
				this.recepta = recepta;
			else
				this.recepta = new Recepta();
		}
예제 #4
0
        public void DonarDeBaixaProducte()
        {

            Producte producte = new Producte("ProvaIDProducte2234", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
            control.Afegir((ObjecteSql)producte.ReceptaOriginal);//doy de alta la receta sinReceta
            control.Afegir((ObjecteSql)producte);//lo doy de alta
            producte.OnBaixa();//lo doy de baja
            Assert.AreEqual(false, bdProves.CompruebaSiFunciona(producte.StringConsultaSql()));//si esta bien!!
        }
예제 #5
0
        public void ErrorAlActualitzarId()
        {
            Producte producte  = new Producte("ProvaIDProducte29", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
            Producte producte2 = new Producte("ProvaIDProducte239", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);

            control.Afegir((ObjecteSql) new Recepta());
            control.Afegir((ObjecteSql)producte);
            control.Afegir((ObjecteSql)producte2);
            producte2.PrimaryKey = producte.PrimaryKey;
            control.ComprovaActualitzacions(producte2);
            Assert.AreEqual("ProvaIDProducte239", producte2.PrimaryKey);
        }
예제 #6
0
        static void Main(string[] args)
        {
            BaseDeDadesMySQL bd = new BaseDeDadesMySQL();

            bd.Conecta();
            ControlObjectesSql control = new Control(bd);

            var estoc = control.Restaurar();

            Estoc.Estoc estocAct = new Estoc.Estoc();
            control.Reset();
            Producte       producte = new Producte("ProvaIDProducte", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
            UnitatProducte unitat   = new UnitatProducte(producte);
            UnitatProducte unitat2  = new UnitatProducte(producte);

            unitat2.Recepta = new Recepta("Altre");
            control.Afegir((ObjecteSql)unitat2.Recepta);
            unitat2.Recepta.Afegir(new Ingredient(producte, 100M));
            control.Afegir((IEnumerable <Ingredient>)unitat2.Recepta);
            unitat2.Quantitat = 12.3M;
            unitat.Quantitat  = 10;
            control.Afegir((ObjecteSql)producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)producte);
            control.Afegir(unitat);
            control.Afegir(unitat2);
            control.ComprovaActualitzacions();
            estocAct.Afegir(producte);
            if (estocAct.Equals(estoc))
            {
                Console.WriteLine("Funciona");                //si esta bien!!
            }
            else
            {
                Console.WriteLine("No funciona");
            }


            estoc = control.Restaurar();
            if (estocAct.Equals(estoc))
            {
                Console.WriteLine("Funciona");                //si esta bien!!
            }
            else
            {
                Console.WriteLine("No funciona");
            }
            //Console.WriteLine(unitat2);
            //Console.WriteLine(unitat2.Recepta);
            //Console.WriteLine(producte);
            //Console.WriteLine(estoc);
            //Console.WriteLine(control);
            Console.ReadKey();
        }
예제 #7
0
		public Ingredient(Producte producte, decimal quantitat)
		{
			CampPrimaryKey = "IdIngredient";
			AltaCanvi("IdProducte");
			AltaCanvi("IdRecepta");
			AltaCanvi("Quantitat");
			this.producte = producte;
			Taula = "Ingredients";
			this.producte = producte;
			this.quantitat = Convert.ToInt32(quantitat * 100);
			Recepta = null;
			DessaCanvis();

		}
예제 #8
0
        public void FabricaElMaximDeProducteAmbProductesDeEstoc()
        {
            Producte       pa             = new Producte("Pa");
            Producte       formatge       = new Producte("Formatge");
            Recepta        receptaBocata  = new Recepta("BocataFormatge");
            Producte       bocataFormatge = new Producte("Bocata de Formatge");
            UnitatProducte unitatPa       = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);

            UnitatProducte[] unitatsBocata;
            Estoc.Estoc      estoc = new Estoc.Estoc();
            receptaBocata.Afegir(new Ingredient(pa, 1.5M));
            receptaBocata.Afegir(new Ingredient(formatge, 6));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge });
            unitatsBocata = Producte.FabricaElMax(bocataFormatge, estoc, receptaBocata);
            Assert.AreNotEqual(new UnitatProducte[] {}, unitatsBocata);
        }
예제 #9
0
        public void ErrorFabricaProductesInsuficients()
        {
            Producte       pa             = new Producte("Pa");
            Producte       formatge       = new Producte("Formatge");
            Recepta        receptaBocata  = new Recepta("BocataFormatge");
            Producte       bocataFormatge = new Producte("Bocata de Formatge");
            UnitatProducte unitatPa       = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);
            UnitatProducte unitatBocata;

            Estoc.Estoc estoc = new Estoc.Estoc();
            receptaBocata.Afegir(new Ingredient(pa, 1.5M));
            receptaBocata.Afegir(new Ingredient(formatge, 50));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge });
            unitatBocata = Producte.Fabrica(bocataFormatge, receptaBocata, new Producte[] { pa, formatge });//por cambiar...se tiene que hacer...
            Assert.AreEqual(null, unitatBocata);
        }
예제 #10
0
        public void FabricaProducteAmbReceptaOriginal()
        {
            Producte       pa             = new Producte("Pa");
            Producte       formatge       = new Producte("Formatge");
            Recepta        receptaBocata  = new Recepta("BocataFormatge");
            Producte       bocataFormatge = new Producte("Bocata de Formatge");
            UnitatProducte unitatPa       = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);
            UnitatProducte unitatBocata;

            Estoc.Estoc estoc = new Estoc.Estoc();
            bocataFormatge.ReceptaOriginal = receptaBocata;
            receptaBocata.Afegir(new Ingredient(pa, 1));
            receptaBocata.Afegir(new Ingredient(formatge, 4));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge });
            unitatBocata = Producte.Fabrica(bocataFormatge, estoc);
            Assert.AreNotEqual(null, unitatBocata);
        }
예제 #11
0
 public void ActualitzarIdProducte()
 {
     Producte producte = new Producte("ProvaIDProducte2123", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
     control.Afegir((ObjecteSql)producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)producte);
     producte.PrimaryKey = "ProvaIDActualitzada";
     control.ComprovaActualitzacions(producte);
     Producte producteDessat=null;
     SortedList<string, Producte> indexProductes = new SortedList<string, Producte>();
     foreach (Producte producteD in Producte.ProductesDessats(bdProves))
         indexProductes.Add(producteD.PrimaryKey, producteD);
     try
     {
         producteDessat = indexProductes[producte.PrimaryKey];
     }
     catch { producteDessat = new Producte("NOFUNCIONAAA"); }
     Assert.AreEqual(producte, producteDessat);//si esta bien!!
 }
예제 #12
0
		public UnitatProducte(Producte producte)
		{
			if (producte == null)
				throw new Exception("La unitatProducte Ha de tenir un producte associat!! ");
			AltaCanvi("DataObertura");
			AltaCanvi("DataCaducitat");
			AltaCanvi("IdProducte");
			AltaCanvi("IdRecepta");
			AltaCanvi("Quantitat");
			this.producte = producte;
			dataCaducitat = new DateTime();
			dataQueEsVaObrir = new DateTime();
			recepta = new Recepta();
			CampPrimaryKey = "IdUnitat";
			PrimaryKey = producte.PrimaryKey + ";unitat";//algo para hacerlo unico...quizas se autoGenera y no hace falta...
			Taula = "UnitatsProductes";
			producte.AltaUnitat(this);

		}
예제 #13
0
        public void FabricaProducteAmbReceptaOriginal()
        {
            Producte pa = new Producte("Pa");
            Producte formatge = new Producte("Formatge");
            Recepta receptaBocata = new Recepta("BocataFormatge");
            Producte bocataFormatge = new Producte("Bocata de Formatge");
            UnitatProducte unitatPa = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);
            UnitatProducte unitatBocata;
            Estoc.Estoc estoc = new Estoc.Estoc();
            bocataFormatge.ReceptaOriginal = receptaBocata;
            receptaBocata.Afegir(new Ingredient(pa, 1));
            receptaBocata.Afegir(new Ingredient(formatge, 4));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge });
            unitatBocata = Producte.Fabrica(bocataFormatge, estoc);
            Assert.AreNotEqual(null, unitatBocata);


        }
예제 #14
0
		static void Main(string[] args)
		{
			BaseDeDadesMySQL bd = new BaseDeDadesMySQL();
			bd.Conecta();
			ControlObjectesSql control = new Control(bd);
			
			var estoc = control.Restaurar();
			Estoc.Estoc estocAct = new Estoc.Estoc();
			control.Reset();
			Producte producte = new Producte("ProvaIDProducte", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
			UnitatProducte unitat = new UnitatProducte(producte);
			UnitatProducte unitat2 = new UnitatProducte(producte);
			unitat2.Recepta = new Recepta("Altre");
			control.Afegir((ObjecteSql)unitat2.Recepta);
			unitat2.Recepta.Afegir(new Ingredient(producte, 100M));
			control.Afegir((IEnumerable<Ingredient>)unitat2.Recepta);
			unitat2.Quantitat = 12.3M;
			unitat.Quantitat = 10;
			control.Afegir((ObjecteSql)producte.ReceptaOriginal);
			control.Afegir((ObjecteSql)producte);
			control.Afegir(unitat);
			control.Afegir(unitat2);
			control.ComprovaActualitzacions();
			estocAct.Afegir(producte);
			if (estocAct.Equals(estoc))
				Console.WriteLine("Funciona");//si esta bien!!
			else
				Console.WriteLine("No funciona");

			
			estoc = control.Restaurar();
			if (estocAct.Equals(estoc))
				Console.WriteLine("Funciona");//si esta bien!!
			else
				Console.WriteLine("No funciona");
			//Console.WriteLine(unitat2);
			//Console.WriteLine(unitat2.Recepta);
			//Console.WriteLine(producte);
			//Console.WriteLine(estoc);
			//Console.WriteLine(control);
			Console.ReadKey();
			
		}
예제 #15
0
        public void ActualitzarDadesProducte()
        {

            Producte producte = new Producte("ProvaIDProducte245", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
            control.Afegir((ObjecteSql)producte.ReceptaOriginal);//doy de alta la receta sinReceta
            control.Afegir((ObjecteSql)producte);//doy de alta el producto
            producte.Unitat = "GramsProva";//lo modifico
            control.ComprovaActualitzacions(producte);//actualizo
            Producte producteDessat=null;
            SortedList<string,Producte> indexProductes=new SortedList<string,Producte>();
            foreach(Producte producteD in Producte.ProductesDessats(bdProves))
                indexProductes.Add(producteD.PrimaryKey,producteD);
            try
            {
                producteDessat = indexProductes[producte.PrimaryKey];
            }
            catch {producteDessat = new Producte("NOFUNCIONAAA"); }
            Assert.AreEqual(producte,producteDessat);//si esta bien!!
        }
예제 #16
0
        public void ActualitzarIdProducte()
        {
            Producte producte = new Producte("ProvaIDProducte2123", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);

            control.Afegir((ObjecteSql)producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)producte);
            producte.PrimaryKey = "ProvaIDActualitzada";
            control.ComprovaActualitzacions(producte);
            Producte producteDessat = null;
            SortedList <string, Producte> indexProductes = new SortedList <string, Producte>();

            foreach (Producte producteD in Producte.ProductesDessats(bdProves))
            {
                indexProductes.Add(producteD.PrimaryKey, producteD);
            }
            try
            {
                producteDessat = indexProductes[producte.PrimaryKey];
            }
            catch { producteDessat = new Producte("NOFUNCIONAAA"); }
            Assert.AreEqual(producte, producteDessat);//si esta bien!!
        }
예제 #17
0
        public void ActualitzarDadesProducte()
        {
            Producte producte = new Producte("ProvaIDProducte245", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);

            control.Afegir((ObjecteSql)producte.ReceptaOriginal); //doy de alta la receta sinReceta
            control.Afegir((ObjecteSql)producte);                 //doy de alta el producto
            producte.Unitat = "GramsProva";                       //lo modifico
            control.ComprovaActualitzacions(producte);            //actualizo
            Producte producteDessat = null;
            SortedList <string, Producte> indexProductes = new SortedList <string, Producte>();

            foreach (Producte producteD in Producte.ProductesDessats(bdProves))
            {
                indexProductes.Add(producteD.PrimaryKey, producteD);
            }
            try
            {
                producteDessat = indexProductes[producte.PrimaryKey];
            }
            catch { producteDessat = new Producte("NOFUNCIONAAA"); }
            Assert.AreEqual(producte, producteDessat);//si esta bien!!
        }
예제 #18
0
		public Ingredient(Producte producte, Recepta recepta, decimal quantitat)
			: this(producte, quantitat)
		{
			Recepta = recepta;
			DessaCanvis();
		}
예제 #19
0
 public void ErrorAlActualitzarId()
 {
  
     Producte producte = new Producte("ProvaIDProducte29", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
     Producte producte2 = new Producte("ProvaIDProducte239", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
     control.Afegir((ObjecteSql)new Recepta());
     control.Afegir((ObjecteSql)producte);
     control.Afegir((ObjecteSql)producte2);
     producte2.PrimaryKey = producte.PrimaryKey;
     control.ComprovaActualitzacions(producte2);
     Assert.AreEqual("ProvaIDProducte239", producte2.PrimaryKey);
 }
예제 #20
0
 public void ActualitzarDadesIngredient()
 {
     Recepta recepta = new Recepta("ProvaRecepta23e");
     Producte producte = new Producte("ProvaProducte2394");
     Ingredient ingredient = new Ingredient(producte, recepta, 100);
     control.Afegir((ObjecteSql)recepta);
     control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)ingredient.Producte);
     control.Afegir((ObjecteSql)ingredient);
     ingredient.Quantitat = 12344;
     control.ComprovaActualitzacions(ingredient);
     Ingredient ingredientDessat = null;
     SortedList<string, Ingredient> indexProductes = new SortedList<string, Ingredient>();
     foreach (Ingredient producteD in Ingredient.IngredientsDessats(bdProves))
         indexProductes.Add(producteD.PrimaryKey, producteD);
     try
     {
         ingredientDessat = indexProductes[ingredient.PrimaryKey];
     }
     catch {ingredientDessat= new Ingredient(producte, recepta, 100); }
     if(ingredientDessat!=null)
     Assert.AreEqual(ingredient.Quantitat, ingredientDessat.Quantitat);//si esta bien!!
     
 }
예제 #21
0
		public static UnitatProducte[] UnitatsDessades(Gabriel.Cat.BaseDeDades baseDeDades, Recepta[] receptes, Producte[] productes)
		{
			string[,]	taula = baseDeDades.ConsultaTableDirect("UnitatsProductes");
			List<UnitatProducte> unitatsProductes = new List<UnitatProducte>();
			SortedList<string, Recepta> indexRecepta = new SortedList<string, Recepta>();
			SortedList<string, Producte> indexProducte = new SortedList<string, Producte>();
			for (int i = 0; i < receptes.Length; i++)
				indexRecepta.Add(receptes[i].PrimaryKey, receptes[i]);

			for (int i = 0; i < productes.Length; i++)
				indexProducte.Add(productes[i].PrimaryKey, productes[i]);
			foreach(var recepta in indexRecepta)
				foreach(var ingredient in recepta.Value)
					try
			{
				if (indexProducte.ContainsKey(ingredient.IdProductePerPosar))
					ingredient.Producte = indexProducte[ingredient.IdProductePerPosar];
			}
			catch { }
			if (taula != null)
				for (int i = 1; i < taula.GetLength(1); i++)
			{//por mirar
				unitatsProductes.Add(new UnitatProducte(indexProducte[taula[1,i]], Convert.ToDecimal(taula[3,i])/100M, ObjecteSql.StringToDateTime(taula[4,i]), ObjecteSql.StringToDateTime(taula[5,i]), indexRecepta[taula[2,i]]));
				unitatsProductes[unitatsProductes.Count - 1].PrimaryKey = taula[0,i];
				unitatsProductes[unitatsProductes.Count - 1].DessaCanvis();
				
			}
			return unitatsProductes.ToArray<UnitatProducte>();
		}
예제 #22
0
        public void ErrorFabricaProductesFaltants()
        {
            Producte pa = new Producte("Pa");
            Producte formatge = new Producte("Formatge");
            Recepta receptaBocata = new Recepta("BocataFormatge");
            Producte bocataFormatge = new Producte("Bocata de Formatge");
            Producte oli = new Producte("Oli");
            UnitatProducte unitatOli = new UnitatProducte(oli, 100);
            UnitatProducte unitatPa = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);
            UnitatProducte unitatBocata;
            Estoc.Estoc estoc = new Estoc.Estoc();
            receptaBocata.Afegir(new Ingredient(pa, 1.5M));
            receptaBocata.Afegir(new Ingredient(formatge, 50));
            receptaBocata.Afegir(new Ingredient(oli,10));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge,oli });
            unitatBocata = Producte.Fabrica(bocataFormatge, receptaBocata, new Producte[] { pa, formatge });//por cambiar...se tiene que hacer...
            Assert.AreEqual(null, unitatBocata);


        }
예제 #23
0
        public void FabricaElMaximDeProducteAmbProductesDeEstoc()
        {
            Producte pa = new Producte("Pa");
            Producte formatge = new Producte("Formatge");
            Recepta receptaBocata = new Recepta("BocataFormatge");
            Producte bocataFormatge = new Producte("Bocata de Formatge");
            UnitatProducte unitatPa = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);
            UnitatProducte[] unitatsBocata;
            Estoc.Estoc estoc = new Estoc.Estoc();
            receptaBocata.Afegir(new Ingredient(pa, 1.5M));
            receptaBocata.Afegir(new Ingredient(formatge, 6));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge });
            unitatsBocata = Producte.FabricaElMax(bocataFormatge, estoc,receptaBocata);
            Assert.AreNotEqual(new UnitatProducte[]{}, unitatsBocata);


        }
예제 #24
0
		public UnitatProducte(Producte producte, decimal quantitat)
			: this(producte)
		{ this.quantitat = Convert.ToInt32(quantitat*100); }
예제 #25
0
		public UnitatProducte(Producte producte, decimal quantitat, DateTime dataCaducitat)
			: this(producte, quantitat)
		{ this.dataCaducitat = dataCaducitat; }
예제 #26
0
		public UnitatProducte(Producte producte, decimal quantitat, DateTime dataCaducitat, DateTime dataObertura)
			: this(producte, quantitat, dataCaducitat)
		{ this.dataQueEsVaObrir = dataObertura; }
예제 #27
0
		public UnitatProducte(Producte producte, decimal quantiat, Recepta recepta)
			: this(producte, quantiat)
		{ this.recepta = recepta; }