Beispiel #1
0
 public void updateHangHoa(HangHoaBan tmp)
 {
     foreach (HangHoaBan i in listHangHoa)
     {
         if (i.id == tmp.id)
         {
             i.sl = tmp.sl;
             if (tmp.sl == 0)
             {
                 listHangHoa.Remove(tmp);
             }
             return;
         }
     }
 }
Beispiel #2
0
        public void addHangHoa(HangHoaBan tmp)
        {
            bool co = false;

            foreach (HangHoaBan i in listHangHoa)
            {
                if (i.id == tmp.id) //Already exists
                {
                    i.sl += tmp.sl;
                    co    = true;
                    break;
                }
            }
            if (!co)
            {
                listHangHoa.Add(tmp);
            }
        }