📄 wherestatement.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace rsgl.baseClass1
{
public class whereStatement
{
private string tableName;
public whereStatement()
{
}
public whereStatement(string tableName)
{
this.tableName = tableName;
}
//构造单一条件的方法
public string conditionStatement(baseClass1.tableInfo tableinfo, string searchType)
{
string columnstring = "";
string columnvalue = "";
columnstring = tableinfo.ColumnName;
if (tableinfo.ColumnType == "char" || tableinfo.ColumnType == "varChar" || tableinfo.ColumnType == "dateTime")
{
if (searchType == "like")
{
columnvalue = "'%" + tableinfo.ColumnValue + "%'";
}
else
{
columnvalue = "'" + tableinfo.ColumnValue + "'";
}
}
else
{
columnvalue = tableinfo.ColumnValue;
}
columnstring = columnstring + " "+searchType +" "+ columnvalue;
return columnstring;
}
//构造where子句的方法
public string whereSql(baseClass1.tableInfo[] tableinfos, string[] serchTypes, string[] status, bool isMulti)
{
StringBuilder wheresql = new StringBuilder("where ");
if (!isMulti)
{
wheresql.Append(conditionStatement(tableinfos[0], serchTypes[0]));
}
else
{
for (int i = 0; i < tableinfos.Length; i++)
{
if (i == 0)
{
wheresql.Append(conditionStatement(tableinfos[i], serchTypes[i]));
}
else
{
wheresql.Append(" " + status[i - 1] + " " + conditionStatement(tableinfos[i], serchTypes[i]));
}
}
}
return wheresql.ToString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -