private void btnlapphieukham_Click(object sender, EventArgs e) { pkbdto = new PhieuKhamBenhDTO(); pkbdto.MaBenhNhan = lblmabenhnhan.Text.ToString(); pkbdto.NgayKham = dtimengaykham.Text.ToString(); pkbdto.TrieuChung = txttrieuchung.Text.ToString(); pkbdto.MaLoaiBenh = int.Parse(cbloaibenhchinh.SelectedValue.ToString()); pkbdto.MaLoaiBenhPhu = int.Parse(cbloaibenhphu.SelectedValue.ToString()); if (pkbbus.insert(pkbdto) > 0) { btnlapphieukham.Enabled = false; btnsuaphieukham.Enabled = true; btninphieukham.Enabled = true; grlaythuoc.Enabled = true; bnbus.showBNChuaLapPhieuKham(lvdsbenhnhan, bnbus.getListByDSKB(dtimengaykham.Text.ToString(), "in"), dtimengaykham.Text.ToString()); } }
public int insert(PhieuKhamBenhDTO bn) { if (((bn.MaLoaiBenh == bn.MaLoaiBenhPhu)&&bn.MaLoaiBenh!=1) || (bn.MaLoaiBenhPhu != 1 && bn.MaLoaiBenh == 1)) { MessageBox.Show(" Lựa chọn loại bệnh và loại bệnh phụ chưa hợp lệ !"); return 0; } else { bn.MaPhieuKhamBenh = bn.MaBenhNhan + bn.NgayKham; int result = dvdao.insert(bn); if (result > 0) MessageBox.Show(" Lập phiếu khám bệnh thành công !"); else MessageBox.Show(" Lập phiếu khám bệnh thất bại !"); return result; } }
// public PhieuKhamBenhDTO getByPrimaryKey(string maphieukham) { PhieuKhamBenhDTO pkb = new PhieuKhamBenhDTO(); string sql = " select * from PHIEUKHAMBENH Where MaPhieuKhamBenh=@MaPhieuKhamBenh "; SqlParameter sp = new SqlParameter("@MaPhieuKhamBenh", maphieukham); DataTable dt = new DataTable(); dt = conectData.LoadData(sql,sp); if (dt == null || dt.Rows.Count == 0) return null; else { pkb.MaPhieuKhamBenh= dt.Rows[0]["MaPhieuKhamBenh"].ToString(); pkb.MaBenhNhan = dt.Rows[0]["MaBenhNhan"].ToString(); pkb.NgayKham= dt.Rows[0]["NgayKham"].ToString(); pkb.TrieuChung =dt.Rows[0]["TrieuChung"].ToString(); pkb.MaLoaiBenh = int.Parse(dt.Rows[0]["MaLoaiBenh"].ToString()); pkb.MaLoaiBenhPhu = int.Parse(dt.Rows[0]["MaLoaiBenhPhu"].ToString()); } return pkb; }
// list of phieu kham by NgayKham và chua co trong hoa don. public PhieuKhamBenhDTO[] getListByBenhNhan(string mabn) { PhieuKhamBenhDTO[] list; string sql = "select * from PHIEUKHAMBENH where MaBenhNhan=@mabenhnhan"; DataTable dt = new DataTable(); SqlParameter sp = new SqlParameter("@mabenhnhan", mabn); dt = conectData.LoadData(sql, sp); if (dt == null || dt.Rows.Count == 0) return null; else { list = new PhieuKhamBenhDTO[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { list[i] = new PhieuKhamBenhDTO(); list[i].MaBenhNhan = dt.Rows[i]["MaBenhNhan"].ToString(); list[i].NgayKham = dt.Rows[i]["NgayKham"].ToString(); list[i].TrieuChung = dt.Rows[i]["TrieuChung"].ToString(); list[i].MaLoaiBenh = int.Parse(dt.Rows[i]["MaLoaiBenh"].ToString()); list[i].MaLoaiBenhPhu = int.Parse(dt.Rows[i]["MaLoaiBenhPhu"].ToString()); } } return list; }
// list of phieu kham by NgayKham và chua co trong hoa don. public PhieuKhamBenhDTO[] getListByNgayKham(string ngaykham) { PhieuKhamBenhDTO[] list; string sql = " select MaBenhNhan from PHIEUKHAMBENH where NgayKham=@NgayKham and MaBenhNhan in (select substring(MaPhieuKhamBenh,1,5) from HOADON where substring(MaPhieuKhamBenh,6,10)=@NgayKham)"; DataTable dt = new DataTable(); SqlParameter sp = new SqlParameter("@NgayKham", ngaykham); dt = conectData.LoadData(sql, sp); if (dt == null || dt.Rows.Count == 0) return null; else { list = new PhieuKhamBenhDTO[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { list[i] = new PhieuKhamBenhDTO(); list[i].MaBenhNhan = dt.Rows[i]["MaBenhNhan"].ToString(); } } return list; }
public int update(PhieuKhamBenhDTO cd) { string sql = "update PHIEUKHAMBENH set TrieuChung=@TrieuChung, MaLoaiBenh=@MaLoaiBenh,MaLoaiBenhPhu=@MaLoaiBenhPhu where MaPhieuKhamBenh=@MaPhieuKham"; SqlParameter[] sp = new SqlParameter[4]; sp[0] = new SqlParameter("@TrieuChung", cd.TrieuChung); sp[1] = new SqlParameter("@MaLoaiBenh", cd.MaLoaiBenh); sp[2] = new SqlParameter("@MaLoaiBenhPhu", cd.MaLoaiBenhPhu); sp[3] = new SqlParameter("@MaPhieuKham", cd.MaPhieuKhamBenh); return conectData.Insert_Update_Delete(sql, sp); }
public int insert(PhieuKhamBenhDTO cd) { string sql = "insert into PHIEUKHAMBENH values (@MaPhieuKhamBenh,@MaBenhNhan,@NgayKham,@TrieuChung,@MaLoaiBenh,@MaLoaiBenhPhu)"; SqlParameter[] sp = new SqlParameter[6]; sp[0] = new SqlParameter("@MaPhieuKhamBenh", cd.MaPhieuKhamBenh); sp[1] = new SqlParameter("@MaBenhNhan", cd.MaBenhNhan); sp[2] = new SqlParameter("@NgayKham", cd.NgayKham); sp[3] = new SqlParameter("@TrieuChung", cd.TrieuChung); sp[4] = new SqlParameter("@MaLoaiBenh", cd.MaLoaiBenh); sp[5] = new SqlParameter("@MaLoaiBenhPhu", cd.MaLoaiBenhPhu); try { return conectData.Insert_Update_Delete(sql, sp); } catch { return -2; } }
private void btnsuaphieukham_Click(object sender, EventArgs e) { pkbdto = new PhieuKhamBenhDTO(); pkbdto.MaBenhNhan = lblmabenhnhan.Text.ToString(); pkbdto.NgayKham = dtimengaykham.Text.ToString(); pkbdto.TrieuChung = txttrieuchung.Text.ToString(); pkbdto.MaLoaiBenh = int.Parse(cbloaibenhchinh.SelectedValue.ToString()); pkbdto.MaLoaiBenhPhu = int.Parse(cbloaibenhphu.SelectedValue.ToString()); pkbbus.update(pkbdto); }
private void lvdsbenhnhan_SelectedIndexChanged(object sender, EventArgs e) { lvdonthuocganday.Items.Clear(); expandablePanel1.Expanded = false; cmbloaithuoc_SelectedIndexChanged(sender, e); if (this.lvdsbenhnhan.SelectedItems.Count > 0) { pkbdto = new PhieuKhamBenhDTO(); ListViewItem lvi = this.lvdsbenhnhan.SelectedItems[0]; lblmabenhnhan.Text = lvi.SubItems[1].Text; lbltenbenhnhan.Text = lvi.SubItems[2].Text; lblgioitinh.Text = lvi.SubItems[3].Text; lblngaysinh.Text = lvi.SubItems[4].Text; lbldiachi.Text = lvi.SubItems[6].Text; grketquakham.Enabled = true; exp1.Expanded = false; pkbdto = pkbbus.getByPrimaryKey(lblmabenhnhan.Text.ToString(), dtimengaykham.Text.ToString()); if (dtimengaykham.Text.Equals(DateTime.Now.ToShortDateString().ToString()) == false) { grketquakham.Enabled = false; grlaythuoc.Enabled = false; if (pkbdto != null) btninphieukham.Enabled = true; } else { if (pkbdto == null) { btnlapphieukham.Enabled = true; btnsuaphieukham.Enabled = false; btninphieukham.Enabled = false; grlaythuoc.Enabled = false; lvDonThuoc.Items.Clear(); } else { btnlapphieukham.Enabled = false; btnsuaphieukham.Enabled = true; btninphieukham.Enabled = true; grlaythuoc.Enabled = true; txttrieuchung.Text = pkbdto.TrieuChung; cbloaibenhchinh.Text = lbbus.getByPrimaryKey(pkbdto.MaLoaiBenh).TenLoaiBenh.ToString(); cbloaibenhphu.Text = lbbus.getByPrimaryKey(pkbdto.MaLoaiBenhPhu).TenLoaiBenh.ToString(); ctkbus.showInListView(lvDonThuoc, ctkbus.getListByMaPhieuKham(lblmabenhnhan.Text + dtimengaykham.Text)); txttrieuchung.Text = ""; // ctkbus.showInListView1(lvdonthuocganday, ctkbus.getListByBenhNhan(lblmabenhnhan.Text.ToString())); } exp1.TitleText = " Bệnh nhân : " + lblmabenhnhan.Text; // tuy chinh menu them, xoa , sua don thuoc cmbloaithuoc.Enabled = true; btSua.Enabled = false; btXoa.Enabled = false; btThem.Enabled = true; btnhuy.Enabled = false; } } }
private void lvDonThuoc_SelectedIndexChanged(object sender, EventArgs e) { if (this.lvDonThuoc.SelectedItems.Count > 0) { pkbdto = new PhieuKhamBenhDTO(); ListViewItem lvi = this.lvDonThuoc.SelectedItems[0]; cmbloaithuoc.Text = lvi.SubItems[1].Text.ToString(); lbldonvi.Text = lvi.SubItems[2].Text; cmbsoluong.Text = lvi.SubItems[3].Text; macachdung = int.Parse(lvi.SubItems[4].Text); cddto = cdbus.getByPrimaryKey(int.Parse(lvi.SubItems[4].Text)); txtcachdung.Text = cddto.CachDung; txtghichu.Text = cddto.GhiChu; txtsang.Text = cddto.Sang.ToString(); txttrua.Text = cddto.Trua.ToString(); txtchieu.Text = cddto.Chieu.ToString(); txttoi.Text = cddto.Toi.ToString(); cmbloaithuoc.Enabled = false; btSua.Enabled = true; btXoa.Enabled = true; btThem.Enabled = false; btnhuy.Enabled = true; lbldongia.Text = ltbus.getByPrimaryKey(int.Parse(cmbloaithuoc.SelectedValue.ToString())).DonGia.ToString(); } }
public void update(PhieuKhamBenhDTO bn) { DialogResult result1; result1 = MessageBox.Show("Bạn có thật sự sửa phiếu khám bệnh nàh ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { if (((bn.MaLoaiBenh == bn.MaLoaiBenhPhu) && bn.MaLoaiBenh != 1) || (bn.MaLoaiBenhPhu != 1 && bn.MaLoaiBenh == 1)) { MessageBox.Show(" Lựa chọn loại bệnh và loại bệnh phụ chưa hợp lệ !"); } else { bn.MaPhieuKhamBenh = bn.MaBenhNhan + bn.NgayKham; int result = dvdao.update(bn); if (result > 0) MessageBox.Show(" Sửa phiếu khám bệnh thành công !"); else MessageBox.Show(" Sửa phiếu khám bệnh thất bại !"); } } }