public static T_FixedAssets ToModel(this T_FixedAssetsModel node) { return(new T_FixedAssets() { Id = node.Id, Address = node.Address, AssetsNo = node.AssetsNo, BuyPrice = node.BuyPrice, Category = node.Category, CompanyId = node.CompanyId, CreateDate = node.CreateDate, CreateUserId = node.CreateUserId, CreateUserName = node.CreateUserName, DateProduction = node.DateProduction, DatePurchase = node.DatePurchase, GroupId = node.GroupId, Manufacturers = node.Manufacturers, Name = node.Name, NowPrice = node.NowPrice, Status = node.Status, TypeSpecification = node.TypeSpecification, UseUserId = node.UseUserId, UseUserName = node.UseUserName, ValidYear = node.ValidYear, }); }
public int AddData(T_FixedAssetsModel model) { int i = 0; for (int k = 1; k <= model.CreateNum; k++) { i = this.Add(model.ToModel()); } return(i); }
/// <summary> /// 复杂查询 /// </summary> /// <param name="model">查询对象</param> /// <param name="Orders">排序字典key:排序的字段,value:asc升序/desc降序</param> /// <param name="PageSize">每页行数,默认15</param> /// <param name="PageIndex">当前页码,默认100</param> /// <returns></returns> public DataGrid <T_FixedAssetsModel> Search(T_FixedAssetsModel model, Dictionary <string, string> Orders = null, int PageSize = 15, int PageIndex = 100) { Expression <Func <T_FixedAssets, bool> > where = null; //最终查询条件 var lambdaList = new List <Expression <Func <T_FixedAssets, bool> > >(); //lambda查询条件集合 int total = 0; //总行数 if (model.AssetsNo != null) { lambdaList.Add(c => c.AssetsNo.Contains(model.AssetsNo)); } if (model.Name != null) { lambdaList.Add(c => c.Name.Contains(model.Name)); } if (model.CompanyId.HasValue) { lambdaList.Add(c => c.CompanyId == (int)model.CompanyId); } if (model.Category != null && model.Category != " ") { lambdaList.Add(c => c.Category == model.Category); } if (model.BeginTime.HasValue) { lambdaList.Add(c => c.DatePurchase >= (DateTime)model.BeginTime); } if (model.EndTime.HasValue) { lambdaList.Add(c => c.DatePurchase <= (DateTime)model.EndTime); } if (model.StatusList.Count() > 0) { lambdaList.Add(c => model.StatusList.Any(a => c.Status == a)); } //将集合表达式树转换成Expression表达式树 MyVisitor <T_FixedAssets, T_FixedAssets> visitor = new MyVisitor <T_FixedAssets, T_FixedAssets>(); where = visitor.Modify(lambdaList); var list = dal.Search(out total, where, Orders, PageSize, PageIndex).DTOList().ToList(); var result = new DataGrid <T_FixedAssetsModel>() { rows = list, total = total }; return(result); }
public int DeleteData(T_FixedAssetsModel model) { return(this.Delete(model.Id)); }
public int EditData(T_FixedAssetsModel model) { return(this.Edit(model.ToModel())); }