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();


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值