
/**//// <summary>
/// Class2 的摘要说明。
/// </summary>
public class QuerySet

{
private ObjectDictionary z_dicConditions;
private string z_strTableName;
public QuerySet(string strTableName)

{
//
// TODO: 在此处添加构造函数逻辑
//
z_dicConditions = new ObjectDictionary();
this.z_strTableName = strTableName;
}
public void AddCellModalCondition(string strCellModalName, EnumConditionType enumType, string strValue)

{
if (strValue == null || strValue == "")
return;
z_dicConditions[strCellModalName] = String.Format(" {0} {1} '{2}' ", strCellModalName, this.EnumConditionType2SqlSymbol(enumType), strValue);
}

//2005.03.20

public void AddStringCondition(string strDataItemName, StringConditionType enumType, string strValue)

{
if (strValue == null || strValue == "")
return;
z_dicConditions[strDataItemName] = String.Format(" {0} {1} '{2}' ", strDataItemName, this.StringConditionType2SqlSymbol(enumType), strValue);
}

public void AddNumberCondition(string strDataItemName, NumberConditionType enumType, string strValue)

{
if (strValue == null || strValue == "")
return;
z_dicConditions[strDataItemName] = String.Format(" {0} {1} {2} ", strDataItemName, this.NumberConditionType2SqlSymbol(enumType), strValue);
}

public void AddDateTimeCondition(string strDataItemName, DateTimeConditionType enumType, string strValue)

{
if (strValue == null || strValue == "" || strValue == new DateTime(1, 1, 1).ToString())

return ;
//strValue = " to_date('" + strValue + "','YYYY-MM-DD hh24:mi:ss') ";
z_dicConditions[strDataItemName] = String.Format(" {0} {1} '{2}' ", strDataItemName, this.DateTimeConditionType2SqlSymbol(enumType), strValue);
}

public void AddEnumCondition(string strDataItemName, EnumConditionType enumType, string strValue)

{
if (strValue == null || strValue == "" || strValue == "0")
return;
z_dicConditions[strDataItemName] = String.Format(" {0} {1} {2} ", strDataItemName, this.EnumConditionType2SqlSymbol(enumType), strValue);
}


private string StringConditionType2SqlSymbol(StringConditionType enumType)

{
switch (enumType)

{
case StringConditionType.匹配:
return " like ";
case StringConditionType.等于:
return " = ";
default:
throw new Exception("无法识别的枚举值!");
}
}

private string NumberConditionType2SqlSymbol(NumberConditionType enumType)

{
switch (enumType)

{
case NumberConditionType.大于:
return " > ";
case NumberConditionType.大于等于:
return " >= ";
case NumberConditionType.小于:
return " < ";
case NumberConditionType.小于等于:
return " <= ";
case NumberConditionType.等于:
return " = ";
case NumberConditionType.不等于:
return "<>";
default:
throw new Exception("无法识别的枚举值!");

}
}

private string DateTimeConditionType2SqlSymbol(DateTimeConditionType enumType)

{
switch (enumType)

{
case DateTimeConditionType.早于:
return " < ";
case DateTimeConditionType.晚于:
return " > ";
case DateTimeConditionType.等于:
return " = ";
default:
throw new Exception("无法识别的枚举值!");
}
}

private string EnumConditionType2SqlSymbol(EnumConditionType enumType)

{
switch (enumType)

{
case EnumConditionType.等于:
return " = ";
case EnumConditionType.不等于:
return " <> ";
default:
throw new Exception("无法识别的枚举值!");
}
}


public string ConditionText

{
get

{
string strConditionText = "";
if (this.z_dicConditions.Values.Length == 0) return strConditionText;
for (int i = 0; i < this.z_dicConditions.Values.Length; i++)

{
strConditionText += this.z_dicConditions.Values[i].ToString();
if (i + 1 < this.z_dicConditions.Values.Length)
strConditionText += " AND ";
}
z_dicConditions.Clear();
return String.Format(" SELECT * FROM {0} WHERE {1}", this.z_strTableName, strConditionText);
}
}

}



public enum StringConditionType
{ 匹配, 等于 };

public enum NumberConditionType
{ 等于, 大于, 大于等于, 小于, 小于等于, 不等于 };

public enum DateTimeConditionType
{ 等于, 晚于, 早于 };

public enum EnumConditionType
{ 等于, 不等于 };

public enum DataItemType
{ 未选择, 数字, 日期, 字符串 };

public enum BooleanValue
{ 未选择, 是, 否 };

public enum CellModal
{ 未选择, FDD_mode,TDD_mode_1_28Mcps, TDD_mode_3_84Mcps };

public enum SlotStatus
{ 未选择, Active, Not_Active};

public enum SlotDirection
{ 未选择, Active, Not_Active};

public enum InventoryUnitType
{未选择,rack, shelf, slot, pack};

public enum LinkStatus
{未选择,normal,deactivated,failed,localBlocked,remoteBlocked, localInhibited,remoteInhibited};

public enum SignallingLinkType
{未选择,窄带7号信令链路, 宽带7号信令链路};

public enum Networkindicator
{ international,spare,national,nationalSpare};

public enum SignallingPointType
{HSTP,LSTP,HSTP_LSTP};

public enum AlarmType
{FIRSTLEVEL,SECONEDLEVEL,THIRDLEVEL,FOURTHLEVEL,FIFTHLEVER};

public enum UserDefinedNetworkType
{AN,CN,AN_CN};