예제 #1
0
 public Form2(Form1 form1, FoodObject obj)
 {
     form = form1;
     InitializeComponent();
     label1.Text += obj.Name;
     food         = obj;
 }
예제 #2
0
        private void createObjectQuery()
        {
            con = perfomConnection(pathToDb);
            con.Open();
            OleDbDataReader reader = null;
            var             cmd    = new OleDbCommand("SELECT * FROM PA_DAT;", con);

            reader = cmd.ExecuteReader();
            String prevId = "";

            while (reader.Read())
            {
                string     id = reader["NDB No"].ToString();
                FoodObject food;

                //jesli juz istnieje w slowniku obiekt wyciagam ze slownika
                if (prevId.Equals(id))
                {
                    food = dictionary[id];
                }
                //jesli nie o robie nowu
                else
                {
                    food   = new FoodObject(id);
                    prevId = id;
                }
                food.SumOfMers += Double.Parse(reader["Flav_Val"].ToString());
                food.SumOfMersWithInputWeight = food.SumOfMers;
                if (!dictionary.ContainsKey(id))
                {
                    OleDbDataReader reader2 = null;
                    var             cmd2    = new OleDbCommand("SELECT * FROM FOOD_DES WHERE FOOD_DES.[NDB No] like '" + id + "'", con);
                    reader2 = cmd2.ExecuteReader();
                    while (reader2.Read())
                    {
                        food.Name = reader2["Long_Desc"].ToString();
                        if (id.Equals("97020"))
                        {
                            food.Name = "Babyfood, fruit, apple, strawberry, banana";
                        }
                        dictionary.Add(id, food);
                    }
                }
            }
            con.Close();
        }
예제 #3
0
 public void setObj(FoodObject food)
 {
     temp2 = food;
 }