本文整理汇总了C#中QueryDataParameters.AddDateTime方法的典型用法代码示例。如果您正苦于以下问题:C# QueryDataParameters.AddDateTime方法的具体用法?C# QueryDataParameters.AddDateTime怎么用?C# QueryDataParameters.AddDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryDataParameters
的用法示例。
在下文中一共展示了QueryDataParameters.AddDateTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
gridElem.IsLiveSite = IsLiveSite;
// Get score ID from query string
scoreId = QueryHelper.GetInteger("ScoreID", 0);
// Initialize score filter
FormFieldInfo ffi = new FormFieldInfo();
ffi.Name = " HAVING SUM(Value)";
ffi.DataType = FormFieldDataTypeEnum.Integer;
ucScoreFilter.FieldInfo = ffi;
ucScoreFilter.DefaultOperator = ">=";
ucScoreFilter.WhereConditionFormat = "{0} {2} {1}";
// Get modify permission of current user
modifyPermission = ContactHelper.AuthorizedModifyContact(SiteId, false);
// Set where condition
gridElem.WhereCondition = "(ScoreId = @ScoreID) AND (Expiration IS NULL OR (DATEDIFF(d, getdate(), Expiration) >= 0)) GROUP BY ContactID"
+ ucScoreFilter.GetWhereCondition();
// Add parameters
QueryDataParameters parameters = new QueryDataParameters();
parameters.AddDateTime("@CurrentDate", DateTime.Now);
parameters.AddId("@CurrentSiteID", SiteId);
parameters.AddId("@ScoreID", scoreId);
gridElem.QueryParameters = parameters;
// Register OnExternalDataBound
gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
gridElem.OnBeforeFiltering += gridElem_OnBeforeFiltering;
// Initialize dropdown lists
if (!RequestHelper.IsPostBack())
{
drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString()));
if ((modifyPermission || ContactGroupHelper.AuthorizedModifyContactGroup(SiteId, false)) && ContactGroupHelper.AuthorizedReadContactGroup(SiteId, false))
{
drpAction.Items.Add(new ListItem(GetString("om.account." + Action.AddToGroup), Convert.ToInt32(Action.AddToGroup).ToString()));
}
if (modifyPermission)
{
drpAction.Items.Add(new ListItem(GetString("om.account." + Action.ChangeStatus), Convert.ToInt32(Action.ChangeStatus).ToString()));
}
drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.Selected), Convert.ToInt32(What.Selected).ToString()));
drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.All), Convert.ToInt32(What.All).ToString()));
}
else
{
if (RequestHelper.CausedPostback(btnOk))
{
// Set delayed reload for unigrid if mass action is performed
gridElem.DelayedReload = true;
}
}
// Register JS scripts
RegisterScripts();
}
示例2: GetQueryParameters
/// <summary>
/// Returns query parameters.
/// </summary>
private QueryDataParameters GetQueryParameters()
{
QueryDataParameters parameters = new QueryDataParameters();
// Date parameters
if (OlderThan > 0)
{
// OlderThan parameter
if (OlderThan > SQL_DATE_TIME_LIMIT)
{
OlderThan = SQL_DATE_TIME_LIMIT;
}
DateTime param = DateTime.Now.AddDays(-Math.Abs(OlderThan));
parameters.AddDateTime("@OlderThan", param);
}
else if (HowOld > 0 && HowOld < SQL_DATE_TIME_LIMIT)
{
// HowOld parameter
DateTime from = DateTime.Now.AddDays(-Math.Abs(HowOld));
parameters.AddDateTime("@From", from);
}
return parameters;
}