/// <summary> /// Create search condition from selected summary period /// </summary> /// <param name="summaryPeriod"></param> /// <returns></returns> private doSummaryARPeriod CTS390_getPeriodDate(string summaryPeriod) { doSummaryARPeriod result = new doSummaryARPeriod(); // ALL result.dateTo = null; result.dateTo = null; result.current = DateTime.Now; DateTime temp = DateTime.Now; if (ARSummaryPeriod.C_AR_SUMMARY_PERIOD_TODAY.Equals(summaryPeriod)) { result.dateFrom = new DateTime(result.current.Value.Year, result.current.Value.Month, result.current.Value.Day, 0, 0, 0); result.dateTo = new DateTime(result.current.Value.Year, result.current.Value.Month, result.current.Value.Day, 23, 59, 59); } else if (ARSummaryPeriod.C_AR_SUMMARY_PERIOD_THISWEEK.Equals(summaryPeriod)) { int dayOfWeek = (int)DateTime.Now.DayOfWeek; temp = DateTime.Now.AddDays(1.0 - dayOfWeek); result.dateFrom = new DateTime(temp.Year, temp.Month, temp.Day, 0, 0, 0); result.dateTo = new DateTime(result.current.Value.Year, result.current.Value.Month, result.current.Value.Day, 23, 59, 59); } else if (ARSummaryPeriod.C_AR_SUMMARY_PERIOD_THISMONTH.Equals(summaryPeriod)) { temp = CommonUtil.FirstDayOfMonthFromDateTime(result.current.Value.Month, result.current.Value.Year); result.dateFrom = new DateTime(temp.Year, temp.Month, temp.Day, 0, 0, 0); result.dateTo = new DateTime(result.current.Value.Year, result.current.Value.Month, result.current.Value.Day, 23, 59, 59); } else if (ARSummaryPeriod.C_AR_SUMMARY_PERIOD_LASTWEEK.Equals(summaryPeriod)) { int dayOfWeek = (int)DateTime.Now.DayOfWeek; temp = DateTime.Now.AddDays(-6.0 - dayOfWeek); //(1.0 - dayOfWeek - 7) result.dateFrom = new DateTime(temp.Year, temp.Month, temp.Day, 0, 0, 0); temp = DateTime.Now.AddDays(0 - dayOfWeek); result.dateTo = new DateTime(temp.Year, temp.Month, temp.Day, 23, 59, 59); } else if (ARSummaryPeriod.C_AR_SUMMARY_PERIOD_LASTMONTH.Equals(summaryPeriod)) { temp = CommonUtil.FirstDayOfMonthFromDateTime(result.current.Value.Month - 1, result.current.Value.Year); result.dateFrom = new DateTime(temp.Year, temp.Month, temp.Day, 0, 0, 0); temp = CommonUtil.LastDayOfMonthFromDateTime(result.current.Value.Month - 1, result.current.Value.Year); result.dateTo = new DateTime(temp.Year, temp.Month, temp.Day, 23, 59, 59); } return(result); }
public ActionResult CTS390_searchAR(string summaryPeriod) { ObjectResultData res = new ObjectResultData(); try { doSummaryARPeriod condition = CTS390_getPeriodDate(summaryPeriod); IARHandler hand = ServiceContainer.GetService <IARHandler>() as IARHandler; List <dtSummaryAR> summary = hand.SummaryAR(condition.dateFrom, condition.dateTo, condition.current); CommonUtil.MappingObjectLanguage <dtSummaryAR>(summary); string xml = CommonUtil.ConvertToXml <dtSummaryAR>(summary, "Contract\\CTS390", CommonUtil.GRID_EMPTY_TYPE.SEARCH); xml = xml.Replace("&amp;nbsp;", "&nbsp;"); //decode back res.ResultData = xml; } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }