本文整理汇总了C#中Framework.Runtime.DBTypes.DBDateTime.AddDays方法的典型用法代码示例。如果您正苦于以下问题:C# DBDateTime.AddDays方法的具体用法?C# DBDateTime.AddDays怎么用?C# DBDateTime.AddDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Framework.Runtime.DBTypes.DBDateTime
的用法示例。
在下文中一共展示了DBDateTime.AddDays方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillDatagrid
/// <summary>
/// Fill datagrid with data
/// </summary>
private void FillDatagrid(DBGuid ID)
{
try
{
string sSortColumn = "ForumThreadName";
int nSelectedRow = -1;
// Storing the previous sort order
if (dtgMain.DataSource != null)
{
sSortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort;
}
// Set filter
ForumItem filter = new ForumItem(Guid.Empty);
filter.FilterOnIsModerated = DBInt.Null;
if (cmbStatus.SelectedIndex > 0)
{
bool bIsModerated = (cmbStatus.SelectedValue.ToString() == "1" ? true : false);
filter.FilterOnIsModerated = (DBInt) Convert.ToInt32(bIsModerated);
filter.IsModerated = bIsModerated;
}
if (cmbForumGroup.SelectedIndex > 0)
{
filter.ForumGroupRef = new DBGuid(new Guid(cmbForumGroup.SelectedValue.ToString()));
}
if (dtpSentFrom.Checked)
{
filter.FilterOnSentFrom = new DBDateTime(dtpSentFrom.Value);
}
if (dtpSentTo.Checked)
{
DBDateTime dateTo = new DBDateTime(dtpSentTo.Value);
filter.FilterOnSentTo = dateTo.AddDays(1).AddMilliseconds(-1);
}
// Retrieving data from BusinessServices
IForumItemService srv = ServiceFactory.GetForumItemService();
ForumItemContainer allData = srv.ForumItemSelectFiltered(filter);
DataTable dt = allData.AllAsDatatable;
dt.DefaultView.Sort = sSortColumn;
dtgMain.DataSource = dt;
// Locates the row specified by ID param
if (!ID.IsNull)
{
BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember];
DataRow dr;
for (int i = 0; i < bm.Count; i++)
{
dr = ((DataRowView) bm.Current).Row;
if (ID.Value.Equals(dr["ID"]))
{
nSelectedRow = i;
break;
}
bm.Position += 1;
}
}
// Makes the row selected
if (nSelectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && nSelectedRow > -1)
{
dtgMain.Select(nSelectedRow);
dtgMain.CurrentRowIndex = nSelectedRow;
}
else if (((DataTable) dtgMain.DataSource).DefaultView.Count != 0)
{
dtgMain.Select(0);
}
// Enabling or disabling the buttons according to record count.
// And is because of previous disable state.
bool bIsEmptyGrid = (((DataTable) dtgMain.DataSource).DefaultView.Count == 0);
tbbInactivate.Enabled = ! bIsEmptyGrid;
tbbModify.Enabled = ! bIsEmptyGrid;
}
catch (Exception ex)
{
// --- Log exception
ExceptionManager.Publish(ex);
// --- Display Exception
ErrorHandler.DisplayError("Nem várt hiba lépett fel a lista frissítése során.", ex);
}
}
示例2: FillDatagrid
/// <summary>
/// Fill datagrid with data
/// </summary>
private void FillDatagrid(DBInt ID)
{
try
{
string sSortColumn = "TimeStamp DESC";
int nSelectedRow = -1;
// Storing the previous sort order
if (dtgMain.DataSource != null)
{
sSortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort;
}
// Set filter
Event filter = new Event();
if (cmbFunctions.SelectedIndex > 0)
{
filter.Method = cmbFunctions.SelectedValue.ToString();
}
if (txtLoginName.Text.Length > 0)
{
filter.PrincipalName = txtLoginName.Text;
}
if (dtpFrom.Checked)
{
filter.FilterOnTimeStampFrom = new DBDateTime(dtpFrom.Value.Date);
}
if (dtpTo.Checked)
{
DBDateTime dateTo = new DBDateTime(dtpTo.Value);
filter.FilterOnTimeStampTo = dateTo.AddDays(1).AddMilliseconds(-1);
}
// Retrieving data from BusinessServices
IEventService srv = ServiceFactory.GetEventService();
EventContainer allData = srv.EventSelectFiltered(filter);
DataTable dt = allData.AllAsDatatable;
dt.DefaultView.Sort = sSortColumn;
dtgMain.DataSource = dt;
// Locates the row specified by ID param
if (!ID.IsNull)
{
BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember];
DataRow dr;
for (int i = 0; i < bm.Count; i++)
{
dr = ((DataRowView) bm.Current).Row;
if (ID.Value.Equals(dr["ID"]))
{
nSelectedRow = i;
break;
}
bm.Position += 1;
}
}
// Makes the row selected
if (nSelectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && nSelectedRow > -1)
{
dtgMain.Select(nSelectedRow);
dtgMain.CurrentRowIndex = nSelectedRow;
}
else if (((DataTable) dtgMain.DataSource).DefaultView.Count != 0)
{
dtgMain.Select(0);
}
// Enabling or disabling the buttons according to record count.
// And is because of previous disable state.
bool bIsEmptyGrid = (((DataTable) dtgMain.DataSource).DefaultView.Count == 0);
tbbModify.Enabled = ! bIsEmptyGrid;
}
catch (Exception ex)
{
// --- Log exception
ExceptionManager.Publish(ex);
// --- Display Exception
ErrorHandler.DisplayError("Nem várt hiba lépett fel a lista frissítése során.", ex);
}
}