private void CapNhat() { try { KHAMDINHKI khamdinhki1 = GetKHAMDINHKIByForm(); KHAMCHUYENKHOA khamchuyenkhoa1 = GetKHAMCHUYENKHOAByForm(); KHAMCANLAMSANG khamcanlamsang1 = GetKHAMCANLAMSANGByForm(); KHAMTHELUC khamtheluc1 = GetKHAMTHELUCByForm(); khamdinhki1.ID = khamdinhki.ID; khamdinhki1.KHAMCANLAMSANGID = khamdinhki.KHAMCANLAMSANGID; khamdinhki1.KHAMTHELUCID = khamdinhki.KHAMTHELUCID; khamdinhki1.KHAMCHUYENKHOAID = khamdinhki.KHAMCHUYENKHOAID; khamchuyenkhoa1.ID = (int)khamdinhki.KHAMCHUYENKHOAID; khamcanlamsang1.ID = (int)khamdinhki.KHAMCANLAMSANGID; khamtheluc1.ID = (int)khamdinhki.KHAMTHELUCID; KHAMDINHKIService.Update(khamdinhki1); KHAMCHUYENKHOAService.Update(khamchuyenkhoa1); KHAMCANLAMSANGService.Update(khamcanlamsang1); KHAMTHELUCService.Update(khamtheluc1); } catch { } }
/// <summary> /// Populate business object from data reader /// </summary> /// <param name="businessObject">business object</param> /// <param name="dataReader">data reader</param> internal void PopulateBusinessObjectFromReader(KHAMDINHKI businessObject, IDataReader dataReader) { businessObject.ID = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.ID.ToString())); if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.BENHNHANID.ToString()))) { businessObject.BENHNHANID = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.BENHNHANID.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.PHANLOAISUCKHOEID.ToString()))) { businessObject.PHANLOAISUCKHOEID = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.PHANLOAISUCKHOEID.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.BACSIID.ToString()))) { businessObject.BACSIID = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.BACSIID.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.KHAMTHELUCID.ToString()))) { businessObject.KHAMTHELUCID = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.KHAMTHELUCID.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.KHAMCANLAMSANGID.ToString()))) { businessObject.KHAMCANLAMSANGID = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.KHAMCANLAMSANGID.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.KHAMCHUYENKHOAID.ToString()))) { businessObject.KHAMCHUYENKHOAID = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.KHAMCHUYENKHOAID.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.KETLUAN.ToString()))) { businessObject.KETLUAN = dataReader.GetString(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.KETLUAN.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.THOIGIANKHAM.ToString()))) { businessObject.THOIGIANKHAM = dataReader.GetDateTime(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.THOIGIANKHAM.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.LOAIHINHKHAM.ToString()))) { businessObject.LOAIHINHKHAM = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.LOAIHINHKHAM.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.BENHHIEMNGHEO.ToString()))) { businessObject.BENHHIEMNGHEO = dataReader.GetInt32(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.BENHHIEMNGHEO.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.GHICHU.ToString()))) { businessObject.GHICHU = dataReader.GetString(dataReader.GetOrdinal(KHAMDINHKI.KHAMDINHKIFields.GHICHU.ToString())); } }
/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of KHAMDINHKI</returns> internal List <KHAMDINHKI> PopulateObjectsFromReader(IDataReader dataReader) { List <KHAMDINHKI> list = new List <KHAMDINHKI>(); while (dataReader.Read()) { KHAMDINHKI businessObject = new KHAMDINHKI(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
public FrmChiTietKhamDinhKi(int _khamdinhkiid) { InitializeComponent(); KHAMDINHKI khamdinhki = KHAMDINHKIService.GetByPrimaryKey(new KHAMDINHKIKeys(_khamdinhkiid)); panelMain.Controls.Clear(); ucKhamDinhKi uc = new ucKhamDinhKi(khamdinhki, 1); panelMain.Controls.Add(uc); uc.Show(); }
private KHAMDINHKI GetKHAMDINHKIByForm() { KHAMDINHKI ans = new KHAMDINHKI(); ans.BACSIID = (int)cbxBacSi.EditValue; ans.BENHNHANID = (int)cbxBenhNhan.EditValue; ans.THOIGIANKHAM = dateThoiGianKham.DateTime; ans.PHANLOAISUCKHOEID = (int)cbxPhanLoaiSucKhoe.EditValue; ans.KETLUAN = txtKetLuan.Text; ans.BENHHIEMNGHEO = cbxBenhHiemNgheo.SelectedIndex; ans.LOAIHINHKHAM = cbxLoaiHinhKham.SelectedIndex; return(ans); }
private void UpdateDetailKhamDinhKi(KHAMDINHKI khamdinhki) { try { cbxBacSi.EditValue = khamdinhki.BACSIID; cbxBenhNhan.EditValue = khamdinhki.BENHNHANID; dateThoiGianKham.DateTime = (DateTime)khamdinhki.THOIGIANKHAM; cbxPhanLoaiSucKhoe.EditValue = khamdinhki.PHANLOAISUCKHOEID; txtKetLuan.Text = khamdinhki.KETLUAN; cbxBenhHiemNgheo.SelectedIndex = (int)khamdinhki.BENHHIEMNGHEO; cbxLoaiHinhKham.SelectedIndex = (int)khamdinhki.LOAIHINHKHAM; } catch { } }
private void btnLuu_Click(object sender, EventArgs e) { try { if (CheckKhamDinhKi()) { KHAMDINHKI khamdinhki1 = GetKHAMDINHKIByForm(); KHAMCHUYENKHOA khamchuyenkhoa = GetKHAMCHUYENKHOAByForm(); KHAMCANLAMSANG khamcanlamsang = GetKHAMCANLAMSANGByForm(); KHAMTHELUC khamtheluc = GetKHAMTHELUCByForm(); if (khamdinhki.ID == 0) { KHAMCHUYENKHOAService.Insert(khamchuyenkhoa); KHAMCANLAMSANGService.Insert(khamcanlamsang); KHAMTHELUCService.Insert(khamtheluc); khamdinhki1.KHAMCHUYENKHOAID = khamchuyenkhoa.ID; khamdinhki1.KHAMTHELUCID = khamtheluc.ID; khamdinhki1.KHAMCANLAMSANGID = khamcanlamsang.ID; KHAMDINHKIService.Insert(khamdinhki1); MessageBox.Show("Thêm thông tin khám định kì thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LockControl(); } else { CapNhat(); MessageBox.Show("Cập nhật thông tin khám định kì thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } UpdateDetail(); } } catch { } }
/// <summary> /// insert new row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true of successfully insert</returns> public bool Insert(KHAMDINHKI businessObject) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = "dbo.[KHAMDINHKI_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("@BENHNHANID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.BENHNHANID)); sqlCommand.Parameters.Add(new SqlParameter("@PHANLOAISUCKHOEID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.PHANLOAISUCKHOEID)); sqlCommand.Parameters.Add(new SqlParameter("@BACSIID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.BACSIID)); sqlCommand.Parameters.Add(new SqlParameter("@KHAMTHELUCID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.KHAMTHELUCID)); sqlCommand.Parameters.Add(new SqlParameter("@KHAMCANLAMSANGID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.KHAMCANLAMSANGID)); sqlCommand.Parameters.Add(new SqlParameter("@KHAMCHUYENKHOAID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.KHAMCHUYENKHOAID)); sqlCommand.Parameters.Add(new SqlParameter("@KETLUAN", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.KETLUAN)); sqlCommand.Parameters.Add(new SqlParameter("@THOIGIANKHAM", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.THOIGIANKHAM)); sqlCommand.Parameters.Add(new SqlParameter("@LOAIHINHKHAM", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.LOAIHINHKHAM)); sqlCommand.Parameters.Add(new SqlParameter("@BENHHIEMNGHEO", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.BENHHIEMNGHEO)); 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("KHAMDINHKI::Insert::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
/// <summary> /// Select by primary key /// </summary> /// <param name="keys">primary keys</param> /// <returns>KHAMDINHKI business object</returns> public KHAMDINHKI SelectByPrimaryKey(KHAMDINHKIKeys keys) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = "dbo.[KHAMDINHKI_SelectByPrimaryKey]"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, keys.ID)); MainConnection.Open(); IDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { KHAMDINHKI businessObject = new KHAMDINHKI(); PopulateBusinessObjectFromReader(businessObject, dataReader); return(businessObject); } else { return(null); } } catch //(Exception ex) { return(null); //throw new Exception("KHAMDINHKI::SelectByPrimaryKey::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
public ucKhamDinhKi(KHAMDINHKI _khamdinhki, int _mode) { khamdinhki = _khamdinhki; mode = _mode; InitializeComponent(); }