Ejemplo n.º 1
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.º 2
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.º 3
0
        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>();
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        private void LichSuXemBenhBtn_Click(object sender, RoutedEventArgs e)
        {
            Benh           b      = LuotKhamDAO.getLuotKham((LichSuKhamListView.SelectedItem as LuotKham).ID).Benh1;
            ThemBenhDialog dialog = new ThemBenhDialog(b, true);

            dialog.ShowDialog();
        }
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
0
 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();
     }
 }
Ejemplo n.º 10
0
        public static void getLichSuKham(string date)
        {
            listLuotKhamTrongNgay.Clear();
            IList <LuotKham> list = LuotKhamDAO.getLuotKhamOfDate(date);

            for (int i = 0; i < list.Count; i++)
            {
                listLuotKhamTrongNgay.Add(list.ElementAt(i));
            }
        }
Ejemplo n.º 11
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.º 12
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.º 13
0
        public static bool getThongKeDoanhThu(string month)
        {
            IList <LuotKham> list = LuotKhamDAO.getLuotKhamOfMonth(month);

            listThongKeLuotkham.Clear();
            string[] tokens;
            int      year;

            try
            {
                tokens = month.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                if (tokens[0].Count() != 2 || tokens[1].Count() != 4)
                {
                    throw new Exception();
                }
                int temp = int.Parse(tokens[0]);
                if (temp < 1 || temp > 12)
                {
                    throw new Exception();
                }
                year = int.Parse(tokens[1]);
            }
            catch (Exception e) { MessageBox.Show("Thang khong hop le!"); return(false); }
            if (!list.Any())
            {
                MessageBox.Show("Khong co du lieu trong thang nay!");
                return(false);
            }
            int days = daysOfMonth.ElementAt(int.Parse(tokens[0]) - 1);

            if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) && tokens[0].Equals("02"))
            {
                days++;
            }

            for (int i = 1; i <= days; i++)
            {
                string day = i.ToString();
                if (day.Count() == 1)
                {
                    day = "0" + day;
                }
                string          date = day + "/" + month;
                ThongKeLuotKham tklk = new ThongKeLuotKham(date);
                tklk.getData(list);
                listThongKeLuotkham.Add(tklk);
            }
            return(true);
        }
Ejemplo n.º 14
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.º 15
0
        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);
        }
Ejemplo n.º 16
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.º 17
0
        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;
                    }
                }
            }
        }
Ejemplo n.º 18
0
        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();
        }