public SearchCtrl CrtSearchCtrl(TableInfo tblInfo, int iCol, Point pos, Size size, SearchCtrl.SearchMode mode) { TableInfo.ColInfo col = tblInfo.m_cols[iCol]; switch (col.m_type) { case TableInfo.ColInfo.ColType.text: case TableInfo.ColInfo.ColType.uniq: SearchCtrlText textCtrl = new SearchCtrlText(col.m_field, col.m_alias, SearchCtrl.CtrlType.text, pos, size); textCtrl.m_mode = mode; textCtrl.m_colInfo = col; return(textCtrl); case TableInfo.ColInfo.ColType.dateTime: lSearchCtrlDate dateCtrl = new lSearchCtrlDate(col.m_field, col.m_alias, SearchCtrl.CtrlType.dateTime, pos, size); return(dateCtrl); case TableInfo.ColInfo.ColType.num: lSearchCtrlNum numCtrl = new lSearchCtrlNum(col.m_field, col.m_alias, SearchCtrl.CtrlType.num, pos, size); return(numCtrl); case TableInfo.ColInfo.ColType.currency: lSearchCtrlCurrency currencyCtrl = new lSearchCtrlCurrency(col.m_field, col.m_alias, SearchCtrl.CtrlType.currency, pos, size); return(currencyCtrl); case TableInfo.ColInfo.ColType.map: SearchCtrlEnum srchCtrl = new SearchCtrlEnum(col.m_field, col.m_alias, SearchCtrl.CtrlType.map, pos, size); srchCtrl.m_colInfo = col; return(srchCtrl); } return(null); }
public void Add(string col, string arg1, SearchCtrl.SearchMode mode = SearchCtrl.SearchMode.match) { Debug.Assert(m_dict.ContainsKey(col)); TableInfo.ColInfo colInfo = m_dict[col]; switch (colInfo.m_type) { case TableInfo.ColInfo.ColType.text: case TableInfo.ColInfo.ColType.num: case TableInfo.ColInfo.ColType.uniq: case TableInfo.ColInfo.ColType.map: break; default: Debug.Assert(false); break; } #if use_sqlite if (mode == SearchCtrl.SearchMode.like) { exprs.Add(string.Format("({0} like @{0})", colInfo.m_field)); srchParams.Add( new SearchParam() { key = string.Format("@{0}", colInfo.m_field), val = string.Format("%{0}%", arg1) } ); } else { exprs.Add(string.Format("({0}=@{0})", colInfo.m_field)); srchParams.Add( new SearchParam() { key = string.Format("@{0}", colInfo.m_field), val = arg1 } ); } #else //use sql server exprs.Add(string.Format("({0} like @{0})", m_fieldName)); srchParams.Add( new lSearchParam() { key = string.Format("@{0}", m_fieldName), val = string.Format("%{0}%", m_value), type = DbType.String } ); //exprs.Add(string.Format("({0} like @{0})", m_fieldName)); //srchParams.Add(string.Format("@{0}", m_fieldName), string.Format("%{0}%", m_value)); #endif }
public void Add(string col, List <string> args) { Debug.Assert(m_dict.ContainsKey(col)); TableInfo.ColInfo colInfo = m_dict[col]; switch (colInfo.m_type) { case TableInfo.ColInfo.ColType.text: case TableInfo.ColInfo.ColType.num: case TableInfo.ColInfo.ColType.uniq: case TableInfo.ColInfo.ColType.map: break; default: Debug.Assert(false); break; } #if use_sqlite var keys = new List <string>(); for (int i = 0; i < args.Count; i++) { var key = string.Format("@{0}_{1}", colInfo.m_field, i); srchParams.Add( new SearchParam() { key = key, val = string.Format("{0}", args[i]) } ); keys.Add(key); } exprs.Add(string.Format("( {0} in ({1}) )", colInfo.m_field, string.Join(",", keys))); #else //use sql server exprs.Add(string.Format("({0} like @{0})", m_fieldName)); srchParams.Add( new lSearchParam() { key = string.Format("@{0}", m_fieldName), val = string.Format("%{0}%", m_value), type = DbType.String } ); //exprs.Add(string.Format("({0} like @{0})", m_fieldName)); //srchParams.Add(string.Format("@{0}", m_fieldName), string.Format("%{0}%", m_value)); #endif }
public void Add(string col, string arg1, bool isWhere = false) { Debug.Assert(m_dict.ContainsKey(col)); TableInfo.ColInfo colInfo = m_dict[col]; switch (colInfo.m_type) { case TableInfo.ColInfo.ColType.text: case TableInfo.ColInfo.ColType.num: case TableInfo.ColInfo.ColType.uniq: case TableInfo.ColInfo.ColType.map: break; default: Debug.Assert(false); break; } #if use_sqlite { List <string> tExpr = isWhere ?whereExprs: setExprs; tExpr.Add(string.Format("{0}=@{0}", colInfo.m_field)); srchParams.Add( new SearchParam() { key = string.Format("@{0}", colInfo.m_field), val = arg1 } ); } #else //use sql server exprs.Add(string.Format("({0} like @{0})", m_fieldName)); srchParams.Add( new lSearchParam() { key = string.Format("@{0}", m_fieldName), val = string.Format("%{0}%", m_value), type = DbType.String } ); //exprs.Add(string.Format("({0} like @{0})", m_fieldName)); //srchParams.Add(string.Format("@{0}", m_fieldName), string.Format("%{0}%", m_value)); #endif }
public void Add(string col, DateTime date) { Debug.Assert(m_dict.ContainsKey(col)); TableInfo.ColInfo colInfo = m_dict[col]; Debug.Assert(colInfo.m_type == TableInfo.ColInfo.ColType.dateTime); setExprs.Add(string.Format("{0}=@startDate", colInfo.m_field)); string zStartDate = date.ToString(lConfigMng.GetDateFormat()); srchParams.Add( new SearchParam() { key = "@startDate", val = string.Format("{0} 00:00:00", zStartDate), type = DbType.Date } ); }