示例#1
0
        public static void updateLuotThuoc(int ID, int soLuongThem)
        {
            if (currentLuotKhamID == -1)
            {
                return;
            }
            LuotThuoc lt    = LuotThuocDAO.getLuotThuoc(ID);
            int       index = -1;

            for (int i = 0; i < listLuotThuoc.Count; i++)
            {
                if (listLuotThuoc.ElementAt(i).ID == ID)
                {
                    index = i;
                }
            }
            if (index == -1 || lt == null)
            {
                return;
            }
            lt.SoLuong += soLuongThem;
            lt.ChiPhi  += soLuongThem * ThuocDAO.getThuoc(lt.Thuoc).DonGia;
            listLuotThuoc.ElementAt(index).soluong2 = (int)lt.SoLuong;
            listLuotThuoc.ElementAt(index).chiphi2  = (double)lt.ChiPhi;
            LuotThuocDAO.updateLuotThuoc(ID, lt);
        }
示例#2
0
        public static bool removeLuotThuoc(int ID)
        {
            if (currentLuotKhamID == -1)
            {
                return(false);
            }
            LuotKham lk = LuotKhamDAO.getLuotKham(currentLuotKhamID);

            LuotThuoc lt = LuotThuocDAO.getLuotThuoc(ID);

            if (lt == null)
            {
                return(false);
            }
            lk.TienThuoc -= lt.ChiPhi;
            LuotKhamDAO.updateLuotKham(lk.ID, lk);
            foreach (LuotThuoc l in listLuotThuoc)
            {
                if (l.ID == ID)
                {
                    lt = l;
                    break;
                }
            }
            listLuotThuoc.Remove(lt);
            LuotThuocDAO.removeLuotThuoc(ID);
            return(true);
        }