private bool CheckInfo() { if (cboKhoCapCuu.SelectedValue == null || cboKhoCapCuu.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng chọn thông tin cấp cứu.", IconType.Information); cboKhoCapCuu.Focus(); return(false); } if (numSoLuongXuat.Value <= 0) { MsgBox.Show(this.Text, "Vui lòng nhập số lượng xuất.", IconType.Information); numSoLuongXuat.Focus(); return(false); } string khoCapCuuGUID = cboKhoCapCuu.SelectedValue.ToString(); Result r = NhapKhoCapCuuBus.CheckKhoCapCuuTonKho(khoCapCuuGUID, (int)numSoLuongXuat.Value); 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 để xuất.", cboKhoCapCuu.Text), 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.", cboKhoCapCuu.Text), IconType.Information); return(false); } } else { MsgBox.Show(this.Text, r.GetErrorAsString("NhapKhoCapCuuBus.CheckKhoCapCuuHetHan"), IconType.Error); Utility.WriteToTraceLog(r.GetErrorAsString("NhapKhoCapCuuBus.CheckKhoCapCuuHetHan")); return(false); } return(true); }
private bool CheckInfo() { if (txtMaPhieuThu.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng nhập mã phiếu thu.", IconType.Information); txtMaPhieuThu.Focus(); return(false); } if (cboMaToaCapCuu.SelectedValue == null || cboMaToaCapCuu.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng nhập mã toa thuốc.", IconType.Information); cboMaToaCapCuu.Focus(); return(false); } //string phieuThuCapCuuGUID = _isNew ? string.Empty : _phieuThuCapCuu.PhieuThuCapCuuGUID.ToString(); //Result result = PhieuThuCapCuuBus.CheckPhieuThuCapCuuExistCode(phieuThuCapCuuGUID, txtMaPhieuThu.Text); //if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST) //{ // if (result.Error.Code == ErrorCode.EXIST) // { // MsgBox.Show(this.Text, "Mã phiếu thu này đã tồn tại rồi. Vui lòng nhập mã khác.", IconType.Information); // txtMaPhieuThu.Focus(); // return false; // } //} //else //{ // MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuCapCuuBus.CheckPhieuThuCapCuuExistCode"), IconType.Error); // return false; //} if (dgChiTiet.RowCount > 0) { for (int i = 0; i < dgChiTiet.RowCount; i++) { DataGridViewRow row = dgChiTiet.Rows[i]; //if (row.Cells["KhoCapCuuGUID"].Value == null || row.Cells["KhoCapCuuGUID"].Value == DBNull.Value || //row.Cells["KhoCapCuuGUID"].Value.ToString() == string.Empty) //{ // MsgBox.Show(this.Text, "Vui lòng chọn cấp cứu để xuất phiếu thu.", IconType.Information); // return false; //} string khoCapCuuGUID = row.Cells["KhoCapCuuGUID"].Value.ToString(); string tenCapCuu = GetTenCapCuu(khoCapCuuGUID); if (row.Cells[4].Value.ToString() == "0") { MsgBox.Show(this.Text, string.Format("Cấp cứu '{0}' chưa có nhập giá bán. Vui lòng chọn cấp cứu khác.", tenCapCuu), IconType.Information); return(false); } int soLuong = 1; if (row.Cells[3].Value != null && row.Cells[3].Value != DBNull.Value) { soLuong = Convert.ToInt32(row.Cells[3].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 > 1) //{ // for (int i = 0; i < dgChiTiet.RowCount - 1; i++) // { // DataGridViewRow row1 = dgChiTiet.Rows[i]; // for (int j = i + 1; j < dgChiTiet.RowCount; j++) // { // DataGridViewRow row2 = dgChiTiet.Rows[j]; // if (row1.Cells["KhoCapCuuGUID"].Value.ToString() == row2.Cells["KhoCapCuuGUID"].Value.ToString()) // { // string tenCapCuu = GetTenCapCuu(row1.Cells["KhoCapCuuGUID"].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); }
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); }