private void OnDisplayToaCapCuuList() { Result result = KeToaCapCuuBus.GetToaCapCuuList(_isAll, _fromDate, _toDate); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); dgToaCapCuu.DataSource = result.QueryResult; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("KeToaCapCuuBus.GetToaCapCuuList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaCapCuuBus.GetToaCapCuuList")); } }
private void GenerateCode() { Cursor.Current = Cursors.WaitCursor; Result result = KeToaCapCuuBus.GetToaCapCuuCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); txtMaToaCapCuu.Text = Utility.GetCode("TCC", count + 1, 7); } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaCapCuuBus.GetToaCapCuuCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaCapCuuBus.GetToaCapCuuCount")); } }
private void OnGetChiTietToaCapCuu(string toaCapCuuGUID) { Result result = KeToaCapCuuBus.GetChiTietToaCapCuu(toaCapCuuGUID); if (result.IsOK) { dgChiTiet.DataSource = result.QueryResult; UpdateNgayHetHanVaSoLuongTon(); RefreshNo(); } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaCapCuuBus.GetChiTietToaCapCuu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaCapCuuBus.GetChiTietToaCapCuu")); } }
private void OnDisplayChiTietToaCapCuu(string toaCapCuuGUID) { Result result = KeToaCapCuuBus.GetChiTietToaCapCuu(toaCapCuuGUID); if (result.IsOK) { DataTable dtChiTiet = dgChiTiet.DataSource as DataTable; DataTable dt = result.QueryResult as DataTable; foreach (DataRow row in dt.Rows) { DataRow newRow = dtChiTiet.NewRow(); string khoCapCuuGUID = row["KhoCapCuuGUID"].ToString(); newRow["KhoCapCuuGUID"] = khoCapCuuGUID; newRow["TenCapCuu"] = row["TenCapCuu"].ToString(); string donViTinh = GetDonViTinh(khoCapCuuGUID); List <double> donGiaList = GetGiaCapCuu(khoCapCuuGUID); double donGia = 0; if (donGiaList != null && donGiaList.Count > 0) { donGia = donGiaList[donGiaList.Count - 1]; } int soLuong = Convert.ToInt32(row["SoLuong"]); newRow["DonViTinh"] = donViTinh; newRow["SoLuong"] = soLuong; newRow["DonGia"] = donGia; newRow["Giam"] = 0; newRow["ThanhTien"] = soLuong * donGia; dtChiTiet.Rows.Add(newRow); } if (_isNew) { UpdateDataSourceDonGia(); } UpdateNgayHetHanVaSoLuongTon(); CalculateTongTien(); RefreshNo(); } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaCapCuuBus.GetChiTietToaCapCuu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaCapCuuBus.GetChiTietToaCapCuu")); } }
private void OnDisplayToaCapCuu() { Result result = KeToaCapCuuBus.GetToaCapCuuChuaXuatPhieuThuList(); if (result.IsOK) { _flag = false; DataTable dt = result.QueryResult as DataTable; DataRow newRow = dt.NewRow(); newRow["ToaCapCuuGUID"] = Guid.Empty; newRow["MaToaCapCuu"] = string.Empty; dt.Rows.InsertAt(newRow, 0); cboMaToaCapCuu.DataSource = dt; _flag = true; } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaCapCuuBus.GetToaCapCuuChuaXuatPhieuThuList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaCapCuuBus.GetToaCapCuuChuaXuatPhieuThuList")); } }
private void OnDelete() { List <string> deletedList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgToaCapCuu.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedList.Add(row["ToaCapCuuGUID"].ToString()); deletedRows.Add(row); } } if (deletedList.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những toa cấp cứu mà bạn đã đánh dấu ?") == DialogResult.Yes) { Result result = KeToaCapCuuBus.DeleteToaCapCuu(deletedList); if (result.IsOK) { foreach (DataRow row in deletedRows) { dt.Rows.Remove(row); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("KeToaCapCuuBus.DeleteToaCapCuu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaCapCuuBus.DeleteToaCapCuu")); } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những toa cấp cứu cần xóa.", IconType.Information); } }
private void OnSaveInfo() { try { MethodInvoker method = delegate { _toaCapCuu.MaToaCapCuu = txtMaToaCapCuu.Text; _toaCapCuu.NgayKeToa = dtpkNgayKeToa.Value; if (cboDocStaff.SelectedValue != null && cboDocStaff.Text.Trim() != string.Empty) { _toaCapCuu.BacSiKeToaGUID = Guid.Parse(cboDocStaff.SelectedValue.ToString()); } else { _toaCapCuu.BacSiKeToaGUID = null; } _toaCapCuu.MaBenhNhan = txtMaBenhNhan.Text; _toaCapCuu.TenBenhNhan = txtTenBenhNhan.Text; _toaCapCuu.DiaChi = txtDiaChi.Text; _toaCapCuu.TenCongTy = _tenCongTy; _toaCapCuu.Status = (byte)Status.Actived; _toaCapCuu.Note = txtGhiChu.Text; if (_isNew) { _toaCapCuu.CreatedDate = DateTime.Now; _toaCapCuu.CreatedBy = Guid.Parse(Global.UserGUID); } List <ChiTietToaCapCuu> addedList = new List <ChiTietToaCapCuu>(); for (int i = 0; i < dgChiTiet.RowCount - 1; i++) { DataGridViewRow row = dgChiTiet.Rows[i]; ChiTietToaCapCuu cttcc = new ChiTietToaCapCuu(); if (row.Cells["ChiTietToaCapCuuGUID"].Value != null && row.Cells["ChiTietToaCapCuuGUID"].Value != DBNull.Value) { cttcc.ChiTietToaCapCuuGUID = Guid.Parse(row.Cells["ChiTietToaCapCuuGUID"].Value.ToString()); } cttcc.CreatedDate = DateTime.Now; cttcc.CreatedBy = Guid.Parse(Global.UserGUID); cttcc.KhoCapCuuGUID = Guid.Parse(row.Cells["KhoCapCuuGUID"].Value.ToString()); if (row.Cells["SoLuong"].Value != null && row.Cells["SoLuong"].Value != DBNull.Value) { cttcc.SoLuong = Convert.ToDouble(row.Cells["SoLuong"].Value); } else { cttcc.SoLuong = 1; } cttcc.Status = (byte)Status.Actived; addedList.Add(cttcc); } Result result = KeToaCapCuuBus.InsertToaCapCuu(_toaCapCuu, addedList, _deletedKeys); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaCapCuuBus.InsertToaCapCuu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("KeToaCapCuuBus.InsertToaCapCuu")); 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); } }
private bool CheckInfo() { if (txtMaToaCapCuu.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng nhập mã toa cấp cứu.", IconType.Information); txtMaToaCapCuu.Focus(); return(false); } if (txtTenBenhNhan.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng chọn tên bệnh nhân.", IconType.Information); txtTenBenhNhan.Focus(); return(false); } string toaCapCuuGUID = _isNew ? string.Empty : _toaCapCuu.ToaCapCuuGUID.ToString(); Result result = KeToaCapCuuBus.CheckToaCapCuuExistCode(toaCapCuuGUID, txtMaToaCapCuu.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 cấp cứu này đã tồn tại rồi. Vui lòng nhập mã khác.", IconType.Information); txtMaToaCapCuu.Focus(); return(false); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("KeToaCapCuuBus.CheckToaCapCuuExistCode"), IconType.Error); return(false); } if (dgChiTiet.RowCount > 1) { for (int i = 0; i < dgChiTiet.RowCount - 1; i++) { DataGridViewRow row = dgChiTiet.Rows[i]; if (row.Cells[1].Value == null || row.Cells[1].Value == DBNull.Value || row.Cells[1].Value.ToString() == Guid.Empty.ToString()) { MsgBox.Show(this.Text, "Vui lòng nhập cấp cứu.", IconType.Information); return(false); } string khoCapCuuGUID = row.Cells[1].Value.ToString(); string tenCapCuu = GetTenCapCuu(khoCapCuuGUID); int soLuong = 1; if (row.Cells[2].Value != null && row.Cells[2].Value != DBNull.Value) { soLuong = Convert.ToInt32(row.Cells[2].Value); } Result r = NhapKhoCapCuuBus.CheckKhoCapCuuTonKho(khoCapCuuGUID, soLuong); if (r.IsOK) { if (!Convert.ToBoolean(r.QueryResult)) { MsgBox.Show(this.Text, string.Format("Cấp cứu '{0}' đã hết hoặc không đủ số lượng để bán. Vui lòng chọn cấp cứu khác.", tenCapCuu), IconType.Information); return(false); } } else { MsgBox.Show(this.Text, r.GetErrorAsString("NhapKhoCapCuuBus.CheckKhoCapCuuTonKho"), IconType.Error); Utility.WriteToTraceLog(r.GetErrorAsString("NhapKhoCapCuuBus.CheckKhoCapCuuTonKho")); return(false); } r = NhapKhoCapCuuBus.CheckKhoCapCuuHetHan(khoCapCuuGUID); if (r.IsOK) { if (Convert.ToBoolean(r.QueryResult)) { MsgBox.Show(this.Text, string.Format("Cấp cứu '{0}' đã hết hạn sử dụng. Vui lòng chọn cấp cứu khác.", tenCapCuu), IconType.Information); return(false); } } else { MsgBox.Show(this.Text, r.GetErrorAsString("NhapKhoCapCuuBus.CheckKhoCapCuuHetHan"), IconType.Error); Utility.WriteToTraceLog(r.GetErrorAsString("NhapKhoCapCuuBus.CheckKhoCapCuuHetHan")); return(false); } } } else { MsgBox.Show(this.Text, "Vui lòng chọn ít nhất 1 cấp cứu.", IconType.Information); return(false); } if (dgChiTiet.RowCount > 2) { for (int i = 0; i < dgChiTiet.RowCount - 2; i++) { DataGridViewRow row1 = dgChiTiet.Rows[i]; for (int j = i + 1; j < dgChiTiet.RowCount - 1; j++) { DataGridViewRow row2 = dgChiTiet.Rows[j]; if (row1.Cells[1].Value.ToString() == row2.Cells[1].Value.ToString()) { string tenCapCuu = GetTenCapCuu(row1.Cells[1].Value.ToString()); MsgBox.Show(this.Text, string.Format("Cấp cứu '{0}' đã tồn tại rồi. Vui lòng chọn cấp cứu khác", tenCapCuu), IconType.Information); return(false); } } } } return(true); }