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 void init() { readSettings(); listAllBenh = BenhDAO.getAllList(); if (!listAllBenh.Any()) { BenhDAO.addOrUpdateBenh("unidentified", new QuanLyPhongKham.Benh()); listAllBenh.Add(new Benh()); } listAllThuoc = ThuocDAO.getAllList(); foreach (Thuoc t in listAllThuoc) { bindingListAllThuoc.Add(t); } IList <LuotKham> list = LuotKhamDAO.getAllLuotKhamOfCurrentDay(); listBenhNhan = new BindingList <BenhNhan>(); if (list.Any()) { for (int i = 0; i < list.Count; i++) { listBenhNhan.Add(list.ElementAt(i).BenhNhan1); } } listLuotKhamTrongNgay = new BindingList <LuotKham>(); listThongKeLuotkham = new BindingList <ThongKeLuotKham>(); listThongKeLuotThuoc = new BindingList <ThongKeLuotThuoc>(); }
private void HoaDonBtn_Click(object sender, RoutedEventArgs e) { try { if (DSLuotKhamListView.SelectedIndex == -1) { return; } StringBuilder builder = new StringBuilder(); LuotKham lk = LuotKhamDAO .getLuotKhamBaseOnDateAndPatient(DateTime.Today.ToString("dd/MM/yyyy") , (DSLuotKhamListView.SelectedItem as BenhNhan).CMND); builder.Append("-----HOA DON THANH TOAN-----"); builder.Append(Environment.NewLine); builder.Append("Thong tin benh nhan"); builder.Append(Environment.NewLine); BenhNhan bn = BenhNhanDAO.getBenhNhan(lk.BenhNhan); builder.Append(">Ho ten: " + bn.HoTen); builder.Append(Environment.NewLine); builder.Append(">So CMND: " + bn.CMND); builder.Append(Environment.NewLine); builder.Append("Thong tin kham benh:"); builder.Append(Environment.NewLine); builder.Append(">Ten benh: " + lk.Benh); builder.Append(Environment.NewLine); builder.Append("Ke toa thuoc:"); builder.Append(Environment.NewLine); ICollection <LuotThuoc> list = lk.LuotThuocs; foreach (LuotThuoc lt in list) { builder.Append(">"); builder.Append(lt.Thuoc); Thuoc thuoc = ThuocDAO.getThuoc(lt.Thuoc); builder.Append(" - "); builder.Append(lt.SoLuong + " " + thuoc.DonVi); builder.Append(" - "); builder.Append(lt.ChiPhi + "VND"); builder.Append(Environment.NewLine); } builder.Append("---------------------------" + Environment.NewLine); builder.Append("Tien kham: " + lk.TienKham); builder.Append(" + Tien thuoc: " + lk.TienThuoc); builder.Append(Environment.NewLine); builder.Append("Tong chi phi: " + lk.ChiPhi); TextDialog dialog = new TextDialog("Hoa don", builder.ToString()); dialog.ShowDialog(); }catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
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); }
public ThemLuotThuocDialog(LuotThuoc lt, bool isObserve) { InitializeComponent(); this.lt = lt; TenThuocLabel.Content = lt.Thuoc; this.isObserve = isObserve; if (isObserve) { AdjustAmountPanel.Visibility = Visibility.Hidden; } Thuoc thuoc = ThuocDAO.getThuoc(lt.Thuoc); DonViLabel.Content = "Don vi tinh: " + thuoc.DonVi; DonGiaLabel.Content = "Don gia: " + thuoc.DonGia; CachDungLabel.Text = "Cach dung: " + thuoc.CachDung; }
public static int addOrUpdateThuoc(string tenthuoc, string donvi, string cachdung, double dongia) { Thuoc thuoc = ThuocDAO.getThuoc(tenthuoc); if (thuoc == null) { thuoc = new QuanLyPhongKham.Thuoc(); } thuoc.TenThuoc = tenthuoc; thuoc.DonVi = donvi; thuoc.DonGia = dongia; thuoc.CachDung = cachdung; int res = ThuocDAO.addOrUpdateThuoc(tenthuoc, thuoc); if (res == 1) { bindingListAllThuoc.Add(thuoc); listAllThuoc.Add(thuoc); } if (res == 0) { foreach (Thuoc t in bindingListAllThuoc) { if (t.TenThuoc.Equals(tenthuoc)) { t.DonVi = donvi; t.DonGia = dongia; t.CachDung = cachdung; } } foreach (Thuoc t in listAllThuoc) { if (t.TenThuoc.Equals(tenthuoc)) { t.DonVi = donvi; t.DonGia = dongia; t.CachDung = cachdung; } } } return(res); }
private void LichSuXemThuocBtn_Click(object sender, RoutedEventArgs e) { ICollection <LuotThuoc> list = LuotKhamDAO .getLuotKham((LichSuKhamListView.SelectedItem as LuotKham).ID).LuotThuocs; StringBuilder builder = new StringBuilder(); builder.Append("Ke toa thuoc: "); builder.Append(Environment.NewLine); foreach (LuotThuoc lt in list) { builder.Append(">"); builder.Append(lt.Thuoc); Thuoc thuoc = ThuocDAO.getThuoc(lt.Thuoc); builder.Append(" - "); builder.Append(lt.SoLuong + " " + thuoc.DonVi); builder.Append(" - "); builder.Append(lt.ChiPhi + " VND"); builder.Append(Environment.NewLine); } TextDialog dialog = new TextDialog("Toa thuoc", builder.ToString()); dialog.ShowDialog(); }