|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.Common;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using NetLibrary.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
namespace NetLibrary.Data
|
|
|
|
|
{
|
|
|
|
|
public class RefParameter
|
|
|
|
|
{
|
|
|
|
|
public RefParameter()
|
|
|
|
|
{
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, ConditionType Condition, Object Value, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = ConvertConditionType(Condition);
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, ConditionTypeNull Condition)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = ConvertConditionTypeNull(Condition);
|
|
|
|
|
this.Type = DbType.String;
|
|
|
|
|
this.Value = "";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, string Condition, Object Value, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
if (Condition == null || Condition == "") throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
CheckCondition(Condition);
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = Condition;
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name"><3E><><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="Condition"><3E><>ϵ<EFBFBD><CFB5></param>
|
|
|
|
|
/// <param name="Value">ֵ</param>
|
|
|
|
|
/// <param name="Type"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="IsDeclare"><3E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(trueĬ<65><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,false<73><65><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ@<40><>name<6D><65><EFBFBD><EFBFBD>)</param>
|
|
|
|
|
public RefParameter(string name, string Condition, Object Value, DbType Type, bool IsDeclare)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
if (Condition == null || Condition == "") throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
CheckCondition(Condition);
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Condition = Condition;
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
this.IsDeclare = IsDeclare;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, ConditionType Condition, Object Value, DbType Type, bool IsDeclare)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = ConvertConditionType(Condition);
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
this.IsDeclare = IsDeclare;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, string Condition, Object Value, string RelateTo, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
if (Condition == null || Condition == "") throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
CheckCondition(Condition);
|
|
|
|
|
CheckRelateTo(RelateTo);
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = Condition;
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
this.RelateTo = RelateTo;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, string Condition, Object Value, string RelateTo, string EndString, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
if (Condition == null || Condition == "") throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
CheckCondition(Condition);
|
|
|
|
|
CheckRelateTo(RelateTo);
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = Condition;
|
|
|
|
|
this.EndString = EndString;
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
this.RelateTo = RelateTo;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, ConditionType Condition, Object Value, string RelateTo, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
CheckRelateTo(RelateTo);
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = ConvertConditionType(Condition);
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
this.RelateTo = RelateTo;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, string Condition, Object Value, string RelateTo, DbType Type, ParameterDirection Direction)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
if (Condition == null || Condition == "") throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
CheckCondition(Condition);
|
|
|
|
|
CheckRelateTo(RelateTo);
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = Condition;
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
this.RelateTo = RelateTo;
|
|
|
|
|
this.Direction = Direction;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter(string name, ConditionType Condition, Object Value, string RelateTo, DbType Type, ParameterDirection Direction)
|
|
|
|
|
{
|
|
|
|
|
if (name == null || name == "") throw new Exception("<22>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
|
|
|
|
CheckRelateTo(RelateTo);
|
|
|
|
|
this.Caption = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Condition = ConvertConditionType(Condition);
|
|
|
|
|
this.Type = Type;
|
|
|
|
|
this.Value = Value;
|
|
|
|
|
this.RelateTo = RelateTo;
|
|
|
|
|
this.Direction = Direction;
|
|
|
|
|
CheckValue(Value, Type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CheckRelateTo(string RelateTo)
|
|
|
|
|
{
|
|
|
|
|
if (RelateTo != "and" && RelateTo != "or")
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>ϵֻ<CFB5><D6BB><EFBFBD><EFBFBD>and<6E><64><EFBFBD><EFBFBD>or");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CheckCondition(string Condition)
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>д<EFBFBD>
|
|
|
|
|
if (Condition != ">=" && Condition != "<=" && Condition != ">" && Condition != "<" && Condition != "=" && Condition != "<>" && Condition != "in" && Condition != "not in" && Condition != "like left" && Condition != "like right" && Condition != "like" && Condition != "is" && Condition != "is not") throw new Exception("<22><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>Ϊ>,<,=,<>,in, not in,like left,like right,like,is,is not");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region ת<><D7AA>ConditionType<70><65><EFBFBD><EFBFBD>
|
|
|
|
|
private string ConvertConditionType(ConditionType ctype)
|
|
|
|
|
{
|
|
|
|
|
switch (ctype)
|
|
|
|
|
{
|
|
|
|
|
case ConditionType.Equals:
|
|
|
|
|
return "=";
|
|
|
|
|
case ConditionType.Ceiling:
|
|
|
|
|
return ">";
|
|
|
|
|
case ConditionType.CeilingEqual:
|
|
|
|
|
return ">=";
|
|
|
|
|
case ConditionType.Floor:
|
|
|
|
|
return "<";
|
|
|
|
|
case ConditionType.FloorEqual:
|
|
|
|
|
return "<=";
|
|
|
|
|
case ConditionType.NotEquals:
|
|
|
|
|
return "<>";
|
|
|
|
|
case ConditionType.In:
|
|
|
|
|
return "in";
|
|
|
|
|
case ConditionType.NotIn:
|
|
|
|
|
return "not in";
|
|
|
|
|
case ConditionType.LikeLeft:
|
|
|
|
|
return "like left";
|
|
|
|
|
case ConditionType.LikeRight:
|
|
|
|
|
return "like right";
|
|
|
|
|
case ConditionType.Like:
|
|
|
|
|
return "like";
|
|
|
|
|
default:
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ת<><D7AA>ConditionTypeNull<6C><6C><EFBFBD><EFBFBD>
|
|
|
|
|
private string ConvertConditionTypeNull(ConditionTypeNull ctype)
|
|
|
|
|
{
|
|
|
|
|
switch (ctype)
|
|
|
|
|
{
|
|
|
|
|
case ConditionTypeNull.Is:
|
|
|
|
|
return "is";
|
|
|
|
|
case ConditionTypeNull.IsNot:
|
|
|
|
|
return "is not";
|
|
|
|
|
default:
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void CheckValue(Object Value, DbType Type)
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (Value == null || Value.ToString() == "" || Type == DbType.String) return;
|
|
|
|
|
if (this.Condition == "in" || this.Condition == "not in")
|
|
|
|
|
{
|
|
|
|
|
string[] chars1 = Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
foreach (string s in chars1)
|
|
|
|
|
{
|
|
|
|
|
if (Type == DbType.Byte || Type == DbType.Int16 || Type == DbType.Int32 || Type == DbType.Int64)
|
|
|
|
|
{
|
|
|
|
|
if (DataRegex.IsNumberInteger(s) == false) throw new Exception(this.Name + ":" + Value.ToString() + ":ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (DataRegex.IsNumberDouble(s) == false) throw new Exception(this.Name + ":" + Value.ToString() + ":ֻ<><D6BB><EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Type == DbType.DateTime)
|
|
|
|
|
{
|
|
|
|
|
try { Convert.ToDateTime(Value); }
|
|
|
|
|
catch { throw new Exception(Value.ToString() + ":ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD>ʽ"); }
|
|
|
|
|
}
|
|
|
|
|
if (Type == DbType.Byte || Type == DbType.Int16 || Type == DbType.Int32 || Type == DbType.Int64)
|
|
|
|
|
{
|
|
|
|
|
if (DataRegex.IsNumberInteger(Value.ToString()) == false) throw new Exception(this.Name + ":" + Value.ToString() + ":ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (Type == DbType.Currency || Type == DbType.Single || Type == DbType.Decimal || Type == DbType.Double)
|
|
|
|
|
{
|
|
|
|
|
if (DataRegex.IsNumberDouble(Value.ToString()) == false) throw new Exception(this.Name + ":" + Value.ToString() + ":ֻ<><D6BB><EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (Type == DbType.Boolean)
|
|
|
|
|
{
|
|
|
|
|
if (Value.ToString() != "True" && Value.ToString() != "False" && Value.ToString() != "0" && Value.ToString() != "1")
|
|
|
|
|
{
|
|
|
|
|
throw new Exception(this.Name + ":" + Value.ToString() + ":ֻ<><D6BB><EFBFBD><EFBFBD>True<75><65>False<73><65>0<EFBFBD><30>1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string m_Caption;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>б<EFBFBD><D0B1><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Caption
|
|
|
|
|
{
|
|
|
|
|
get { return m_Caption; }
|
|
|
|
|
set { m_Caption = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string m_Name;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return m_Name; }
|
|
|
|
|
set { m_Name = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string m_Condition;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,С<><D0A1>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,in, not in,like,like left,like right)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Condition
|
|
|
|
|
{
|
|
|
|
|
get { return m_Condition; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
CheckCondition(value);
|
|
|
|
|
m_Condition = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Object m_Value;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ֵ
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Object Value
|
|
|
|
|
{
|
|
|
|
|
get { return m_Value; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
CheckValue(value, this.Type);
|
|
|
|
|
if (value != null && value != DBNull.Value && this.Type == DbType.String) { m_Value = value.ToString().Replace("'", "''"); }
|
|
|
|
|
else { m_Value = value; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string m_RelateTo = "and";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ϵ<EFBFBD><CFB5>(and,or)Ĭ<><C4AC>Ϊand
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RelateTo
|
|
|
|
|
{
|
|
|
|
|
get { return m_RelateTo; }
|
|
|
|
|
set { m_RelateTo = value; }
|
|
|
|
|
}
|
|
|
|
|
private string m_EndString = "";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string EndString
|
|
|
|
|
{
|
|
|
|
|
get { return m_EndString; }
|
|
|
|
|
set { m_EndString = value; }
|
|
|
|
|
}
|
|
|
|
|
private System.Data.DbType m_Type = DbType.Object;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public System.Data.DbType Type
|
|
|
|
|
{
|
|
|
|
|
get { return m_Type; }
|
|
|
|
|
set { m_Type = value; }
|
|
|
|
|
}
|
|
|
|
|
private ParameterDirection m_Direction = ParameterDirection.Input;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ParameterDirection Direction
|
|
|
|
|
{
|
|
|
|
|
get { return m_Direction; }
|
|
|
|
|
set { m_Direction = value; }
|
|
|
|
|
}
|
|
|
|
|
private bool m_IsDeclare = true;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(trueĬ<65><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,false<73><65><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ@<40><>name<6D><65><EFBFBD><EFBFBD>)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsDeclare
|
|
|
|
|
{
|
|
|
|
|
get { return m_IsDeclare; }
|
|
|
|
|
set { m_IsDeclare = value; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class RefParameterCollection : List<RefParameter>
|
|
|
|
|
{
|
|
|
|
|
private int m_PageIndex = 1;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ҳ<EFBFBD><D2B3>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int PageIndex
|
|
|
|
|
{
|
|
|
|
|
get { return m_PageIndex; }
|
|
|
|
|
set { m_PageIndex = value; }
|
|
|
|
|
}
|
|
|
|
|
private int m_PageSize = 10;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ÿҳ<C3BF><D2B3>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int PageSize
|
|
|
|
|
{
|
|
|
|
|
get { return m_PageSize; }
|
|
|
|
|
set { m_PageSize = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameterCollection()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
public RefParameterCollection(int PageIndex, int PageSize)
|
|
|
|
|
{
|
|
|
|
|
this.PageIndex = PageIndex;
|
|
|
|
|
this.PageSize = PageSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(string name, ConditionType Condition, Object Value, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, Type));
|
|
|
|
|
}
|
|
|
|
|
public void Add(string name, ConditionTypeNull Condition)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(string name, string Condition, Object Value, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, Type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name"><3E><><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="Condition"><3E><>ϵ<EFBFBD><CFB5></param>
|
|
|
|
|
/// <param name="Value">ֵ</param>
|
|
|
|
|
/// <param name="Type"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="IsDeclare"><3E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(trueĬ<65><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,false<73><65><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ@<40><>name<6D><65><EFBFBD><EFBFBD>)</param>
|
|
|
|
|
public void Add(string name, string Condition, Object Value, DbType Type, bool IsDeclare)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, Type, IsDeclare));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(string name, ConditionType Condition, Object Value, DbType Type, bool IsDeclare)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, Type, IsDeclare));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(string name, string Condition, Object Value, string RelateTo, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, RelateTo, Type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(string name, string Condition, Object Value, string RelateTo, string EndString, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, RelateTo, EndString, Type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(string name, ConditionType Condition, Object Value, string RelateTo, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, RelateTo, Type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(string name, string Condition, Object Value, string RelateTo, DbType Type, ParameterDirection Direction)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, RelateTo, Type, Direction));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(string name, ConditionType Condition, Object Value, string RelateTo, DbType Type, ParameterDirection Direction)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, Condition, Value, RelateTo, Type, Direction));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddOutParameter(string name, DbType Type)
|
|
|
|
|
{
|
|
|
|
|
this.Add(new RefParameter(name, "=", null, "and", Type, ParameterDirection.Output));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Contains(string name)
|
|
|
|
|
{
|
|
|
|
|
foreach (RefParameter pam in this)
|
|
|
|
|
{
|
|
|
|
|
if (pam.Name == name) return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RefParameter this[string name]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
foreach (RefParameter cf in this)
|
|
|
|
|
{
|
|
|
|
|
if (cf.Name == name) return cf;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Remove(string name)
|
|
|
|
|
{
|
|
|
|
|
foreach (RefParameter cf in this)
|
|
|
|
|
{
|
|
|
|
|
if (cf.Name == name) { this.Remove(cf); return; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
|
|
|
|
private string ConvertUnionChar(string value)
|
|
|
|
|
{
|
|
|
|
|
string a = value;
|
|
|
|
|
a = a.ToString().Replace("*", "[*]");
|
|
|
|
|
//a = a.ToString().Replace("~", "[~]");
|
|
|
|
|
//a = a.ToString().Replace("(", "[(]");
|
|
|
|
|
//a = a.ToString().Replace(")", "[)]");
|
|
|
|
|
//a = a.ToString().Replace("#", "[#]");
|
|
|
|
|
//a = a.ToString().Replace("/", "[/]");
|
|
|
|
|
//a = a.ToString().Replace("=", "[=]");
|
|
|
|
|
//a = a.ToString().Replace(">", "[>]");
|
|
|
|
|
//a = a.ToString().Replace("<", "[<]");
|
|
|
|
|
//a = a.ToString().Replace("+", "[+]");
|
|
|
|
|
//a = a.ToString().Replace("-", "[-]");
|
|
|
|
|
//a = a.ToString().Replace("|", "[|]");
|
|
|
|
|
//a = a.ToString().Replace("^", "[^]");
|
|
|
|
|
//a = a.ToString().Replace("%", "[%]");
|
|
|
|
|
//a = a.ToString().Replace("&", "[&]");
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DataTable<6C><65>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
|
|
|
|
|
public string GetDataTableWhere()
|
|
|
|
|
{
|
|
|
|
|
string tsql = "";
|
|
|
|
|
foreach (RefParameter pam in this)
|
|
|
|
|
{
|
|
|
|
|
string value = pam.Value.ToString();
|
|
|
|
|
if (pam.Type == DbType.String) value = ConvertUnionChar(value);
|
|
|
|
|
if (this.IndexOf(pam) == 0)
|
|
|
|
|
{
|
|
|
|
|
switch (pam.Condition)
|
|
|
|
|
{
|
|
|
|
|
case "in":
|
|
|
|
|
if (pam.Type != DbType.String)
|
|
|
|
|
{
|
|
|
|
|
tsql = pam.Name + " in (" + value + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] chars1 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
string ss = "";
|
|
|
|
|
foreach (string s in chars1)
|
|
|
|
|
{
|
|
|
|
|
if (ss == "") { ss = "'" + s + "'"; }
|
|
|
|
|
else { ss = ss + ",'" + s + "'"; }
|
|
|
|
|
}
|
|
|
|
|
tsql = pam.Name + " in (" + ss + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "not in":
|
|
|
|
|
if (pam.Type != DbType.String)
|
|
|
|
|
{
|
|
|
|
|
tsql = pam.Name + " not in (" + value + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] chars2 = value.Split(new char[] { ',' });
|
|
|
|
|
string ss = "";
|
|
|
|
|
foreach (string s in chars2)
|
|
|
|
|
{
|
|
|
|
|
if (ss == "") { ss = "'" + s + "'"; }
|
|
|
|
|
else { ss = ss + ",'" + s + "'"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsql = pam.Name + " not in (" + ss + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "like":
|
|
|
|
|
tsql = pam.Name + " like '%" + value + "%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like left":
|
|
|
|
|
tsql = pam.Name + " like '%" + value + "'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like right":
|
|
|
|
|
tsql = pam.Name + " like '" + value + "%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is":
|
|
|
|
|
tsql = pam.Name + " is null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is not":
|
|
|
|
|
tsql = pam.Name + " is not null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (pam.Type == DbType.String && Convert.ToString(pam.Value) == "")
|
|
|
|
|
{
|
|
|
|
|
tsql = pam.Name + "=''" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Value == null || pam.Value == DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
tsql = pam.Name + " is null" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Type == DbType.String || pam.Type == DbType.DateTime)
|
|
|
|
|
{
|
|
|
|
|
tsql = pam.Name + pam.Condition + "'" + value + "'" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tsql = pam.Name + pam.Condition + value + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (pam.Condition)
|
|
|
|
|
{
|
|
|
|
|
case "in":
|
|
|
|
|
if (pam.Type != DbType.String)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " in (" + value + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] chars3 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
string ss = "";
|
|
|
|
|
foreach (string s in chars3)
|
|
|
|
|
{
|
|
|
|
|
if (ss == "") { ss = "'" + s + "'"; }
|
|
|
|
|
else { ss = ss + ",'" + s + "'"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " in (" + ss + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "not in":
|
|
|
|
|
if (pam.Type != DbType.String)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " not in (" + value + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] chars4 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
string ss = "";
|
|
|
|
|
foreach (string s in chars4)
|
|
|
|
|
{
|
|
|
|
|
if (ss == "") { ss = "'" + s + "'"; }
|
|
|
|
|
else { ss = ss + ",'" + s + "'"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " not in (" + ss + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "like":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like '%" + value + "%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like left":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like '%" + value + "'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like right":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like '" + value + "%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is not":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is not null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "<>":
|
|
|
|
|
if (Convert.ToString(pam.Value) == "")
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " <> ''" + pam.EndString;
|
|
|
|
|
else tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " <>" + pam.Value + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (pam.Type == DbType.String && Convert.ToString(pam.Value) == "")
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + "=''" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Value == null || pam.Value == DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Type == DbType.String || pam.Type == DbType.DateTime)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + pam.Condition + "'" + value + "'" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + pam.Condition + value + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tsql;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public string GetWhere(CommandType CommandType)
|
|
|
|
|
{
|
|
|
|
|
string tsql = "";
|
|
|
|
|
if (this.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
if (CommandType == CommandType.Text)
|
|
|
|
|
{
|
|
|
|
|
foreach (RefParameter pam in this)
|
|
|
|
|
{
|
|
|
|
|
if (pam.Direction != ParameterDirection.Input) continue;
|
|
|
|
|
if (pam.IsDeclare == false) continue; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (tsql.IndexOf("where") == -1)
|
|
|
|
|
{
|
|
|
|
|
switch (pam.Condition)
|
|
|
|
|
{
|
|
|
|
|
case "in":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " " + pam.Condition + " (@" + pam.Caption + "0";
|
|
|
|
|
string[] chars1 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
for (int i = 1; i < chars1.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " ,@" + pam.Caption + i.ToString();
|
|
|
|
|
}
|
|
|
|
|
tsql = tsql + ")" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "not in":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " " + pam.Condition + " (@" + pam.Caption + "0";
|
|
|
|
|
string[] chars2 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
for (int i = 1; i < chars2.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " ,@" + pam.Caption + i.ToString();
|
|
|
|
|
}
|
|
|
|
|
tsql = tsql + ")" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " like '%'+" + "@" + pam.Caption + "+'%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like left":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " like '%'+" + "@" + pam.Caption + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like right":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " like " + "@" + pam.Caption + "+'%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is not":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " is not null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (pam.Type == DbType.String && Convert.ToString(pam.Value) == "")
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " where " + pam.Name + "=''" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Value == null || pam.Value == DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " where " + pam.Name + pam.Condition + "@" + pam.Caption + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (pam.Condition)
|
|
|
|
|
{
|
|
|
|
|
case "in":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " " + pam.Condition + " (@" + pam.Caption + "0";
|
|
|
|
|
string[] chars3 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
for (int i = 1; i < chars3.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " ,@" + pam.Caption + i.ToString();
|
|
|
|
|
}
|
|
|
|
|
tsql = tsql + ")" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "not in":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " " + pam.Condition + " (@" + pam.Caption + "0";
|
|
|
|
|
string[] chars4 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
for (int i = 1; i < chars4.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " ,@" + pam.Caption + i.ToString();
|
|
|
|
|
}
|
|
|
|
|
tsql = tsql + ")" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like '%'+" + "@" + pam.Caption + "+'%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like left":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like '%'+" + "@" + pam.Caption + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like right":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like " + "@" + pam.Caption + "+'%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is not":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is not null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "<>":
|
|
|
|
|
if (Convert.ToString(pam.Value) == "")
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " <> ''" + pam.EndString;
|
|
|
|
|
else tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " <>" + pam.Value + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (pam.Type == DbType.String && Convert.ToString(pam.Value) == "")
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + "=''" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Value == null || pam.Value == DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + pam.Condition + "@" + pam.Caption + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (RefParameter pam in this)
|
|
|
|
|
{
|
|
|
|
|
if (pam.Direction != ParameterDirection.Input) continue;
|
|
|
|
|
if (pam.IsDeclare == false) continue; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (tsql.IndexOf("where") == -1)
|
|
|
|
|
{
|
|
|
|
|
switch (pam.Condition)
|
|
|
|
|
{
|
|
|
|
|
case "in":
|
|
|
|
|
if (pam.Type != DbType.String)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " in (" + pam.Value.ToString() + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] chars1 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
string ss = "";
|
|
|
|
|
foreach (string s in chars1)
|
|
|
|
|
{
|
|
|
|
|
if (ss == "") { ss = "'" + s + "'"; }
|
|
|
|
|
else { ss = ss + ",'" + s + "'"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " in (" + ss + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "not in":
|
|
|
|
|
if (pam.Type != DbType.String)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " not in (" + pam.Value.ToString() + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] chars2 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
string ss = "";
|
|
|
|
|
foreach (string s in chars2)
|
|
|
|
|
{
|
|
|
|
|
if (ss == "") { ss = "'" + s + "'"; }
|
|
|
|
|
else { ss = ss + ",'" + s + "'"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " not in (" + ss + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "like":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " like '%" + pam.Value.ToString() + "%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like left":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " like '%" + pam.Value.ToString() + "'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like right":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " like '" + pam.Value.ToString() + "%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is not":
|
|
|
|
|
tsql = tsql + " where " + pam.Name + " is not null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
if (pam.Type == DbType.String && Convert.ToString(pam.Value) == "")
|
|
|
|
|
{
|
|
|
|
|
tsql = " where " + pam.Name + "=''" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Value == null || pam.Value == DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
tsql = " where " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Type == DbType.String || pam.Type == DbType.DateTime)
|
|
|
|
|
{
|
|
|
|
|
tsql = " where " + pam.Name + pam.Condition + "'" + pam.Value.ToString() + "'" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tsql = " where " + pam.Name + pam.Condition + pam.Value.ToString() + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (pam.Condition)
|
|
|
|
|
{
|
|
|
|
|
case "in":
|
|
|
|
|
if (pam.Type != DbType.String)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " in (" + pam.Value.ToString() + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] chars3 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
string ss = "";
|
|
|
|
|
foreach (string s in chars3)
|
|
|
|
|
{
|
|
|
|
|
if (ss == "") { ss = "'" + s + "'"; }
|
|
|
|
|
else { ss = ss + ",'" + s + "'"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " in (" + ss + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "not in":
|
|
|
|
|
if (pam.Type != DbType.String)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " not in (" + pam.Value.ToString() + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] chars4 = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
string ss = "";
|
|
|
|
|
foreach (string s in chars4)
|
|
|
|
|
{
|
|
|
|
|
if (ss == "") { ss = "'" + s + "'"; }
|
|
|
|
|
else { ss = ss + ",'" + s + "'"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " not in (" + ss + ")" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "like":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like '%" + pam.Value.ToString() + "%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like left":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like '%" + pam.Value.ToString() + "'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "like right":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " like '" + pam.Value.ToString() + "%'" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "is not":
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is not null" + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
case "<>":
|
|
|
|
|
if (Convert.ToString(pam.Value) == "")
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " <> ''" + pam.EndString;
|
|
|
|
|
else tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " <>" + pam.Value + pam.EndString;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (pam.Type == DbType.String && Convert.ToString(pam.Value) == "")
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + "=''" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Value == null || pam.Value == DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + " is null" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else if (pam.Type == DbType.String || pam.Type == DbType.DateTime)
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + pam.Condition + "'" + pam.Value.ToString() + "'" + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tsql = tsql + " " + pam.RelateTo + " " + pam.Name + pam.Condition + pam.Value.ToString() + pam.EndString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tsql;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public System.Data.SqlClient.SqlParameter[] GetParameter()
|
|
|
|
|
{
|
|
|
|
|
List<System.Data.SqlClient.SqlParameter> list = new List<System.Data.SqlClient.SqlParameter>();
|
|
|
|
|
if (this.Count == 0) return list.ToArray();
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (RefParameter pam in this)
|
|
|
|
|
{
|
|
|
|
|
int index = this.IndexOf(pam);
|
|
|
|
|
if (pam.Direction == ParameterDirection.Input)
|
|
|
|
|
{
|
|
|
|
|
if (pam.IsDeclare == true)
|
|
|
|
|
{
|
|
|
|
|
if (pam.Condition == "in" || pam.Condition == "not in")
|
|
|
|
|
{
|
|
|
|
|
string[] chars = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
i = 0;
|
|
|
|
|
foreach (string s in chars)
|
|
|
|
|
{
|
|
|
|
|
list.Add(new System.Data.SqlClient.SqlParameter() { ParameterName = pam.Caption + i.ToString(), DbType = pam.Type, Value = s });
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (pam.Value != null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(new System.Data.SqlClient.SqlParameter() { ParameterName = pam.Caption, DbType = pam.Type, Value = pam.Value });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list.Add(new System.Data.SqlClient.SqlParameter() { ParameterName = pam.Name, DbType = pam.Type, Value = pam.Value });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list.Add(new System.Data.SqlClient.SqlParameter() { ParameterName = pam.Name, DbType = pam.Type, Direction = ParameterDirection.Output });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list.ToArray();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public System.Data.OleDb.OleDbParameter[] GetOledbParameter()
|
|
|
|
|
{
|
|
|
|
|
List<System.Data.OleDb.OleDbParameter> list = new List<System.Data.OleDb.OleDbParameter>();
|
|
|
|
|
if (this.Count == 0) return list.ToArray();
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (RefParameter pam in this)
|
|
|
|
|
{
|
|
|
|
|
int index = this.IndexOf(pam);
|
|
|
|
|
if (pam.Direction == ParameterDirection.Input)
|
|
|
|
|
{
|
|
|
|
|
if (pam.IsDeclare == true)
|
|
|
|
|
{
|
|
|
|
|
if (pam.Condition == "in" || pam.Condition == "not in")
|
|
|
|
|
{
|
|
|
|
|
string[] chars = pam.Value.ToString().Split(new char[] { ',' });
|
|
|
|
|
i = 0;
|
|
|
|
|
foreach (string s in chars)
|
|
|
|
|
{
|
|
|
|
|
list.Add(new System.Data.OleDb.OleDbParameter() { ParameterName = pam.Caption + i.ToString(), DbType = pam.Type, Value = s });
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (pam.Value != null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(new System.Data.OleDb.OleDbParameter() { ParameterName = pam.Caption, DbType = pam.Type, Value = pam.Value });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list.Add(new System.Data.OleDb.OleDbParameter() { ParameterName = pam.Name, DbType = pam.Type, Value = pam.Value });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list.Add(new System.Data.OleDb.OleDbParameter() { ParameterName = pam.Name, DbType = pam.Type, Direction = ParameterDirection.Output });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list.ToArray();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum ConditionType
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>=
|
|
|
|
|
/// </summary>
|
|
|
|
|
Equals = 0,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>>
|
|
|
|
|
/// </summary>
|
|
|
|
|
Ceiling = 1,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>(>=)
|
|
|
|
|
/// </summary>
|
|
|
|
|
CeilingEqual = 2,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// С<><D0A1>(<)
|
|
|
|
|
/// </summary>
|
|
|
|
|
Floor = 3,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// С<>ڵ<EFBFBD><DAB5><EFBFBD>(<=)
|
|
|
|
|
/// </summary>
|
|
|
|
|
FloorEqual = 4,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<>)
|
|
|
|
|
/// </summary>
|
|
|
|
|
NotEquals = 5,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// in
|
|
|
|
|
/// </summary>
|
|
|
|
|
In = 6,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// not in
|
|
|
|
|
/// </summary>
|
|
|
|
|
NotIn = 7,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// like left
|
|
|
|
|
/// </summary>
|
|
|
|
|
LikeLeft = 8,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// like right
|
|
|
|
|
/// </summary>
|
|
|
|
|
LikeRight = 9,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// like
|
|
|
|
|
/// </summary>
|
|
|
|
|
Like = 10
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum ConditionTypeNull
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// is
|
|
|
|
|
/// </summary>
|
|
|
|
|
Is = 0,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// is not
|
|
|
|
|
/// </summary>
|
|
|
|
|
IsNot = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum EditDataType
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ǰʹ<C7B0><CAB9>DataSet<65><74><EFBFBD><EFBFBD>DataTable<6C><65><EFBFBD><EFBFBD>Դ
|
|
|
|
|
/// </summary>
|
|
|
|
|
DataSetIndex,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ǰʹ<C7B0><CAB9>DataView<65><77><EFBFBD><EFBFBD>Դ
|
|
|
|
|
/// </summary>
|
|
|
|
|
DataViewIndex
|
|
|
|
|
}
|
|
|
|
|
}
|