/// <summary> /// Gets the current system info. /// </summary> private void GetCurrentSystemInfo() { using (var ctx = new EF6.RT2020Entities()) { var oSysInfo = ctx.SystemInfo.AsNoTracking().FirstOrDefault(); if (oSysInfo != null) { string lastYear = oSysInfo.LastMonthEnd.ToString().Substring(0, 4); string lastMonth = oSysInfo.LastMonthEnd.ToString().Substring(4, 2); DateTime currentMonth = new DateTime(Convert.ToInt32(lastYear), Convert.ToInt32(lastMonth), 1); currentMonth = currentMonth.AddMonths(1); this.CurrentSystemDate = currentMonth; this.CurrentSystemYear = currentMonth.Year.ToString(); this.CurrentSystemMonth = currentMonth.Month.ToString().PadLeft(2, '0'); this.LastMonthEnd = oSysInfo.LastMonthEnd.ToString(); this.LastYearEnd = oSysInfo.LastYearEnd.ToString(); // Address Info. this.CompanyName = oSysInfo.CompanyName; this.CompanyName_Chs = oSysInfo.CompanyName_Chs; this.CompanyName_Cht = oSysInfo.CompanyName_Cht; this.SysInfo = oSysInfo; } } }
public static EF6.SystemInfo Get(Guid id) { EF6.SystemInfo result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SystemInfo.Find(id); } return(result); }