🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
刚开始的时候想的是用一句SQL语句写出所有,后来因SQL函数写不下去就用了代码 ~~~ protected string sDateJson; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DateTime dtnow = DateTime.Now; DataTable dttable = SqlEasy.ExecuteDataTable("select * from Psi_Goods"); foreach (DataRow dr in dttable.Rows) { DateTime dttime = Convert.ToDateTime(dr["up_time"].ToString()); if (dtnow.AddMonths(-4) > dttime) { sDateJson += "{\"KeyId\":" + dr["KeyId"].ToString() + ",\"goodsNo\":\"" + dr["goodsNo"].ToString() + "\",\"goodsName\":\"" + dr["goodsName"].ToString() + "\",\"goodsShortName\":\"" + dr["goodsShortName"].ToString() + "\",\"goodsClassName\":\"" + dr["goodsClassName"].ToString() + "\",\"specs\":\"" + dr["specs"].ToString() + "\",\"unit\":\"" + dr["unit"].ToString() + "\",\"stock\":\"" + dr["stock"].ToString() + "\",\"buyPrice\":\"" + dr["buyPrice"].ToString() + "\",\"up_time\":\"" + dr["up_time"].ToString() + "\",}"; } if (!string.IsNullOrEmpty(sDateJson)) { sDateJson = sDateJson.Substring(0, sDateJson.Length -1); } } } } ~~~