예제 #1
0
        public void DonarDeAltaRecepta()
        {
            Recepta recepta = new Recepta("ProvaRecepta");

            control.Afegir((ObjecteSql)recepta);
            Assert.AreEqual(true, bdProves.CompruebaSiFunciona(recepta.StringConsultaSql()));
        }
예제 #2
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!!
            }
        }
예제 #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 ActionResult DeleteConfirmed(int id)
        {
            Recepta recepta = db.Receptas.Find(id);

            db.Receptas.Remove(recepta);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #5
0
        public void ActualitzarRecepta()
        {
            Recepta recepta = new Recepta("ProvaRecepta324");

            control.Afegir((ObjecteSql)recepta);
            recepta.PrimaryKey = "ProvaReceptaACtualitzacio";
            control.ComprovaActualitzacions(recepta);
            Assert.AreEqual(true, bdProves.CompruebaSiFunciona(recepta.StringConsultaSql()));
        }
예제 #6
0
 public ActionResult Edit([Bind(Include = "Id,Name,miligrami,dozvolenaDoza")] Recepta recepta)
 {
     if (ModelState.IsValid)
     {
         db.Entry(recepta).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(recepta));
 }
예제 #7
0
        public void DonarDeAltaIngredient()
        {
            Recepta    recepta    = new Recepta("ProvaRecepta98");
            Ingredient ingredient = new Ingredient(new Producte("ProvaProducte234"), recepta, 100);

            control.Afegir((ObjecteSql)recepta);
            control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)ingredient.Producte);
            control.Afegir((ObjecteSql)ingredient);
            Assert.AreEqual(true, bdProves.CompruebaSiFunciona(ingredient.StringConsultaSql()));
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "Id,Name,miligrami,dozvolenaDoza")] Recepta recepta)
        {
            if (ModelState.IsValid)
            {
                db.Receptas.Add(recepta);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(recepta));
        }
예제 #9
0
        public void DonarDeBaixaIngredientDonantDeBaixaRecepta()
        {
            Recepta    recepta    = new Recepta("ProvaRecepta423");
            Ingredient ingredient = new Ingredient(new Producte("ProvaProducte69234"), recepta, 100);

            control.Afegir((ObjecteSql)recepta);
            control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)ingredient.Producte);
            control.Afegir((ObjecteSql)ingredient);
            recepta.OnBaixa();
            Assert.AreEqual(false, bdProves.CompruebaSiFunciona(ingredient.StringConsultaSql()));
        }
예제 #10
0
        // GET: Receptas/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Recepta recepta = db.Receptas.Find(id);

            if (recepta == null)
            {
                return(HttpNotFound());
            }
            return(View(recepta));
        }
예제 #11
0
        public void ActualitzarIdIngredient()
        {
            Recepta    recepta = new Recepta("ProvaRecepta23e");
            string     idAnt;
            Ingredient ingredient = new Ingredient(new Producte("ProvaProducte28934"), recepta, 100);

            idAnt = ingredient.PrimaryKey;
            control.Afegir((ObjecteSql)recepta);
            control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)ingredient.Producte);
            control.Afegir((ObjecteSql)ingredient);
            recepta.PrimaryKey = "NouIDRecepta";
            control.ComprovaActualitzacions(recepta);
            control.ComprovaActualitzacions(ingredient);
            Assert.AreNotEqual(idAnt, ingredient.PrimaryKey);
        }
예제 #12
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);
        }
예제 #13
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);
        }
예제 #14
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);
        }
예제 #15
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);

		}
예제 #16
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);


        }
