Ejemplo n.º 1
0
 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()); }
 }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool isObserve = false;

            if (Bussiness.currentLuotKhamID == -1)
            {
                isObserve = true;
            }
            LuotThuoc lt = new LuotThuoc();

            lt.LuotKham = Bussiness.currentLuotKhamID;
            lt.Thuoc    = (ThemThuocListView.SelectedItem as Thuoc).TenThuoc;
            ThemLuotThuocDialog dialog = new ThemLuotThuocDialog(lt, isObserve);

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    Bussiness.addLuotThuoc(lt.Thuoc, (int)lt.SoLuong);
                    LuotKham lk = LuotKhamDAO.getLuotKham(Bussiness.currentLuotKhamID);
                    TienKhamTxtBlock.Text          = "Tien kham: " + lk.TienKham.ToString();
                    TienThuocTxtBlock.Text         = "Tien thuoc: " + lk.TienThuoc.ToString();
                    TongChiPhiTxtBlock.Text        = "Tong chi phi: " + lk.ChiPhi.ToString();
                    ThongTinLuotKhamTab.IsSelected = true;
                }
                catch (Exception ex) { MessageBox.Show(ex.ToString()); }
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            Bussiness.removeLuotThuoc((LuotThuocListView.SelectedItem as LuotThuoc).ID);
            LuotKham lk = LuotKhamDAO.getLuotKham(Bussiness.currentLuotKhamID);

            TienKhamTxtBlock.Text   = "Tien kham: " + lk.TienKham.ToString();
            TienThuocTxtBlock.Text  = "Tien thuoc: " + lk.TienThuoc.ToString();
            TongChiPhiTxtBlock.Text = "Tong chi phi: " + lk.ChiPhi.ToString();
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        public static bool removeLuotKham(int ID)
        {
            LuotKham lk = null;

            using (var context = new DataModel())
            {
                lk = context.LuotKhams.Find(ID);
                context.LuotKhams.Remove(lk);
                context.SaveChanges();
            }
            return(lk == null);
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        public static LuotKham getLuotKham(int ID)
        {
            LuotKham lk = null;

            using (var context = new DataModel())
            {
                lk = context.LuotKhams
                     .Include("BenhNhan1")
                     .Include("LuotThuocs")
                     .Include("Benh1")
                     .Where(s => s.ID == ID).FirstOrDefault();
            }
            return(lk);
        }
Ejemplo n.º 10
0
 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()); }
 }
Ejemplo n.º 11
0
        public static void updateLuotKham(int ID, string benh)
        {
            LuotKham lk = LuotKhamDAO.getLuotKham(ID);

            if (lk == null)
            {
                return;
            }
            lk.Benh = benh;
            LuotKhamDAO.updateLuotKham(ID, lk);

            /*foreach (LuotThuoc lt in lk.LuotThuocs)
             * {
             *  LuotKhamDAO.updateLuotKham(ID,lk);
             * }*/
        }
Ejemplo n.º 12
0
        public static bool addLuotKham(LuotKham lk)
        {
            bool res = false;

            using (var context = new DataModel())
            {
                if (getLuotKhamBaseOnDateAndPatient(lk.NgayKham, lk.BenhNhan) == null)
                {
                    try
                    {
                        context.LuotKhams.Add(lk);
                        context.SaveChanges();
                    }
                    catch (Exception e) { System.Windows.MessageBox.Show(e.InnerException.ToString()); }
                    res = true;
                }
            }
            return(res);
        }
Ejemplo n.º 13
0
        public static LuotKham getLuotKhamBaseOnDateAndPatient(String date, String CMND)
        {
            LuotKham         lk   = null;
            IList <LuotKham> list = new List <LuotKham>();

            using (var context = new DataModel())
            {
                list = context.LuotKhams
                       .Include("BenhNhan1")
                       .Include("LuotThuocs")
                       .Include("Benh1")
                       .Where(s => s.NgayKham.Equals(date) && s.BenhNhan.Equals(CMND))
                       .ToList();
                if (list.Any())
                {
                    lk = list.FirstOrDefault();
                }
            }
            return(lk);
        }
Ejemplo n.º 14
0
        public static void updateLuotKham(int ID, LuotKham lk)
        {
            if (ID != lk.ID)
            {
                return;
            }
            LuotKham l = null;

            using (var context = new DataModel())
            {
                l = context.LuotKhams.Find(ID);
                if (l == null)
                {
                    context.LuotKhams.Add(lk);
                }
                else
                {
                    context.Entry(l).CurrentValues.SetValues(lk);
                }
                context.SaveChanges();
            }
        }