c# 利用委托返回控件的值

private delegate string mydelMember(); //声明委托

private string GetSearchWhere() //委托执行的方法
{
string result = string.Empty;

if (myTextBoxMemberID.Text.Trim() != "")
{
result = " and memberid='" + myTextBoxMemberID.Text.Trim() + "'";
}

if (myTextBoxMemberName.Text.Trim() != "")
{
result += " and membername like '%" + myTextBoxMemberName.Text.Trim() + "%'";
}

if (myTextBoxIDCard.Text.Trim() != "")
{
result += " and idcard = '" + myTextBoxIDCard.Text.Trim() + "'";
}

if (myTextBoxGZDW.Text.Trim() != "")
{
result += " and gzdw like '%" + myTextBoxGZDW.Text.Trim() + "%'";
}

if (myTextBoxjfdy .Text.Trim() != "")
{
result += " and xsjf >= " + myTextBoxjfdy.Text.Trim() + "";
}

if (myTextBoxjfxy .Text.Trim() != "")
{
result += " and xsjf <= " + myTextBoxjfxy.Text.Trim() + "";
}

if (comBoxPricType.Items.Count > 0)
{
if (comBoxPricType.SelectedIndex >= 0)
{
result += " and prictypeid = '" + comBoxPricType.Items[comBoxPricType.SelectedIndex].ToString().Substring(0, comBoxPricType.Items[comBoxPricType.SelectedIndex].ToString().IndexOf(".")) + "'";
}
}
if (myTextBoxZKL.Text.Trim()!="" )
{
result += " and zkrate <" + myTextBoxZKL.Text.Trim() + "";
}

return result;
}

//调用:

mydelMember strSearChWhere = new mydelMember(this.GetSearchWhere);

string strTemp = strSearChWhere();


你可能感兴趣的:(c# 利用委托返回控件的值)