/// <summary>
        /// Load report data from DB
        /// </summary>
        /// <param name="pickedMonth"></param>
        /// <param name="pickedYear"></param>
        private bool LoadReport(int pickedMonth, int pickedYear)
        {
            DS_DoanhThu.Clear();

            using (var dc = new QLPM_ModelDataContext())
            {
                if (CanGetReport && PickedMonth > 0 && PickedYear > 0)
                {
                    var total = (from hd in dc.HOADONs
                                 where hd.PHIEUKHAMBENH.NgayKham.Month == pickedMonth &&
                                 hd.PHIEUKHAMBENH.NgayKham.Year == pickedYear
                                 select hd).Sum(x => x.TienKham + x.TienThuoc);

                    (from hd in dc.HOADONs
                     where hd.PHIEUKHAMBENH.NgayKham.Month == pickedMonth &&
                     hd.PHIEUKHAMBENH.NgayKham.Year == pickedYear
                     group hd by hd.PHIEUKHAMBENH.NgayKham into g
                     select new DOANHTHUNGAY
                    {
                        Ngay = g.Key,
                        SoBenhNhan = g.Count(),
                        DoanhThu = g.Sum(i => i.TienKham + i.TienThuoc)
                    }).ToList().ForEach(x => {
                        x.TiLe = Math.Round((double)(x.DoanhThu / total) * 100, 1);
                        DS_DoanhThu.Add(x);
                    });
                }
            }
            return(DS_DoanhThu.Count != 0 ? true : false);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Getting data from DB
 /// </summary>
 private void GetData()
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.NHANVIENs.Select(x => x).ToList().ForEach(x => DS_NV.Add(x));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Getting data from DB
 /// </summary>
 /// <returns></returns>
 private void ReadList(DateTime datePicked)
 {
     if (DS_KhamBenh.Count == 0)
     {
         // Getting data from DB (if exists)
         using (var dc = new QLPM_ModelDataContext())
         {
             var query = (from pk in dc.PHIEUKHAMBENHs
                          where pk.NgayKham == datePicked
                          select pk.Ma_BenhNhan).ToList();
             if (query.Count > 0)
             {
                 foreach (var item in query)
                 {
                     DS_KhamBenh.Add((BENHNHAN)(from bn in dc.HOSOBENHNHANs
                                                where bn.Ma_BenhNhan == item
                                                select bn).FirstOrDefault());
                 }
             }
         }
         ViewSource = (CollectionView)CollectionViewSource.GetDefaultView(DS_KhamBenh);
     }
     else
     {
         ViewSource = (CollectionView)CollectionViewSource.GetDefaultView(DS_KhamBenh);
     }
 }
Exemplo n.º 4
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         return(dc.BENHs.Single(x => x.Ma_Benh == value.ToString()).TenBenh);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Load report data from DB
        /// </summary>
        /// <param name="pickedMonth"></param>
        /// <param name="pickedYear"></param>
        /// <returns></returns>
        private bool LoadReport(int pickedMonth, int pickedYear)
        {
            DS_DungThuoc.Clear();

            using (var dc = new QLPM_ModelDataContext())
            {
                if (CanGetReport && PickedMonth1 > 0 && PickedYear1 > 0)
                {
                    (from pk in dc.CT_PHIEUKHAMBENHs
                     where pk.PHIEUKHAMBENH.NgayKham.Month == pickedMonth &&
                     pk.PHIEUKHAMBENH.NgayKham.Year == pickedYear
                     group pk by new { pk.THUOC.TenThuoc, pk.Ma_Thuoc } into g
                     select new SUDUNGTHUOC
                    {
                        Ma_Thuoc = g.Key.Ma_Thuoc,
                        TenThuoc = g.Key.TenThuoc,
                        SoLanDung = g.Count()
                    }).ToList().ForEach(x =>
                    {
                        x.SoLuong  = dc.CT_PHIEUKHAMBENHs.Where(y => y.Ma_Thuoc == x.Ma_Thuoc).Sum(z => z.SoLuong);
                        x.TenDonVi = dc.THUOCs.Single(y => x.Ma_Thuoc == y.Ma_Thuoc).DONVI.TenDonVi;
                        DS_DungThuoc.Add(x);
                    });
                }
            }
            return(DS_DungThuoc.Count != 0 ? true : false);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Add a CT_PHIEUKHAM to DB
 /// </summary>
 /// <param name="ct"></param>
 public static void AddPill(CT_PHIEUKHAMBENH ct)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.CT_PHIEUKHAMBENHs.InsertOnSubmit(ct);
         dc.SubmitChanges();
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Delete a HOADON
 /// </summary>
 /// <param name="pk"></param>
 public static void RemoveHoaDon(PHIEUKHAM pk)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.HOADONs.DeleteOnSubmit(dc.HOADONs.Single(hd => hd.Ma_PhieuKham == pk.Ma_PhieuKham));
         dc.SubmitChanges();
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Remove a benhnhan obj from database
 /// </summary>
 /// <param name="bn"></param>
 public static void RemoveBenhNhan(BENHNHAN bn)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.HOSOBENHNHANs.DeleteOnSubmit((HOSOBENHNHAN)bn);
         dc.SubmitChanges();
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Add a new benhnhan obj to database
 /// </summary>
 /// <param name="bn">BenhNhan</param>
 public static void AddBenhNhan(BENHNHAN bn)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.HOSOBENHNHANs.InsertOnSubmit((HOSOBENHNHAN)bn);
         dc.SubmitChanges();
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Delete a CT_PHIEUKHAM from DB
 /// </summary>
 /// <param name="ct"></param>
 public static void RemovePill(CT_PHIEUKHAMBENH ct)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.CT_PHIEUKHAMBENHs.DeleteOnSubmit(ct);
         dc.SubmitChanges();
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Get the limit of patients in a day from db
 /// </summary>
 /// <returns></returns>
 public static int GetMaximumPatientToday()
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         return((from ts in dc.THAMSOs
                 select ts.SLBenhNhan).FirstOrDefault());
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Get the examination fee from db
 /// </summary>
 /// <returns></returns>
 public static decimal GetExaminationFee()
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         return((from ts in dc.THAMSOs
                 select ts.TienKham).FirstOrDefault());
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Saving a new NV to DB
 /// </summary>
 /// <param name="nv"></param>
 public void SaveNewNV(NHANVIEN nv)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.NHANVIENs.InsertOnSubmit(nv);
         dc.SubmitChanges();
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Save new data to DB
 /// </summary>
 /// <param name="hoso"></param>
 public void SaveNewHoSo(HOSOBENHNHAN hoso)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.HOSOBENHNHANs.InsertOnSubmit(hoso);
         dc.SubmitChanges();
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// Load list of profiles from DB
 /// </summary>
 private void LoadDS_HoSo()
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         (from hs in dc.HOSOBENHNHANs
          select hs).ToList().ForEach(x => DS_HoSo.Add(x));
     }
     ViewSource = (CollectionView)CollectionViewSource.GetDefaultView(DS_HoSo);
 }
Exemplo n.º 16
0
 private void LoadLists()
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.THUOCs.Select(x => x).ToList().ForEach(x => DS_Thuoc.Add(x));
         dc.CACHDUNGs.Select(x => x).ToList().ForEach(x => DS_CachDung.Add(x));
     }
     ViewSource.Refresh();
 }
Exemplo n.º 17
0
 /// <summary>
 /// Getting data from DB, criteria: maBenhNhan
 /// </summary>
 /// <param name="maBenhNhan"></param>
 private void ReadList(string maBenhNhan)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         (from pk in dc.PHIEUKHAMBENHs
          where pk.Ma_BenhNhan == maBenhNhan
          select pk).ToList().ForEach(x => DS_PhieuKham.Add((PHIEUKHAM)x));
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Getting data from DB, criteria: date.today
 /// </summary>
 /// <returns></returns>
 private void ReadList(DateTime datePicked)
 {
     DS_PhieuKham.Clear();
     // Getting data from DB (if exists)
     using (var dc = new QLPM_ModelDataContext())
     {
         (from pk in dc.PHIEUKHAMBENHs
          where pk.NgayKham == datePicked
          select pk).ToList().ForEach(x => DS_PhieuKham.Add((PHIEUKHAM)x));
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// Remove a PHIEUKHAMBENH from DB
        /// </summary>
        /// <param name="bn"></param>
        public static void RemovePhieuKham(BENHNHAN bn)
        {
            using (var dc = new QLPM_ModelDataContext())
            {
                var phieukham = dc.PHIEUKHAMBENHs.Single(pk => pk.Ma_BenhNhan == bn.Ma_BenhNhan && pk.NgayKham == DateTime.Today);

                dc.CT_PHIEUKHAMBENHs.DeleteAllOnSubmit(dc.CT_PHIEUKHAMBENHs.Where(ctpk => ctpk.Ma_PhieuKham == phieukham.Ma_PhieuKham));
                dc.PHIEUKHAMBENHs.DeleteOnSubmit(phieukham);
                dc.SubmitChanges();
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Getting diseases from DB
 /// </summary>
 private void ReadDiseases()
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         (from b in dc.BENHs
          select b).ToList().ForEach(x =>
         {
             DS_Benh.Add(x);
         });
     }
 }
Exemplo n.º 21
0
        private void GetBills()
        {
            DS_HoaDon.Clear();

            using (var dc = new QLPM_ModelDataContext())
            {
                (from hd in dc.HOADONs
                 where hd.PHIEUKHAMBENH.NgayKham == DateTime.Today
                 select hd).ToList().ForEach(x => DS_HoaDon.Add((CTHOADON)x));
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// Create a new PHIEUKHAMBENH after add a BENHNHAN to DSKHAMBENH
 /// </summary>
 /// <param name="bn"></param>
 public static void AddPhieuKham(BENHNHAN bn)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         var pk = new PHIEUKHAMBENH();
         pk.Ma_PhieuKham = GetNewID(pk);
         pk.Ma_BenhNhan  = bn.Ma_BenhNhan;
         pk.NgayKham     = DateTime.Today;
         dc.PHIEUKHAMBENHs.InsertOnSubmit(pk);
         dc.SubmitChanges();
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// Load Data from DB
 /// </summary>
 /// <param name="maBenhNhan"></param>
 private void GetData(string maBenhNhan)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         dc.PHIEUKHAMBENHs.Where(x => x.Ma_BenhNhan == maBenhNhan).ToList().ForEach(x =>
         {
             DS_PhieuKham.Add(new CTTRACUU()
             {
                 PhieuKham = (PHIEUKHAM)x,
                 HoaDon    = (CTHOADON)(x.HOADONs.Single(y => y.Ma_PhieuKham == x.Ma_PhieuKham))
             });
         });
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Load lists
        /// </summary>
        private void LoadLists()
        {
            if (CanGetReport)
            {
                ListMonth1.Clear();
                ListYear1.Clear();
                using (var dc = new QLPM_ModelDataContext())
                {
                    (from m in dc.CT_PHIEUKHAMBENHs
                     group m by m.PHIEUKHAMBENH.NgayKham.Month into g
                     select g.Key).ToList().ForEach(x => ListMonth1.Add(x));

                    (from m in dc.CT_PHIEUKHAMBENHs
                     group m by m.PHIEUKHAMBENH.NgayKham.Year into g
                     select g.Key).ToList().ForEach(x => ListYear1.Add(x));
                }
            }
        }
Exemplo n.º 25
0
 private void GetResultBySymtom(string trieuChung)
 {
     using (var dc = new QLPM_ModelDataContext())
     {
         var query = (from pk in dc.PHIEUKHAMBENHs
                      join bn in dc.HOSOBENHNHANs on pk.Ma_BenhNhan equals bn.Ma_BenhNhan
                      join be in dc.BENHs on pk.Ma_Benh equals be.Ma_Benh
                      where pk.TrieuChung == trieuChung
                      select new
         {
             pk.Ma_PhieuKham,
             bn.Ma_BenhNhan,
             bn.Hoten,
             pk.NgayKham,
             be.TenBenh,
             pk.TrieuChung
         }).ToList();
         ViewSource = (CollectionView)CollectionViewSource.GetDefaultView(query);
     }
 }
Exemplo n.º 26
0
        /// <summary>
        /// Getting all the records from DB
        /// </summary>
        private void GetList()
        {
            LookUpList = new ObservableCollection <RECORD>();

            using (var dc = new QLPM_ModelDataContext())
            {
                (from pk in dc.PHIEUKHAMBENHs
                 join bn in dc.HOSOBENHNHANs on pk.Ma_BenhNhan equals bn.Ma_BenhNhan
                 join be in dc.BENHs on pk.Ma_Benh equals be.Ma_Benh
                 select new RECORD
                {
                    Ma_BenhNhan = bn.Ma_BenhNhan,
                    HoTen = bn.Hoten,
                    NgayKham = pk.NgayKham,
                    TenBenh = be.TenBenh,
                    TrieuChung = pk.TrieuChung
                }).ToList().ForEach(x => LookUpList.Add(x));

                ViewSource = (CollectionView)CollectionViewSource.GetDefaultView(LookUpList);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Add a HOADON to DB
        /// </summary>
        /// <param name="pk"></param>
        public static void AddHoaDon(PHIEUKHAM pk)
        {
            using (var dc = new QLPM_ModelDataContext())
            {
                if (dc.HOADONs.Any(x => x.Ma_PhieuKham == pk.Ma_PhieuKham))
                {
                    var hd = dc.HOADONs.Single(x => x.Ma_PhieuKham == pk.Ma_PhieuKham);

                    if (pk.DONTHUOC.Count > 0)
                    {
                        foreach (var item in pk.DONTHUOC)
                        {
                            hd.TienThuoc += item.SoLuong * item.DonGia;
                        }
                    }

                    dc.SubmitChanges();
                }
                else
                {
                    var hd = new HOADON();
                    hd.Ma_HoaDon    = GetNewID(hd);
                    hd.Ma_PhieuKham = pk.Ma_PhieuKham;
                    hd.TienKham     = (from ts in dc.THAMSOs
                                       select ts.TienKham).FirstOrDefault();

                    if (pk.DONTHUOC.Count > 0)
                    {
                        foreach (var item in pk.DONTHUOC)
                        {
                            hd.TienThuoc += item.SoLuong * item.DonGia;
                        }
                    }

                    dc.HOADONs.InsertOnSubmit(hd);
                    dc.SubmitChanges();
                }
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Read the script from an Ma_PhieuKham
        /// </summary>
        /// <param name="ma_PhieuKham"></param>
        /// <returns></returns>
        private ObservableCollection <CT_DONTHUOC> ReadScript(string ma_PhieuKham)
        {
            var donthuoc = new ObservableCollection <CT_DONTHUOC>();

            using (var dc = new QLPM_ModelDataContext())
            {
                (from ctpk in dc.CT_PHIEUKHAMBENHs
                 join t in dc.THUOCs on ctpk.Ma_Thuoc equals t.Ma_Thuoc
                 join cd in dc.CACHDUNGs on ctpk.Ma_CachDung equals cd.Ma_CachDung
                 where ctpk.Ma_PhieuKham == ma_PhieuKham
                 select new CT_DONTHUOC()
                {
                    Ma_PhieuKham = ctpk.Ma_PhieuKham,
                    Ma_Thuoc = ctpk.Ma_Thuoc,
                    TenThuoc = t.TenThuoc,
                    Ma_CachDung = ctpk.Ma_CachDung,
                    TenCachDung = cd.TenCachDung,
                    DonGia = ctpk.DonGia,
                    GhiChu = ctpk.GhiChu
                }).ToList().ForEach(x => donthuoc.Add(x));
            }
            return(donthuoc);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Get a new ID depends on type of the object
        /// </summary>
        /// <typeparam name="T">Type of object</typeparam>
        /// <param name="obj">Object to be getting a new ID</param>
        /// <returns></returns>
        public static string GetNewID <T>(T obj)
        {
            var ID = "";

            using (var dc = new QLPM_ModelDataContext())
            {
                switch (obj.GetType().Name)
                {
                case "HOSOBENHNHAN":
                    if (dc.HOSOBENHNHANs.Count() == 0)
                    {
                        ID = "P000";
                    }
                    else
                    {
                        ID = "P" + (int.Parse(dc.HOSOBENHNHANs.ToArray().Last().Ma_BenhNhan.Substring(1)) + 1).ToString("000");
                    }
                    break;

                case "BENH":
                    if (dc.BENHs.Count() == 0)
                    {
                        ID = "D000";
                    }
                    else
                    {
                        ID = "D" + (int.Parse(dc.BENHs.ToArray().Last().Ma_Benh.Substring(1)) + 1).ToString("000");
                    }
                    break;

                case "NHANVIEN":
                    if (dc.NHANVIENs.Count() == 0)
                    {
                        ID = "E000";
                    }
                    else
                    {
                        ID = "E" + (int.Parse(dc.NHANVIENs.ToArray().Last().Ma_NV.Substring(1)) + 1).ToString("000");
                    }
                    break;

                case "HOADON":
                    if (dc.HOADONs.Count() == 0)
                    {
                        ID = "B000";
                    }
                    else
                    {
                        ID = "B" + (int.Parse(dc.HOADONs.ToArray().Last().Ma_HoaDon.Substring(1)) + 1).ToString("000");
                    }
                    break;

                case "PHIEUKHAMBENH":
                    if (dc.PHIEUKHAMBENHs.Count() == 0)
                    {
                        ID = "R000";
                    }
                    else
                    {
                        ID = "R" + (int.Parse(dc.PHIEUKHAMBENHs.ToArray().Last().Ma_PhieuKham.Substring(1)) + 1).ToString("000");
                    }
                    break;

                case "PHIEUNHAP":
                    if (dc.PHIEUNHAPTHUOCs.Count() == 0)
                    {
                        ID = "I000";
                    }
                    else
                    {
                        ID = "I" + (int.Parse(dc.PHIEUNHAPTHUOCs.ToArray().Last().Ma_PhieuNhap.Substring(1)) + 1).ToString("000");
                    }
                    break;

                case "THUOC":
                    if (dc.THUOCs.Count() == 0)
                    {
                        ID = "P000";
                    }
                    else
                    {
                        ID = "P" + (int.Parse(dc.THUOCs.ToArray().Last().Ma_Thuoc.Substring(1)) + 1).ToString("000");
                    }
                    break;

                case "DONVI":
                    if (dc.DONVIs.Count() == 0)
                    {
                        ID = "U000";
                    }
                    else
                    {
                        ID = "U" + (int.Parse(dc.DONVIs.ToArray().Last().Ma_DonVi.Substring(1)) + 1).ToString("000");
                    }
                    break;

                case "CACHDUNG":
                    if (dc.CACHDUNGs.Count() == 0)
                    {
                        ID = "T000";
                    }
                    else
                    {
                        ID = "T" + (int.Parse(dc.CACHDUNGs.ToArray().Last().Ma_CachDung.Substring(1)) + 1).ToString("000");
                    }
                    break;

                default:
                    break;
                }
            }

            return(ID);
        }