private void LichSuXemBNBtn_Click(object sender, RoutedEventArgs e) { BenhNhan bn = LuotKhamDAO.getLuotKham((LichSuKhamListView.SelectedItem as LuotKham).ID).BenhNhan1; ThemLuotKhamDialog dialog = new ThemLuotKhamDialog(bn, 2); dialog.ShowDialog(); }
private void KhamBenhBtn_Click(object sender, RoutedEventArgs e) { try { if (DSLuotKhamListView.SelectedIndex == -1) { return; } ThongTinLuotKhamTab.IsEnabled = true; BenhNhan bn = DSLuotKhamListView.SelectedItem as BenhNhan; LuotKham lk = LuotKhamDAO.getLuotKhamBaseOnDateAndPatient(DateTime.Today.ToString("dd/MM/yyyy"), bn.CMND); Bussiness.currentLuotKhamID = -1; BenhComboBox.SelectedItem = lk.Benh; Bussiness.currentLuotKhamID = lk.ID; LuotKhamIDLabel.Content = "ID: " + lk.ID; BenhComboBox.SelectedItem = lk.Benh; if (!lk.Benh.Equals("")) { Benh b = BenhDAO.getBenh(lk.Benh); TrieuChungTxtBlock.Text = b.TrieuChung; } TienKhamTxtBlock.Text = "Tien kham: " + lk.TienKham.ToString(); TienThuocTxtBlock.Text = "Tien thuoc: " + lk.TienThuoc.ToString(); TongChiPhiTxtBlock.Text = "Tong chi phi: " + lk.ChiPhi.ToString(); UserInfoTxtBlock.Text = bn.HoTen; Bussiness.listLuotThuoc.Clear(); foreach (LuotThuoc lt in lk.LuotThuocs) { Bussiness.listLuotThuoc.Add(lt); } ThongTinLuotKhamTab.IsSelected = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// /// </summary> /// <param name="CMND"></param> /// <param name="benhnhan"></param> /// <returns>-1:loi, 0:update, 1:them</returns> public static int addOrUpdateBenhNhan(String CMND, BenhNhan benhnhan) { if (CMND != benhnhan.CMND) { return(-1); } BenhNhan bn = null; int res = 0; using (var context = new DataModel()) { bn = context.BenhNhans.Find(CMND); if (bn == null) { res = 1; context.BenhNhans.Add(benhnhan); } else { context.Entry(bn).CurrentValues.SetValues(benhnhan); } context.SaveChanges(); } return(res); }
public ThemLuotKhamDialog(BenhNhan benhnhan, int isUpdate) { InitializeComponent(); bn = benhnhan; if (isUpdate > 0) { CMNDTxt.IsReadOnly = true; if (isUpdate > 1) { HoTenTxt.IsReadOnly = true; DiaChiTxt.IsReadOnly = true; SDTTxt.IsReadOnly = true; NamRadioBtn.IsEnabled = false; NuRadioBtn.IsEnabled = false; OKPanel.Visibility = Visibility.Hidden; } } else { CMNDTxt.IsEnabled = true; } CMNDTxt.Text = benhnhan.CMND; HoTenTxt.Text = benhnhan.HoTen; DiaChiTxt.Text = benhnhan.DiaChi; SDTTxt.Text = benhnhan.SDT; if (benhnhan.GioiTinh == 1) { NamRadioBtn.IsChecked = true; } else { NuRadioBtn.IsChecked = 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 int addOrUpdateBenhNhan(string CMND, string hoten, string sdt, string diachi, byte gioitinh) { BenhNhan bn = BenhNhanDAO.getBenhNhan(CMND); foreach (BenhNhan b in listBenhNhan) { if (b.CMND.Equals(CMND)) { b.hoten1 = hoten; b.sdt1 = sdt; b.diachi1 = diachi; b.gioitinh1 = gioitinh; } } if (bn == null) { bn = new BenhNhan(); } bn.CMND = CMND; bn.HoTen = hoten; bn.SDT = sdt; bn.DiaChi = diachi; bn.GioiTinh = gioitinh; return(BenhNhanDAO.addOrUpdateBenhNhan(CMND, bn)); }
public static BenhNhan getBenhNhan(String CMND) { BenhNhan bn = null; using (var context = new DataModel()) { bn = context.BenhNhans.Find(CMND); } return(bn); }
private void LuotKhamRemoveBtn_Click(object sender, RoutedEventArgs e) { if (DSLuotKhamListView.SelectedIndex == -1) { return; } resetLuotKhamTab(); BenhNhan bn = DSLuotKhamListView.SelectedItem as BenhNhan; LuotKham lk = LuotKhamDAO.getLuotKhamBaseOnDateAndPatient(DateTime.Today.ToString("dd/MM/yyyy"), bn.CMND); Bussiness.removeLuotKham(lk.ID); }
public static bool removeBenhNhan(String CMND) { BenhNhan benhnhan = null; using (var context = new DataModel()) { benhnhan = context.BenhNhans.Find(CMND); context.BenhNhans.Remove(benhnhan); context.SaveChanges(); } return(benhnhan == null); }
public static bool addLuotKham(string benhnhan, string ngaykham) { LuotKham lk = new LuotKham(); BenhNhan bn = BenhNhanDAO.getBenhNhan(benhnhan); lk.BenhNhan = benhnhan; lk.TienKham = tienKham; lk.TienThuoc = 0; lk.NgayKham = ngaykham; lk.ID = currentLKID++; listBenhNhan.Add(bn); return(LuotKhamDAO.addLuotKham(lk)); }
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()); } }
private void UpdateUserInfoBtn_Click(object sender, RoutedEventArgs e) { BenhNhan bn = LuotKhamDAO.getLuotKham(Bussiness.currentLuotKhamID).BenhNhan1; ThemLuotKhamDialog dialog = new ThemLuotKhamDialog(bn, 1); if (dialog.ShowDialog() == true) { Bussiness.addOrUpdateBenhNhan(bn.CMND, bn.HoTen, bn.SDT, bn.DiaChi, (byte)bn.GioiTinh); UserInfoTxtBlock.Text = bn.HoTen; foreach (BenhNhan b in Bussiness.listBenhNhan) { if (b.CMND.Equals(bn.CMND)) { b.diachi1 = bn.DiaChi; b.sdt1 = bn.SDT; b.gioitinh1 = (byte)bn.GioiTinh; b.hoten1 = bn.HoTen; } } } }
private void ThemBenhNhanBtn_Click(object sender, RoutedEventArgs e) { if (Bussiness.listBenhNhan.Count > Bussiness.gioiHanLuotKham) { MessageBox.Show("So luong ca kham hom nay da vuot qua gioi han!"); return; } BenhNhan bn = new BenhNhan(); ThemLuotKhamDialog dialog = new ThemLuotKhamDialog(bn, 0); if (dialog.ShowDialog() == true) { foreach (BenhNhan b in Bussiness.listBenhNhan) { if (b.CMND.Equals(bn.CMND)) { MessageBox.Show("Benh nhan nay da duoc kham trong hom nay!"); return; } } Bussiness.addOrUpdateBenhNhan(bn.CMND, bn.HoTen, bn.SDT, bn.DiaChi, (byte)bn.GioiTinh); Bussiness.addLuotKham(bn.CMND, DateTime.Today.ToString("dd/MM/yyyy")); } }