using MESClassLibrary.BLL.Log; using MESClassLibrary.DAL; using MESClassLibrary.EFModel; using MESClassLibrary.Model; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; namespace MESClassLibrary.BLL.Painting { public class ChaimUpRecordBll { BasicBLL db = new BasicBLL(); public string SearchInfoAll(string page, string pagesize, string startTime, string endTime,int flag,string barCode) { try { string jsonStr = "[]"; int total = 0;//总行数 List list = new List(); string sql = @" SELECT ID,barcode,carType,color,flag,createTime,productName from tb_ChainUp where 1=1"; if (!string.IsNullOrEmpty(startTime)) { sql += @" and createTime between '"+ startTime + @"' and '"+ endTime +@"'"; } if (flag == 2) { } else if (flag == 0) { sql += @" and flag=0"; } else if (flag == 1) { sql += @" and flag=1"; } if (!string.IsNullOrEmpty(barCode)) { sql += @" and barcode like '%"+ barCode +@"%'"; } DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { list = Tool.ConvertTo(dt).ToList(); } if (list.Count > 0) { total = list.Count; int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize); list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList(); JsonDataModel md = new JsonDataModel(); md.total = total.ToString(); md.rows = list; IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(md, Formatting.Indented, timeConverter); } return jsonStr; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); return ""; } } public List> SearchForExcel(string page, string pagesize, string startTime, string endTime, int flag, string barCode) { try { List> list = new List>(); string jsonStr = "[]"; int total = 0;//总行数 List listProduct = new List(); string sql = @" SELECT ID,barcode,carType,color,flag,createTime,productName from tb_ChainUp where 1=1"; if (!string.IsNullOrEmpty(startTime)) { sql += @" and createTime between '" + startTime + @"' and '" + endTime + @"'"; } if (flag == 2) { } else if (flag == 0) { sql += @" and flag=0"; } else if (flag == 1) { sql += @" and flag=1"; } if (!string.IsNullOrEmpty(barCode)) { sql += @" and barcode like '%" + barCode + @"%'"; } DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { listProduct = Tool.ConvertTo(dt).ToList(); } if (listProduct != null && listProduct.Count() > 0) { List title_ = new List(); title_.Add("条码"); //title_.Add("车型"); title_.Add("产品名称"); title_.Add("颜色"); title_.Add("是否下悬挂链"); title_.Add("上悬挂链时间"); list.Add(title_); foreach (var item in listProduct) { List rowList = new List(); rowList.Add(item.barcode == null ? "" : item.barcode); //rowList.Add(item.carType == null ? "" : item.carType); rowList.Add(item.productName == null ? "" : item.productName); rowList.Add(item.color == null ? "" : item.color); switch (item.flag) { case 0: rowList.Add("未下悬挂链"); break; case 1: rowList.Add("已下悬挂链"); break; } rowList.Add(item.createTime == null ? "" : item.createTime.ToString()); list.Add(rowList); } } return list; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); return null; } } } }