/// <summary> /// 获取系统可以上报最晚数据的时间限制 /// </summary> /// <param name="dealerID">经销店ID</param> /// <returns></returns> public Common.Entity.DealerRepControl GetLastReportDateSet(int dealerID) { var result = new DAL.Dealer().GetLastReportDate(dealerID); if (null != result) { if (result.LastRepDateTime >= DateTime.Now.Date) { return(result); } } Common.Entity.DealerRepControl cResult = new Common.Entity.DealerRepControl(); int setDay = int.Parse(System.Configuration.ConfigurationManager.AppSettings["defaultReportCarDay"]); cResult.LastRepDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, setDay).AddDays(-1); cResult.InvoiceDateTime = cResult.LastRepDateTime.AddDays(1 - cResult.LastRepDateTime.Day); cResult.InvoiceDateTime = cResult.LastRepDateTime < DateTime.Now.Date ? cResult.InvoiceDateTime : cResult.InvoiceDateTime.AddMonths(-1); return(cResult); }
public Common.Entity.DealerRepControl GetLastReportDate(int dealerID) { StringBuilder strSql = new StringBuilder(); strSql.Append(@" select * from DealerRepControl where DealerId=@DealerId and Convert(char(6),LastRepDateTime,112)=@LastRepDateTime"); SqlParameter[] param = { new SqlParameter("@DealerId", dealerID), new SqlParameter("@LastRepDateTime", DateTime.Now.ToString("yyyyMM")) }; DataTable dt = SqlHelper.GetDateTable(SqlHelper.connStr, CommandType.Text, strSql.ToString(), param); Common.Entity.DealerRepControl model = null; if (dt.Rows.Count > 0) { model = new Common.Entity.DealerRepControl(); model.DealerId = Convert.ToInt32(dt.Rows[0]["DealerId"]); model.DealerCode = dt.Rows[0]["DealerCode"].ToString(); model.LastRepDateTime = Convert.ToDateTime(dt.Rows[0]["LastRepDateTime"].ToString()); model.InvoiceDateTime = Convert.ToDateTime(dt.Rows[0]["InvoiceDateTime"].ToString()); return(model); } return(model); }