Exemplo n.º 1
0
        private void HienThiDonThuoc()
        {
            dsDonThuoc = donThuocBLL.LayThongTinDonThuoc();
            dsBenhNhan = benhnhanBLL.LayThongTinBenhNhan();
            var gridviewInfo = dsDonThuoc
                               .Join(dsBenhNhan, dt => dt.MaBenhNhan, bn => bn.MaBenhNhan, (dt, bn) => new
            {
                MaDonThuoc  = dt.MaDonThuoc,
                NgayKeDon   = dt.NgayKe,
                MoTaBenh    = dt.MoTaBenh,
                TenBenhNhan = bn.TenBenhNhan
            }).ToList();

            bsDonThuoc.DataSource            = gridviewInfo;
            dgvDanhSachDonThuocKD.DataSource = bsDonThuoc;
        }
Exemplo n.º 2
0
 public FormDSBN()
 {
     InitializeComponent();
     bsBN  = new BindingSource();
     bnBLL = new BenhNhanBLL();
     dsBN  = new List <eBenhNhan>();
     dsBN  = bnBLL.LayThongTinBenhNhan();
     HienThiThongTinBenhNhan();
     AutoComplete();
     tbTimKiemBN.Text      = "Nhập mã bệnh nhân";
     tbTimKiemBN.ForeColor = Color.Gray;
 }
Exemplo n.º 3
0
        public UCKeDonThuoc()
        {
            InitializeComponent();
            KhaiBao();
            dsBN = bnBLL.LayThongTinBenhNhan();
            HienThiThongTinThuoc();
            DateTime dt = DateTime.Today;

            lblDate.Text = dt.ToString("dd/MM/yyyy");
            AutoComplete();
            btnHuy.Enabled                  = false;
            btnThem.Enabled                 = false;
            textBoxTimKiemThuocKD.Text      = "Nhập tên thuốc";
            textBoxTimKiemThuocKD.ForeColor = Color.Gray;
            System.Windows.Forms.Form f = System.Windows.Forms.Application.OpenForms["FormKeDonThuoc"];
        }
        private void btnLapHoaDon_Click(object sender, EventArgs e)
        {
            dsHoaDon   = hoadonBLL.LayThongTinHoaDon();
            dsLoThuoc  = loThuocBLL.LayThongTinLoThuoc();
            dsBenhNhan = benhnhanBLL.LayThongTinBenhNhan();
            var timkiemBN = dsBenhNhan.Where(w => w.TenBenhNhan.Equals(txtBenhNhan.Text)).ToList();

            eHoaDon   newHD = new eHoaDon();
            eBenhNhan newBN = new eBenhNhan();

            if (dsHoaDon.Count == 0)
            {
                newHD.MaHoaDon = "1";
            }
            else
            {
                newHD.MaHoaDon = (Convert.ToInt32(dsHoaDon.Last().MaHoaDon) + 1).ToString();
            }

            newHD.MaNhanVien = "1";
            if (timkiemBN.Count == 0)
            {
                newHD.MaBenhNhan  = newBN.MaBenhNhan = (dsBenhNhan.Count + 1).ToString();
                newBN.TenBenhNhan = txtBenhNhan.Text;
                newBN.NamSinh     = Convert.ToInt32(txtNamSinh.Text);
                newBN.SDT         = txtSDT.Text;
                newBN.DiaChi      = cbbTP.Text;
                if (rdNam.Checked == true)
                {
                    newBN.GioiTinh = "nam";
                }
                else
                {
                    newBN.GioiTinh = "nu";
                }
                benhnhanBLL.ThemThongTinBenhNhan(newBN);
            }
            else
            {
                newHD.MaBenhNhan = timkiemBN.First().MaBenhNhan;
            }
            newHD.NgayLapHD  = DateTime.Now;
            newHD.TongTien   = Convert.ToDecimal(lblTongTien.Text);
            newHD.MaDonThuoc = null;
            hoadonBLL.ThemThongTinHoaDon(newHD);

            for (int i = 0; i < dgvThuocDaChon.Rows.Count; i++)
            {
                var       loThuocTimKiem = dsLoThuoc.Where(w => w.MaLoThuoc.Equals(dgvThuocDaChon.Rows[i].Cells["MaLoThuoc"].Value.ToString()));
                eCTHoaDon newCTHD        = new eCTHoaDon();
                if (dsHoaDon.Count == 0)
                {
                    newCTHD.MaHoaDon = "1";
                }
                else
                {
                    newCTHD.MaHoaDon = (Convert.ToInt32(dsHoaDon.Last().MaHoaDon) + 1).ToString();
                }
                newCTHD.MaLoThuoc = dgvThuocDaChon.Rows[i].Cells["MaLoThuoc"].Value.ToString();
                newCTHD.DVT       = dgvThuocDaChon.Rows[i].Cells["DVT"].Value.ToString();
                newCTHD.SoLuong   = Convert.ToInt32((dgvThuocDaChon.Rows[i].Cells["soluongcol"].Value));
                newCTHD.GiaBan    = Convert.ToDecimal((dgvThuocDaChon.Rows[i].Cells["dongiacol"].Value));
                loThuocBLL.CapNhatSoLuongLoThuoc(dgvThuocDaChon.Rows[i].Cells["MaLoThuoc"].Value.ToString(), loThuocTimKiem.First().SoLuong - Convert.ToInt32((dgvThuocDaChon.Rows[i].Cells["soluongcol"].Value)));
                cthdBLL.ThemThongTinCTHoaDon(newCTHD);
            }
            MessageBox.Show("Tao Hoa Don Thanh Cong");
            LoadSauKhiLapHD();
            HienThiLoThuoc();
        }