private BENHNHAN getBENHNHANByForm() { BENHNHAN ans = new BENHNHAN(); ans.HOTEN = txtHoTen.Text; ans.NGAYSINH = dateNgaySinh.DateTime; ans.SDT = txtSDT.Text; ans.QUEQUAN = txtQueQuan.Text; ans.MATHEBHYT = txtMaBHYT.Text; ans.TRINHDOVANHOA = txtTrinhDo.Text; ans.NGHENGHIEPTRUOCNN = txtNgheNghiepTruoc.Text; ans.NGHENGHIEPSAUNN = txtNgheNghiepSau.Text; ans.NHOMMAU = txtNhomMau.Text; ans.TIENSUGIADINH = txtTienSuGiaDinh.Text; ans.TIENSUBANTHAN = txtTienSuBanThan.Text; ans.NAMNHAPNGU = Int32.Parse(txtNamNhapNgu.Text); ans.DONVIID = (int)cbxDonVi.EditValue; ans.CAPBACID = (int)cbxCapBac.EditValue; ans.CHUCVUID = (int)cbxChucVu.EditValue; ans.DOITUONGID = (int)cbxDoiTuong.EditValue; ans.GIOITINH = cbxGioiTinh.SelectedIndex; return(ans); }
public ActionResult SelectBenhNhan() { BENHNHAN ct = new BENHNHAN(); ct.listBN = database.BENHNHANs.ToList <BENHNHAN>(); return(PartialView(ct)); }
public string UpdateBenhNhan(QLPHONGKHAMEntities db, BenhNhanDTO BenhNhan) { BENHNHAN benhNhanDAO = new BENHNHAN(); BUS.Com.Utils.CopyPropertiesFrom(BenhNhan, benhNhanDAO); return(benhNhanDao.Save(db, benhNhanDAO)); }
private void btnXuatBaoCao_Click(object sender, EventArgs e) { if (Check()) { BENHNHAN benhnhan = BENHNHANService.GetByPrimaryKey(new BENHNHANKeys((int)khamthuongxuyen.BENHNHANID)); dynamic param = new { YKienDeNghi = txtYKienDeNghi.Text, BenhVienCapTren = BENHVIENService.GetByPrimaryKey(new BENHVIENKeys((int)khamthuongxuyen.BENHVIENID)).TEN, HoTen = benhnhan.HOTEN, Tuoi = DateTime.Now.Year - ((DateTime)benhnhan.NGAYSINH).Year, CapBac = CAPBACService.GetByPrimaryKey(new CAPBACKeys((int)benhnhan.CAPBACID)).TEN, ChucVu = CHUCVUService.GetByPrimaryKey(new CHUCVUKeys((int)benhnhan.CHUCVUID)).TEN, DonVi = txtDonVi.Text, DonViBenhNhan = DONVIService.GetByPrimaryKey(new DONVIKeys((int)benhnhan.DONVIID)).TEN, Benh = txtCanBenh.Text, //BENHService.GetByPrimaryKey(new BENHKeys((int)khamthuongxuyen.BENHID)).TEN, Ngay = DateTime.Now.ToString(@"\N\g\à\y dd \t\h\á\n\g MM \n\ă\m yyyy"), SoSucKhoe = txtSoSucKhoe.Text }; FrmRpGiayGioiThieu form = new FrmRpGiayGioiThieu(param); this.Hide(); form.ShowDialog(); this.Close(); } }
private void UpdateDetail() { try { BENHNHAN tg = getBENHNHANByID(); if (tg.ID == 0) { return; } txtHoTen.Text = tg.HOTEN; txtMaBHYT.Text = tg.MATHEBHYT; txtSDT.Text = tg.SDT; txtNamNhapNgu.Text = tg.NAMNHAPNGU.ToString(); txtQueQuan.Text = tg.QUEQUAN; txtNgheNghiepSau.Text = tg.NGHENGHIEPSAUNN; txtNgheNghiepTruoc.Text = tg.NGHENGHIEPTRUOCNN; txtNhomMau.Text = tg.NHOMMAU; txtTienSuBanThan.Text = tg.TIENSUBANTHAN; txtTienSuGiaDinh.Text = tg.TIENSUGIADINH; txtTrinhDo.Text = tg.TRINHDOVANHOA; cbxCapBac.EditValue = (int)tg.CAPBACID; cbxChucVu.EditValue = (int)tg.CHUCVUID; cbxDonVi.EditValue = (int)tg.DONVIID; cbxDoiTuong.EditValue = (int)tg.DOITUONGID; cbxGioiTinh.SelectedIndex = (int)tg.GIOITINH; dateNgaySinh.DateTime = (DateTime)tg.NGAYSINH; } catch { } }
/// <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(); } }
/// <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(); } }
/// <summary> /// Remove a benhnhan object from list, DB and refresh the view /// </summary> /// <param name="bn"></param> public async Task Remove(BENHNHAN bn) { //await Task.Run(() => Helper.RemoveBenhNhan(bn)); await Task.Run(() => Helper.RemovePhieuKham(bn)); DS_KhamBenh.Remove(bn); ViewSource.Refresh(); }
public ActionResult DeleteConfirmed(int id) { BENHNHAN bENHNHAN = db.BENHNHANs.Find(id); db.BENHNHANs.Remove(bENHNHAN); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Add a new benhnhan object to list, DB and refresh the view /// </summary> /// <param name="bn"></param> public async Task Add(BENHNHAN bn) { //await Task.Run(() => Helper.AddBenhNhan(bn)); await Task.Run(() => Helper.AddPhieuKham(bn)); DS_KhamBenh.Add(bn); ViewSource.Refresh(); }
public ActionResult Edit([Bind(Include = "MABN,TENBN,NGAYSINHBN,DIACHIBN,GIOITINH,CMND,BHYT")] BENHNHAN bENHNHAN) { if (ModelState.IsValid) { db.Entry(bENHNHAN).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bENHNHAN)); }
/// <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(); } }
/// <summary> /// insert new row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true of successfully insert</returns> public bool Insert(BENHNHAN businessObject) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = "dbo.[BENHNHAN_Insert]"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int, 4, ParameterDirection.Output, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ID)); sqlCommand.Parameters.Add(new SqlParameter("@HOTEN", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.HOTEN)); sqlCommand.Parameters.Add(new SqlParameter("@GIOITINH", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.GIOITINH)); sqlCommand.Parameters.Add(new SqlParameter("@SDT", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.SDT)); sqlCommand.Parameters.Add(new SqlParameter("@QUEQUAN", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.QUEQUAN)); sqlCommand.Parameters.Add(new SqlParameter("@NGAYSINH", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.NGAYSINH)); sqlCommand.Parameters.Add(new SqlParameter("@MATHEBHYT", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.MATHEBHYT)); sqlCommand.Parameters.Add(new SqlParameter("@NAMNHAPNGU", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.NAMNHAPNGU)); sqlCommand.Parameters.Add(new SqlParameter("@TRINHDOVANHOA", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TRINHDOVANHOA)); sqlCommand.Parameters.Add(new SqlParameter("@CAPBACID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CAPBACID)); sqlCommand.Parameters.Add(new SqlParameter("@CHUCVUID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CHUCVUID)); sqlCommand.Parameters.Add(new SqlParameter("@NGHENGHIEPTRUOCNN", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.NGHENGHIEPTRUOCNN)); sqlCommand.Parameters.Add(new SqlParameter("@NGHENGHIEPSAUNN", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.NGHENGHIEPSAUNN)); sqlCommand.Parameters.Add(new SqlParameter("@DOITUONGID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DOITUONGID)); sqlCommand.Parameters.Add(new SqlParameter("@DONVIID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DONVIID)); sqlCommand.Parameters.Add(new SqlParameter("@TIENSUBANTHAN", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TIENSUBANTHAN)); sqlCommand.Parameters.Add(new SqlParameter("@TIENSUGIADINH", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TIENSUGIADINH)); sqlCommand.Parameters.Add(new SqlParameter("@DANTOC", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DANTOC)); sqlCommand.Parameters.Add(new SqlParameter("@DIACHI", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DIACHI)); sqlCommand.Parameters.Add(new SqlParameter("@TINHTRANGCONGTAC", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TINHTRANGCONGTAC)); sqlCommand.Parameters.Add(new SqlParameter("@NHOMMAU", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.NHOMMAU)); sqlCommand.Parameters.Add(new SqlParameter("@DIUNG", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DIUNG)); sqlCommand.Parameters.Add(new SqlParameter("@GHICHU", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.GHICHU)); MainConnection.Open(); sqlCommand.ExecuteNonQuery(); businessObject.ID = (int)sqlCommand.Parameters["@ID"].Value; return(true); } catch //(Exception ex) { return(false); //throw new Exception("BENHNHAN::Insert::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
public ActionResult Create([Bind(Include = "MABN,TENBN,NGAYSINHBN,DIACHIBN,GIOITINH,CMND,BHYT")] BENHNHAN bENHNHAN) { if (ModelState.IsValid) { db.BENHNHANs.Add(bENHNHAN); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bENHNHAN)); }
public void Insert_TestCase3() { BENHNHAN benhNhan = new BENHNHAN { MaBenhNhan = TestCommon.LEN_10, }; BenhNhanDAO dao = new BenhNhanDAO(); string actual = dao.Save(db, benhNhan); string expected = "1111"; Assert.Equals(expected, actual); }
/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of BENHNHAN</returns> internal List <BENHNHAN> PopulateObjectsFromReader(IDataReader dataReader) { List <BENHNHAN> list = new List <BENHNHAN>(); while (dataReader.Read()) { BENHNHAN businessObject = new BENHNHAN(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
/// <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(); } }
// Sua Benh Nhan private void button5_Click(object sender, EventArgs e) { // kiem tra du lieu dau vao if (txb_MaBN.Text == "" || (txb_MaBN.Text).Length > 5) { MessageBox.Show("Mã bệnh nhân không được trống và không quá 5 ký tự. Vui lòng nhập lại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (IsNumber(txb_DienThoai.Text) == false || txb_DienThoai.Text == "") { MessageBox.Show("Số điện thoại không đúng. Vui lòng nhập lại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txb_HoTen.Text == "") { MessageBox.Show(" Vui lòng nhập tên bệnh nhân lại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txb_HoTen.Text == "") { MessageBox.Show(". Vui lòng nhập tên bệnh nhân lại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // khoi tao doi tuong DTO BENHNHAN bnDTO = new BENHNHAN(); bnDTO.MaBN1 = int.Parse(txb_MaBN.Text); bnDTO.TenBN1 = txb_HoTen.Text; bnDTO.NgaySinh1 = DateTime.Parse(dtp_NgaySinh.Text); bnDTO.DiaChi1 = txb_DiaChi.Text; bnDTO.DienThoai1 = txb_DienThoai.Text.ToString(); //bnDTO.GioiTinh1= if (rdb_Nam.Checked == true) { bnDTO.GioiTinh1 = "Nam"; } else { bnDTO.GioiTinh1 = "Nữ"; } // goi lop nghiep vu BENHNHAN_BUS if (BenhNhanBUS.SuaBenhNhan(bnDTO) == true) { TaiDuLieuVaoDataGirdView(); MessageBox.Show("Sửa thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MessageBox.Show(" Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); }
public void Delete_TestCase8() { BENHNHAN benhNhan = new BENHNHAN { MaBenhNhan = TestCommon.LEN_10, HoTen = TestCommon.LEN_50, CMND = "123456789012", }; BenhNhanDAO dao = new BenhNhanDAO(); string actual = dao.Save(db, benhNhan); Assert.Equals(null, actual); }
private void btnSua_Click(object sender, EventArgs e) { if (!CheckLuaChon()) { return; } if (btnSua.Text == "Sửa") { btnSua.Text = "Lưu"; btnXoa.Text = "Hủy"; btnThem.Enabled = false; UnlockControl(); return; } if (btnSua.Text == "Lưu") { if (Check()) { btnSua.Text = "Sửa"; btnXoa.Text = "Xóa"; LockControl(); BENHNHAN cu = getBENHNHANByID(); BENHNHAN moi = getBENHNHANByForm(); CapNhat(ref cu, moi); if (BENHNHANService.Update(cu)) { MessageBox.Show("Sửa thông tin bệnh nhân thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Sửa thông tin bệnh nhân thất bại\n", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadDgvBENHNHAN(); } return; } }
public ActionResult EditProfile(BENHNHAN std) { try { db.Entry(std).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch { ModelState.AddModelError("Confirmpwd", "Vui lòng kiểm tra mật khẩu"); return(View(std)); } }
private bool CheckLuaChon() { BENHNHAN tg = getBENHNHANByID(); if (tg.ID == 0) { MessageBox.Show("Chưa có bệnh nhân nào được chọn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
// GET: BENHNHANs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BENHNHAN bENHNHAN = db.BENHNHANs.Find(id); if (bENHNHAN == null) { return(HttpNotFound()); } return(View(bENHNHAN)); }
private void btnXoa_Click(object sender, EventArgs e) { if (btnXoa.Text == "Xóa") { if (!CheckLuaChon()) { return; } BENHNHAN cu = getBENHNHANByID(); DialogResult rs = MessageBox.Show("Bạn có chắc chắn xóa bệnh nhân " + cu.HOTEN + "?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (rs == DialogResult.Cancel) { return; } try { BENHNHANService.Delete(new BENHNHANKeys(cu.ID)); MessageBox.Show("Xóa thông tin bệnh nhân thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Xóa thông tin bệnh nhân thất bại\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadDgvBENHNHAN(); return; } if (btnXoa.Text == "Hủy") { btnSua.Text = "Sửa"; btnThem.Text = "Thêm"; btnXoa.Text = "Xóa"; LockControl(); UpdateDetail(); return; } }
public ActionResult Register(BENHNHAN bn) { var check = database.BENHNHANs.FirstOrDefault(s => s.SoDienThoai == bn.SoDienThoai); if (check == null) { database.Configuration.ValidateOnSaveEnabled = false; database.BENHNHANs.Add(bn); database.SaveChanges(); return(RedirectToAction("Login")); } else { return(View()); } }
public string GetInformationBenhNhan(QLPHONGKHAMEntities db, string MaBenhNhan, out BenhNhanDTO InformationBenhNhan) { InformationBenhNhan = new BenhNhanDTO(); BENHNHAN entity = null; object[] id = { MaBenhNhan }; if (benhNhanDao.FindById(db, id, out entity) == Constant.RES_FAI) { return(Constant.RES_FAI); } if (entity == null) { return(Constant.RES_FAI); } BUS.Com.Utils.CopyPropertiesFrom(entity, InformationBenhNhan); return(Constant.RES_SUC); }
private BENHNHAN getBENHNHANByID() { try { int id = (int)dgvBENHNHAN.GetFocusedRowCellValue("ID"); BENHNHAN ans = BENHNHANService.GetAllBy(BENHNHAN.BENHNHANFields.ID, id).FirstOrDefault(); if (ans == null) { return(new BENHNHAN()); } return(ans); } catch { return(new BENHNHAN()); } }
public ActionResult Create(BENHNHAN Nv) { var check = database.BENHNHANs.FirstOrDefault(s => s.SoDienThoai == Nv.SoDienThoai); if (check == null) { database.Configuration.ValidateOnSaveEnabled = false; database.BENHNHANs.Add(Nv); database.SaveChanges(); return(RedirectToAction("Index")); } else { ViewBag.error = "Số Điện Thoại Đã Tồn Tại"; return(View()); } }
public ActionResult ForgotPassword(BENHNHAN BN) { var check = database.BENHNHANs.Where(s => s.SoDienThoai == BN.SoDienThoai).FirstOrDefault(); if (check != null) { database.Configuration.ValidateOnSaveEnabled = false; check.MatKhau = BN.MatKhau; database.SaveChanges(); return(RedirectToAction("Login")); } else { ViewBag.ErrorInfo = "Sai số điện thoại"; return(View()); } }
public ActionResult Index(BENHNHAN BN) { var check = database.BENHNHANs.Where(s => s.MaBenhNhan == BN.MaBenhNhan).FirstOrDefault(); if (check == null) { ViewBag.ErrorInfo = "Không có thông tin"; return(View()); } else { database.Configuration.ValidateOnSaveEnabled = false; Session["MaBenhNhan"] = check.MaBenhNhan; return(RedirectToAction("LichSuKham", "CreateProfile")); } }