예제 #17
0
        private void WypiszeRecepteBtn_Click(object sender, RoutedEventArgs e)
        {
            if (listaLekow2.Count() == 0)
            {
                MessageBoxResult result1 = MessageBox.Show("Nie wybrano żadnych leków");
                return;
            }
            using DataBaseContext dataBaseContext = new DataBaseContext();

            Pacjent pacjentDb = dataBaseContext.Pacjeci.Where(p => p.PESEL == wizyta.pacjent.PESEL).FirstOrDefault();

            Lekarz lekarzDb = dataBaseContext.Lekarze.Where(p => p.PESEL == wizyta.lekarz.PESEL).FirstOrDefault();


            Recepta recepta = new Recepta
            {
                pacjent = pacjentDb,
                lekarz  = lekarzDb,
            };


            for (int i = 0; i < listaLekow2.Count(); i++)
            {
                Lek        lekDb      = dataBaseContext.Leki.Where(p => p.ID == listaLekow2[i].ID).FirstOrDefault();
                LekRecepta lekRecepta = new LekRecepta
                {
                    recepta = recepta,
                    lek     = lekDb
                };
                dataBaseContext.LekRecepta.Add(lekRecepta);
            }


            dataBaseContext.Add(recepta);

            dataBaseContext.SaveChanges();
            MessageBoxResult result = MessageBox.Show("Dodano recepte");
        }
예제 #18
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>();
		}
예제 #19
0
 public void ActualitzarIdIngredient()
 {
     
     Recepta recepta = new Recepta("ProvaRecepta23e");
     string idAnt;
     Ingredient ingredient = new Ingredient(new Producte("ProvaProducte28934"), recepta, 100);
     idAnt = ingredient.PrimaryKey;
     control.Afegir((ObjecteSql)recepta);
     control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)ingredient.Producte);
     control.Afegir((ObjecteSql)ingredient);
     recepta.PrimaryKey = "NouIDRecepta";
     control.ComprovaActualitzacions(recepta);
     control.ComprovaActualitzacions(ingredient);
     Assert.AreNotEqual(idAnt, ingredient.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 void DonarDeBaixaIngredientDonantDeBaixaRecepta()
 {
     Recepta recepta = new Recepta("ProvaRecepta423");
     Ingredient ingredient = new Ingredient(new Producte("ProvaProducte69234"), recepta, 100);
     control.Afegir((ObjecteSql)recepta);
     control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)ingredient.Producte);
     control.Afegir((ObjecteSql)ingredient);
     recepta.OnBaixa();
     Assert.AreEqual(false, bdProves.CompruebaSiFunciona(ingredient.StringConsultaSql()));
 }
예제 #22
0
 public void DonarDeAltaIngredient()
 {
     Recepta recepta = new Recepta("ProvaRecepta98");
     Ingredient ingredient = new Ingredient(new Producte("ProvaProducte234"),recepta, 100);
     
     control.Afegir((ObjecteSql)recepta);
     control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)ingredient.Producte);
     control.Afegir((ObjecteSql)ingredient);
     Assert.AreEqual(true, bdProves.CompruebaSiFunciona(ingredient.StringConsultaSql()));
 }
예제 #23
0
 public void ActualitzarRecepta()
 {
     Recepta recepta = new Recepta("ProvaRecepta324");
     control.Afegir((ObjecteSql)recepta);
     recepta.PrimaryKey = "ProvaReceptaACtualitzacio";
     control.ComprovaActualitzacions(recepta);
     Assert.AreEqual(true, bdProves.CompruebaSiFunciona(recepta.StringConsultaSql()));
 }
예제 #24
0
 public void DonarDeBaixaRecepta()
 {
     Recepta recepta = new Recepta("ProvaRecepta2");
     control.Afegir((ObjecteSql)recepta);
     recepta.OnBaixa();
     Assert.AreEqual(false, bdProves.CompruebaSiFunciona(recepta.StringConsultaSql()));
 }
예제 #25
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);


        }
예제 #26
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);


        }
예제 #27
0
		public Ingredient(Producte producte, Recepta recepta, decimal quantitat)
			: this(producte, quantitat)
		{
			Recepta = recepta;
			DessaCanvis();
		}
예제 #28
0
		public UnitatProducte(Producte producte, decimal quantiat, Recepta recepta)
			: this(producte, quantiat)
		{ this.recepta = recepta; }