[英]How to simplify my C# Code
我正在使用DevExpress開發Windows窗體應用程序。 我需要簡化我的C#代碼以下是我使用的代碼:
if (srch_lookup_chequebookno.Text == "Auto")
{
MessageBox.Show("ChequeBook No : "+chequebookno+ " Saved Successfully.", MessageBoxButtons.OK, MessageBoxIcon.Information);
dtgridview = iCubeERP.Accounts.FinanceTransactions.BOChequeBook.getchequedetails("GridValue", chequebookno, "", "", "");
}
else
{
MessageBox.Show("ChequeBook No : " + srch_lookup_chequebookno.Text + " Updated Successfully.", MessageBoxButtons.OK, MessageBoxIcon.Information);
dtgridview = iCubeERP.Accounts.FinanceTransactions.BOChequeBook.getchequedetails("GridValue", srch_lookup_chequebookno.Text, "", "", "");
}
根據您的錯誤信息,看來你dateEdit_periodfrom變量是DateEdit型(不SearchLookupEdit)的。 DateEdit不提供DataSource屬性。 確保使用正確的變量來完成任務。
您必須始終在過程完成之后放置成功消息框,以確保顯示成功消息后不會觸發異常。 為了使其更具可讀性,我添加了另一行代碼
if (srch_lookup_chequebookno.Text == "Auto")
{
dtgridview = iCubeERP.Accounts.FinanceTransactions.BOChequeBook.getchequedetails("GridValue", chequebookno, "", "", "");
string msg = string.Format("ChequeBook No: {0} Saved Successfully", chequebookno);
MessageBox.Show(msg, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
dtgridview = iCubeERP.Accounts.FinanceTransactions.BOChequeBook.getchequedetails("GridValue", srch_lookup_chequebookno.Text, "", "", "");
string msg = string.Format("ChequeBook No: {0} Updated Successfully", srch_lookup_chequebookno);
MessageBox.Show(msg, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.