我有 Windows 表單應用程式,我想防止為同一名患者重復下單
我檢查病人今天是否有訂單,如果我嘗試下另一個訂單,它會顯示訊息
患者今天有訂單,然后單擊確定按鈕時我需要關閉視窗,但單擊確定按鈕時不會關閉視窗,
這是我使用的代碼:
var patientNumber = order.GetPatientNumber(Convert.ToInt32(textPatientID.Text),Program.branch_id); // int?
bool patientExists = patientNumber.HasValue;
if (patientExists == true)
{
DialogResult dialogResult = MessageBox.Show("PATIENT HAS ORDER TODAY ", "DUPLICATE ORDER ", MessageBoxButtons.OK, MessageBoxIcon.Stop);
if (dialogResult == DialogResult.OK)
{
this.Close();
}
}
我也嘗試關閉表單,但也沒有關閉:
var patientNumber = order.GetPatientNumber(Convert.ToInt32(textPatientID.Text),Program.branch_id); // int?
bool patientExists = patientNumber.HasValue;
if (patientExists == true)
{
DialogResult dialogResult = MessageBox.Show("PATIENT HAS ORDER TODAY ", "DUPLICATE ORDER ", MessageBoxButtons.OK, MessageBoxIcon.Stop);
this.Close();
}
為什么它不關閉有什么問題請您幫忙?
uj5u.com熱心網友回復:
我看不出任何原因
if (dialogResult == DialogResult.OK)
檢查,因為對話框有唯一的 OK按鈕:
if (order
.GetPatientNumber(int.Parse(textPatientID.Text), Program.branch_id)
.HasValue) {
MessageBox.Show(
"PATIENT HAS ORDER TODAY",
"DUPLICATE ORDER",
MessageBoxButtons.OK,
MessageBoxIcon.Stop);
Close();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/392599.html
標籤:C#
