void CheckDate(ReqRpt001QueryTablePostModel postModel) { prodList = postModel.ProdList; type = postModel.DateType; if (postModel.DateType == "month") { from = postModel.DateFromValue + "-01"; fromDate = DateTime.Parse(from); var rawList = postModel.DateToValue.Split('-'); int days = DateTime.DaysInMonth(Convert.ToInt16(rawList[0]), Convert.ToInt16(rawList[1])); to = postModel.DateToValue + "-" + (days > 10?days.ToString():"0" + days); toDate = DateTime.Parse(to); } else { from = postModel.DateFromValue.Split('-')[0] + "-01-01"; fromDate = DateTime.Parse(from); to = postModel.DateToValue.Split('-')[0] + "-12-31"; toDate = DateTime.Parse(to); } if (fromDate > toDate) { throw new Exception("开始日期不能大于结束日期"); } }
public ReqRpt001TableDataBuilder(ReqRpt001QueryTablePostModel postModel) { CheckDate(postModel); Initialize(); }