private void OnDisplayChiTietToaThuoc(string toaThuocGUID) { Result result = KeToaBus.GetChiTietToaThuocListWithoutThuocNgoai(toaThuocGUID); if (result.IsOK) { DataTable dtChiTiet = (gridViewPTT.DataSource as DataView).Table; dtChiTiet.Rows.Clear(); DataTable dt = result.QueryResult as DataTable; int stt = 1; foreach (DataRow row in dt.Rows) { DataRow newRow = dtChiTiet.NewRow(); dtChiTiet.Rows.Add(newRow); string thuocGUID = row["ThuocGUID"].ToString(); newRow["STT"] = stt++; newRow["ThuocGUID"] = thuocGUID; double soLuong = Convert.ToDouble(row["SoLuong"]); newRow["SoLuong"] = soLuong; UpdateThongTinThuoc(newRow); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaBus.GetChiTietToaThuocList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.GetChiTietToaThuocList")); } }
private void OnDisplayToaThuocList() { Result result = KeToaBus.GetToaThuocTrongNgayList(); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); dgToaThuoc.DataSource = result.QueryResult; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("KeToaBus.GetToaThuocTrongNgayList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.GetToaThuocTrongNgayList")); } }
private bool CheckInfo() { if (txtMaToaThuoc.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng nhập mã toa thuốc.", IconType.Information); txtMaToaThuoc.Focus(); return(false); } if (cboBacSi.SelectedValue == null || cboBacSi.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng chọn bác sĩ kê toa.", IconType.Information); cboBacSi.Focus(); return(false); } if (txtTenBenhNhan.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng chọn bệnh nhân.", IconType.Information); btnChonBenhNhan.Focus(); return(false); } string toaThuocGUID = _isNew ? string.Empty : _toaThuoc.ToaThuocGUID.ToString(); Result result = KeToaBus.CheckToaThuocExistCode(toaThuocGUID, txtMaToaThuoc.Text); if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST) { if (result.Error.Code == ErrorCode.EXIST) { MsgBox.Show(this.Text, "Mã toa thuốc này đã tồn tại rồi. Vui lòng nhập mã khác.", IconType.Information); txtMaToaThuoc.Focus(); return(false); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaBus.CheckToaThuocExistCode"), IconType.Error); return(false); } if (dgChiTiet.RowCount <= 0) { MsgBox.Show(this.Text, "Vui lòng kê toa ít nhất 1 thuốc.", IconType.Information); return(false); } return(true); }
private void OnChuyenKetQuaKham() { if (!_isChuyenBenhAn) { return; } List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgToaThuoc.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedRows.Add(row); } } if (dgToaThuoc.RowCount <= 0 || deletedRows == null || deletedRows.Count <= 0) { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu ít nhất 1 toa thuốc cần chuyển.", IconType.Information); return; } if (_patientRow2 == null) { MsgBox.Show(Application.ProductName, "Vui lòng chọn bệnh nhân nhận toa thuốc chuyển đến.", IconType.Information); return; } string fileNum = _patientRow2["FileNum"].ToString(); if (MsgBox.Question(Application.ProductName, string.Format("Bạn có muốn chuyển những toa thuốc đã chọn đến bệnh nhân: '{0}'?", fileNum)) == DialogResult.No) { return; } Result result = KeToaBus.ChuyenBenhAn(_patientRow2["PatientGUID"].ToString(), deletedRows); if (result.IsOK) { DisplayAsThread(); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("KeToaBus.ChuyenBenhAn"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.ChuyenBenhAn")); } }
private void OnGetChiTietToaThuoc(string toaThuocGUID) { Result result = KeToaBus.GetChiTietToaThuocList(toaThuocGUID); if (result.IsOK) { dgChiTiet.DataSource = result.QueryResult; //RefreshNo(); } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaBus.GetChiTietToaThuocList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.GetChiTietToaThuocList")); } }
private void GenerateCode() { Cursor.Current = Cursors.WaitCursor; Result result = KeToaBus.GetToaThuocCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); txtMaToaThuoc.Text = Utility.GetCode("KT", count + 1, 7); } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaBus.GetToaThuocCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.GetToaThuocCount")); } }
private void OnDisplayToaThuocList() { Result result = KeToaBus.GetToaThuocList(); if (result.IsOK) { DataTable dt = result.QueryResult as DataTable; DataRow newRow = dt.NewRow(); newRow["ToaThuocGUID"] = Guid.Empty.ToString(); newRow["MaToaThuoc"] = string.Empty; dt.Rows.InsertAt(newRow, 0); cboMaToaThuoc.DataSource = dt; } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("KeToaBus.GetToaThuocList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.GetToaThuocList")); } }
private void OnTatCanhBao() { List <string> deletedToaThuocList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgToaThuoc.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedToaThuocList.Add(row["ToaThuocGUID"].ToString()); deletedRows.Add(row); } } if (deletedToaThuocList.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn tắt cảnh báo những toa thuốc mà bạn đã đánh dấu ?") == DialogResult.Yes) { Result result = KeToaBus.TatCanhBaoToaThuoc(deletedToaThuocList); if (result.IsOK) { foreach (DataRow row in deletedRows) { dt.Rows.Remove(row); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("KeToaBus.TatCanhBaoToaThuoc"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.TatCanhBaoToaThuoc")); } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những toa thuốc cần tắt cảnh báo.", IconType.Information); } }
private void OnDisplayToaThuocList() { Result result = null; if (_patientRow == null) { result = KeToaBus.GetToaThuocList(_isAll, _fromDate, _toDate, _tenBenhNhan); } else { string patientGUID = _patientRow["PatientGUID"].ToString(); result = KeToaBus.GetToaThuocList(patientGUID, Global.UserGUID, _isAll, _fromDate, _toDate); } if (result.IsOK) { MethodInvoker method = delegate { ClearData(); dgToaThuoc.DataSource = result.QueryResult; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("KeToaBus.GetToaThuocList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.GetToaThuocList")); } }
private void OnSaveInfo() { try { MethodInvoker method = delegate { _toaThuoc.MaToaThuoc = txtMaToaThuoc.Text; _toaThuoc.NgayKeToa = DateTime.Now; _toaThuoc.NgayKham = dtpkNgayKham.Value; if (chkNgayTaiKham.Checked) { _toaThuoc.NgayTaiKham = dtpkNgayTaiKham.Value; } else { _toaThuoc.NgayTaiKham = null; } _toaThuoc.BacSiKeToa = Guid.Parse(cboBacSi.SelectedValue.ToString()); _toaThuoc.BenhNhan = Guid.Parse(txtTenBenhNhan.Tag.ToString()); _toaThuoc.ChanDoan = txtChanDoan.Text; _toaThuoc.Note = txtGhiChu.Text; _toaThuoc.Status = (byte)Status.Actived; _toaThuoc.Loai = raToaChung.Checked ? (byte)LoaiToaThuoc.Chung : (byte)LoaiToaThuoc.SanKhoa; if (_isNew) { _toaThuoc.CreatedDate = DateTime.Now; _toaThuoc.CreatedBy = Guid.Parse(Global.UserGUID); } else { _toaThuoc.UpdatedDate = DateTime.Now; _toaThuoc.UpdatedBy = Guid.Parse(Global.UserGUID); } DataTable dt = dgChiTiet.DataSource as DataTable; List <ChiTietToaThuoc> addedList = new List <ChiTietToaThuoc>(); foreach (DataRow row in dt.Rows) { ChiTietToaThuoc cttt = new ChiTietToaThuoc(); if (row["ChiTietToaThuocGUID"] != null && row["ChiTietToaThuocGUID"] != DBNull.Value) { cttt.ChiTietToaThuocGUID = Guid.Parse(row["ChiTietToaThuocGUID"].ToString()); cttt.UpdatedDate = DateTime.Now; cttt.UpdatedBy = Guid.Parse(Global.UserGUID); } else { cttt.CreatedDate = DateTime.Now; cttt.CreatedBy = Guid.Parse(Global.UserGUID); } if (row["ThuocGUID"] != null && row["ThuocGUID"] != DBNull.Value) { cttt.ThuocGUID = Guid.Parse(row["ThuocGUID"].ToString()); } else { cttt.TenThuocNgoai = row["TenThuoc"].ToString(); } cttt.SoLuong = Convert.ToInt32(row["SoLuong"]); cttt.LieuDung = row["LieuDung"].ToString(); cttt.Note = row["Note"].ToString(); cttt.Sang = Convert.ToBoolean(row["Sang"]); cttt.SangNote = row["SangNote"].ToString(); cttt.Trua = Convert.ToBoolean(row["Trua"]); cttt.TruaNote = row["TruaNote"].ToString(); cttt.Chieu = Convert.ToBoolean(row["Chieu"]); cttt.ChieuNote = row["ChieuNote"].ToString(); cttt.Toi = Convert.ToBoolean(row["Toi"]); cttt.ToiNote = row["ToiNote"].ToString(); cttt.TruocAn = Convert.ToBoolean(row["TruocAn"]); cttt.TruocAnNote = row["TruocAnNote"].ToString(); cttt.SauAn = Convert.ToBoolean(row["SauAn"]); cttt.SauAnNote = row["SauAnNote"].ToString(); cttt.Khac_TruocSauAn = Convert.ToBoolean(row["Khac_TruocSauAn"]); cttt.Khac_TruocSauAnNote = row["Khac_TruocSauAnNote"].ToString(); cttt.Uong = Convert.ToBoolean(row["Uong"]); cttt.UongNote = row["UongNote"].ToString(); cttt.Boi = Convert.ToBoolean(row["Boi"]); cttt.BoiNote = row["BoiNote"].ToString(); cttt.Dat = Convert.ToBoolean(row["Dat"]); cttt.DatNote = row["DatNote"].ToString(); cttt.Khac_CachDung = Convert.ToBoolean(row["Khac_CachDung"]); cttt.Khac_CachDungNote = row["Khac_CachDungNote"].ToString(); cttt.Status = (byte)Status.Actived; addedList.Add(cttt); } Result result = KeToaBus.InsertToaThuoc(_toaThuoc, addedList, _deletedKeys); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaBus.InsertToaThuoc"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaBus.InsertToaThuoc")); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } catch (Exception e) { MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }