首页上一页 1 下一页尾页 3 条记录 1/1页
代码看不懂
发表在C#图书答疑
2009-06-03
是否精华
是
否
版块置顶:
是
否
private void button1_Click(object sender, EventArgs e)
{
#region//生成SQL
#region//生成where条件字符串
strSql.Append("select * from view_house where ");
if (strMidle.IndexOf("house_companyName")!=-1)
{
if (strWhere != string.Empty)
{
strWhere += "and " + "物业名称 like '%" + this.txtName.Text.Trim().ToString() + "%'" ;
}
else
{
strWhere += "物业名称 like '%" + this.txtName.Text.Trim().ToString() + "%'";
}
strMidle=strMidle.Replace("house_companyName", "#");
}
if (strMidle.IndexOf("huose_typeID")!= -1)
{
if (strWhere != string.Empty)
{
strWhere += "and " + "类型='" + this.cboXing.Text.ToString() + "'" ;
}
else
{
strWhere += "类型='" + this.cboXing.Text.ToString() + "'" ;
}
strMidle=strMidle.Replace("huose_typeID", "#");
这段有一些地方看不懂,还有
try
{
string strS = strWhere.Substring(strWhere.Length - 4);
if (strS.Trim() == "and")
{
strWhere = strWhere.Substring(0, strWhere.Length - 4);//去掉尾and
}
}
catch { return; }
这段也不懂
麻烦小科老师能详细点的给我讲解一下,谢谢
{
#region//生成SQL
#region//生成where条件字符串
strSql.Append("select * from view_house where ");
if (strMidle.IndexOf("house_companyName")!=-1)
{
if (strWhere != string.Empty)
{
strWhere += "and " + "物业名称 like '%" + this.txtName.Text.Trim().ToString() + "%'" ;
}
else
{
strWhere += "物业名称 like '%" + this.txtName.Text.Trim().ToString() + "%'";
}
strMidle=strMidle.Replace("house_companyName", "#");
}
if (strMidle.IndexOf("huose_typeID")!= -1)
{
if (strWhere != string.Empty)
{
strWhere += "and " + "类型='" + this.cboXing.Text.ToString() + "'" ;
}
else
{
strWhere += "类型='" + this.cboXing.Text.ToString() + "'" ;
}
strMidle=strMidle.Replace("huose_typeID", "#");
这段有一些地方看不懂,还有
try
{
string strS = strWhere.Substring(strWhere.Length - 4);
if (strS.Trim() == "and")
{
strWhere = strWhere.Substring(0, strWhere.Length - 4);//去掉尾and
}
}
catch { return; }
这段也不懂
麻烦小科老师能详细点的给我讲解一下,谢谢