【发布时间】:2010-10-15 13:36:34
【问题描述】:
我对 winforms 和 C# 比较陌生,我正在开发一个允许用户执行搜索的应用程序。要搜索数据,他们可以使用以下方法:
-具有 6 个选项的组合框
-他们将根据选择的组合框搜索输入信息的文本框。
我有一个存储过程,每个搜索选项都有一个参数。该过程适用于搜索任何选项。此过程已添加到项目中,我通过 TableAdapter 连接到它。
我正在努力将这些搜索条件中的每一个传递给代码的最佳方式。我是这样开始的:
public void DataRefresh(string searchCombo, string searchValue)
{
string returnMessage = string.Empty;
switch (searchCombo)
{
case "Acct":
Data.Manager.TAM.SearchDataTableAdapter.Fill(DataSet.spSearchData, ref returnMessage, searchValue, null, null, null, null, null);
break;
}
SearchDataBindingSource.DataSource = DataSet.spSearchData;
}
我最初认为我可以根据用户发送的内容使用 switch/case 来传递参数。
有没有更好的方法来做到这一点?我想是的,但我似乎想不出办法。
任何建议都会很棒!
【问题讨论】: