示例#1
0
 private void IdReceptaCanviatEvent(ObjecteSql sqlObj)
 {
     if (PrimaryKey.Contains(';'))
     {
         if (PrimaryKey.Split(';')[0] != sqlObj.PrimaryKey)
         {
             PrimaryKey = recepta.PrimaryKey + ";" + producte.PrimaryKey;
         }
     }
 }
示例#2
0
        public override string StringInsertSql(TipusBaseDeDades tipusBD)
        {
            string sentencia = null;

            if (ComprovacioSiEsPot())
            {
                sentencia  = "insert into " + Taula + "(IdProducte,IdRecepta,Quantitat,DataCaducitat,DataObertura) values(";
                sentencia += "'" + producte.PrimaryKey + "',";
                sentencia += "'" + IdRecepta + "',";
                sentencia += "'" + quantitat + "',";
                sentencia += ObjecteSql.DateTimeToStringSQL(tipusBD, DataCaducitat) + ",";
                sentencia += ObjecteSql.DateTimeToStringSQL(tipusBD, DataQueEsVaObrir) + ");";
            }
            return(sentencia);
        }
示例#3
0
 private void IdProducteCanviatEvent(ObjecteSql sqlObj)
 {
     if (PrimaryKey.Contains(';'))
     {
         if (PrimaryKey.Split(';')[1] != sqlObj.PrimaryKey)
         {
             if (Recepta != null)
             {
                 PrimaryKey = recepta.PrimaryKey + ";" + producte.PrimaryKey;
             }
             else
             {
                 PrimaryKey = IdIntern + ";" + producte.PrimaryKey;
             }
         }
     }
 }
示例#4
0
        public override string StringInsertSql(TipusBaseDeDades tipusBD)
        {
            //en este caso no importa el tipo de BD
            string sentencia = null;

            if (ComprovacioSiEsPot())
            {
                sentencia  = "insert into " + Taula + " (" + CampPrimaryKey + ",categoria,unitat,idRecepta,rutaImatge,infoExtra,quantitatMinimaEstoc,quantitatNormalEstoc,tempsAvisPerCaducar,tempsUnCopObert,tempsUnCopFet) values(";
                sentencia += "'" + PrimaryKey + "',";
                sentencia += "'" + categoria + "',";
                sentencia += "'" + unitat + "',";
                sentencia += "'" + receptaOri.PrimaryKey + "',";
                sentencia += "'" + rutaImatge + "',";
                sentencia += "'" + infoExtra + "',";
                sentencia += quantitatMinimaEstoc + ",";
                sentencia += quantitatNormalEstoc + ",";
                sentencia += ObjecteSql.TimeSpanToString(tempsAvisPerCaducar) + ",";
                sentencia += ObjecteSql.TimeSpanToString(tempsUnCopObert) + ",";
                sentencia += ObjecteSql.TimeSpanToString(tempsUnCopFet) + ");";
            }
            return(sentencia);
        }
示例#5
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>());
        }
示例#6
0
 private void AltaProducteEvent(ObjecteSql sqlObj)
 {
     Afegir(sqlObj as Producte);
 }
示例#7
0
 private void BaixaProduceteEvent(ObjecteSql sqlObj)
 {
     Treu(sqlObj as Producte);
 }
示例#8
0
 private void BaixaEvent(ObjecteSql sqlObj)
 {
     Treu(sqlObj as Ingredient);
 }
示例#9
0
 private void AltaEvent(ObjecteSql sqlObj)
 {
     Afegir(sqlObj as Ingredient);
 }
示例#10
0
        public static Producte[] ProductesDessats(Gabriel.Cat.BaseDeDades baseDeDades, Recepta[] receptes)
        {
            List <Producte> productes = new List <Producte>();

            SortedList <string, Recepta> indexReceptes = new SortedList <string, Recepta>();

            for (int i = 0; i < receptes.Length; i++)
            {
                indexReceptes.Add(receptes[i].PrimaryKey, receptes[i]);
            }
            string[,] taula = baseDeDades.ConsultaTableDirect("Productes");
            if (taula != null)
            {
                for (int i = 1; i < taula.GetLength(1); i++)
                {
                    try {                    //por mirar
                        productes.Add(new Producte(taula[0, i], taula[1, i], taula[2, i], ObjecteSql.StringToTimeSpan(taula[8, i]), ObjecteSql.StringToTimeSpan(taula[9, i]), ObjecteSql.StringToTimeSpan(taula[10, i]), indexReceptes[taula[3, i]], Convert.ToDecimal(taula[6, i]) / 100M, Convert.ToDecimal(taula[7, i]) / 100M)
                        {
                            rutaImatge = taula[4, i],
                            infoExtra  = taula[5, i]
                        });
                        foreach (Ingredient ingredient in indexReceptes[taula[3, i]])
                        {
                            if (ingredient.IdProductePerPosar == productes[productes.Count - 1].PrimaryKey)
                            {
                                ingredient.Producte = productes[productes.Count - 1];
                                ingredient.DessaCanvis();
                            }
                        }
                    } catch {
                    }
                }
            }
            return(productes.ToArray <Producte>());
        }
示例#11
0
		private void IdProducteCanviatEvent(ObjecteSql sqlObj)
		{
			if (PrimaryKey.Contains(';'))
				if (PrimaryKey.Split(';')[1] != sqlObj.PrimaryKey) {
				if (Recepta != null)
					PrimaryKey = recepta.PrimaryKey + ";" + producte.PrimaryKey;
				else
					PrimaryKey = IdIntern + ";" + producte.PrimaryKey;
			}
		}
示例#12
0
		private void IdReceptaCanviatEvent(ObjecteSql sqlObj)
		{
			if (PrimaryKey.Contains(';'))
				if (PrimaryKey.Split(';')[0] != sqlObj.PrimaryKey)
					PrimaryKey = recepta.PrimaryKey + ";" + producte.PrimaryKey;
		}