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); }
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); }
public static bool removeLuotKham(int ID) { LuotKham lk = LuotKhamDAO.getLuotKham(ID); if (lk == null) { return(false); } foreach (LuotThuoc lt in lk.LuotThuocs) { LuotThuocDAO.removeLuotThuoc(lt.ID); } BenhNhan temp = null; foreach (BenhNhan bn in listBenhNhan) { if (bn.CMND.Equals(lk.BenhNhan)) { temp = bn; break; } } listBenhNhan.Remove(temp); LuotKhamDAO.removeLuotKham(ID); if (currentLuotKhamID == ID) { currentLuotKhamID = -1; } return(true); }
public static void readSettings() { try { string[] lines = System.IO.File.ReadAllLines("setting.txt"); for (int i = 0; i < lines.Count(); i++) { string[] tokens = lines[i].Split(new string[] { " - " }, StringSplitOptions.RemoveEmptyEntries); if (tokens[0].Equals("Tien kham")) { tienKham = double.Parse(tokens[1]); } if (tokens[0].Equals("Gioi han luot kham")) { gioiHanLuotKham = int.Parse(tokens[1]); } if (tokens[0].Equals("Don vi thuoc")) { donViThuoc = new List <string>(); donViThuoc.Add(""); for (int j = 1; j < tokens.Count(); j++) { donViThuoc.Add(tokens[j]); } } if (tokens[0].Equals("Trieu chung")) { trieuChung = new List <string>(); for (int j = 1; j < tokens.Count(); j++) { trieuChung.Add(tokens[j]); } } } currentLKID = LuotKhamDAO.getLatestID() + 1; currentLTID = LuotThuocDAO.getLatestID() + 1; } catch (Exception e) { // thong bao loi. donViThuoc = new List <string>(); donViThuoc.Add("Vien"); donViThuoc.Add("Vi thuoc 6 vien"); donViThuoc.Add("Hop"); trieuChung = new List <string>(); trieuChung.Add("Khó thở"); trieuChung.Add("Nghẹn ở họng và lồng ngực."); trieuChung.Add("Chóng mặt"); trieuChung.Add("Co giật"); trieuChung.Add("Nôn mửa, buồn nôn"); trieuChung.Add("Đau bụng"); trieuChung.Add("Đau cơ"); trieuChung.Add("Cơ thể cảm thấy đau nhức nhẹ"); saveSettings(); } }
public static bool getThongKeThuoc(string month) { IList <LuotThuoc> list = LuotThuocDAO.getLuotThuocOfMonth(month); listThongKeLuotThuoc.Clear(); for (int i = 0; i < listAllThuoc.Count; i++) { ThongKeLuotThuoc tklt = new ThongKeLuotThuoc(listAllThuoc.ElementAt(i).TenThuoc); tklt.getData(list); listThongKeLuotThuoc.Add(tklt); } return(true); }
public static void addLuotThuoc(string thuoc, int soLuong) { if (currentLuotKhamID == -1) { return; } int check = -1; LuotKham lk; foreach (Thuoc th in listAllThuoc) { if (th.TenThuoc.Equals(thuoc)) { check = 0; break; } } if (check == -1) { return; } else { lk = LuotKhamDAO.getLuotKham(currentLuotKhamID); IList <LuotThuoc> list = lk.LuotThuocs.ToList(); foreach (LuotThuoc lth in list) { if (lth.Thuoc.Equals(thuoc)) { lk.TienThuoc += soLuong * ThuocDAO.getThuoc(thuoc).DonGia; LuotKhamDAO.updateLuotKham(lk.ID, lk); updateLuotThuoc(lth.ID, soLuong); return; } } } LuotThuoc lt = new LuotThuoc(); lt.ID = currentLTID++; lt.LuotKham = currentLuotKhamID; lt.SoLuong = soLuong; lt.Thuoc = thuoc; lt.ChiPhi = lt.SoLuong * ThuocDAO.getThuoc(thuoc).DonGia; lk.TienThuoc += lt.ChiPhi; listLuotThuoc.Add(lt); LuotKhamDAO.updateLuotKham(lk.ID, lk); LuotThuocDAO.addLuotThuoc(lt); }