📄 datehelper.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.CompilerServices;
using Qeb.Control;
namespace Qeb.Support.Common
{
public class DateHelper
{
private static QDataStore m_dsServerTime = null;
//[MethodImpl(MethodImplOptions.Synchronized)]
private static void InitDsServer()
{
if (m_dsServerTime == null)
{
m_dsServerTime = new QDataStore();
m_dsServerTime.LibraryList = PBL.GyPbl;
m_dsServerTime.DataWindowObject = GyDataObjects.D_Gy_ServerTime;
}
}
[MethodImpl(MethodImplOptions.Synchronized)]
public static DateTime GetServerTime()
{
InitDsServer();
App.DbProxy.Retrieve(m_dsServerTime);
if (m_dsServerTime.RowCount ==0 )
{
throw new Exception("取服务器时间出错,没有返回记录!");
}
else
{
if (m_dsServerTime.IsItemNull(1,"SysDate"))
{
throw new Exception("没有取到服务器时间!");
}
else
{
return m_dsServerTime.GetItemDateTime(1, "Sysdate");
}
}
}
/// <summary>
/// 取某月最后一天
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public static DateTime LastDayofMon(DateTime date)
{
int monthCount = DateTime.DaysInMonth(date.Year, date.Month);
return Convert.ToDateTime(date.Year.ToString() + "-" + date.Month.ToString() + "-" + monthCount);
}
/// <summary>
/// 取某月最后一天
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public static DateTime LastDayofMon(int year,int month)
{
int monthCount = DateTime.DaysInMonth(year, month);
return Convert.ToDateTime(year.ToString() + "-" + month.ToString() + "-" + monthCount);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -