public bool Add(DeliverDist deliverDist, out string strResult) { strResult = string.Empty; bool result = false; var deliver = new DeliverDist(); if (deliverDist != null) { try { deliver.DistCode = deliverDist.DistCode; deliver.CustomCode = deliverDist.CustomCode; deliver.DistName = deliverDist.DistName; deliver.DistCenterCode = deliverDist.DistCenterCode; deliver.CompanyCode = deliverDist.CompanyCode; deliver.UniformCode = deliverDist.UniformCode; deliver.Description = deliverDist.Description; deliver.IsActive = deliverDist.IsActive; deliver.UpdateTime = DateTime.Now; DeliverDistRepository.Add(deliver); DeliverDistRepository.SaveChanges(); result = true; } catch (Exception ex) { strResult = "原因:" + ex.InnerException; } } return(result); }
public bool Delete(string DistCode) { var deliver = DeliverDistRepository.GetQueryable() .FirstOrDefault(i => i.DistCode == DistCode); if (DistCode != null) { DeliverDistRepository.Delete(deliver); DeliverDistRepository.SaveChanges(); } else { return(false); } return(true); }
public bool Save(string DistCode, string CustomCode, string DistName, string DistCenterCode, string CompanyCode, string UniformCode, string Description, string IsActive, out string strResult) { strResult = string.Empty; try { var deliver = DeliverDistRepository.GetQueryable() .FirstOrDefault(i => i.DistCode == DistCode); deliver.CustomCode = CustomCode; deliver.DistName = DistName; deliver.DistCenterCode = DistCenterCode; deliver.CompanyCode = CompanyCode; deliver.UniformCode = UniformCode; deliver.Description = Description; deliver.IsActive = IsActive; DeliverDistRepository.SaveChanges(); } catch (Exception ex) { strResult = "原因:" + ex.InnerException; } return(true); }
public object D_Details(int page, int rows, string QueryString, string Value) { string DistCode = ""; string DistName = ""; if (QueryString == "DistCode") { DistCode = Value; } else { DistName = Value; } IQueryable <DeliverDist> deliverQuery = DeliverDistRepository.GetQueryable(); var deliver = deliverQuery.Where(c => c.DistName.Contains(DistCode) && c.CompanyCode.Contains(DistName)) .OrderBy(c => c.DistCode) .Select(c => c); if (!DistName.Equals(string.Empty)) { deliver = deliver.Where(p => p.DistCode == DistCode); } int total = deliver.Count(); deliver = deliver.Skip((page - 1) * rows).Take(rows); var temp = deliver.ToArray().Select(c => new { DistCode = c.DistCode, CustomCode = c.CustomCode, DistName = c.DistName, DistCenterCode = c.DistCenterCode, CompanyCode = c.CompanyCode, IsActive = c.IsActive == "1" ? "可用" : "不可用" }); return(new { total, rows = temp.ToArray() }); }
public object GetDetails(int page, int rows, string DistCode, string CustomCode, string DistName, string CompanyCode, string UniformCode, string IsActive) { IQueryable <DeliverDist> DeliverDistQuery = DeliverDistRepository.GetQueryable(); var DeliverDist = DeliverDistQuery.Where(c => c.DistCode.Contains(DistCode) && c.DistName.Contains(DistName) && c.IsActive.Contains(IsActive) && c.UniformCode.Contains(UniformCode)); if (!CustomCode.Equals(string.Empty)) { DeliverDist = DeliverDist.Where(d => d.CustomCode == CustomCode); } if (!CompanyCode.Equals(string.Empty)) { DeliverDist = DeliverDist.Where(d => d.DistCenterCode == CompanyCode); } DeliverDist = DeliverDist.OrderBy(h => h.DistCode); int total = DeliverDist.Count(); DeliverDist = DeliverDist.Skip((page - 1) * rows).Take(rows); var temp = DeliverDist.ToArray().Select(c => new { DistCode = c.DistCode, CustomCode = c.CustomCode, DistName = c.DistName, DistCenterCode = c.DistCenterCode, CompanyCode = c.CompanyCode, UniformCode = c.UniformCode, Description = c.Description, IsActive = c.IsActive == "1" ? "可用" : "不可用", UpdateTime = c.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss") }); return(new { total, rows = temp.ToArray() }); }