public ActionResult Add([ModelBinder(typeof(JsonBinder<StorageEntity>))] StorageEntity entity) { StorageProvider provider = new StorageProvider(); int line = 0; if (entity.StorageNum.IsEmpty()) { entity.CreateTime = DateTime.Now; entity.StorageNum = entity.StorageNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(StorageEntity)) : entity.StorageNum; entity.IsDelete = (int)EIsDelete.NotDelete; entity.IsForbid = (int)EBool.No; line = provider.Add(entity); } else { entity.Include(a => new { a.StorageName, a.StorageType, a.Length, a.Width, a.Height, a.Action, a.Status, a.IsDefault, a.Remark }); entity.Where(a => a.StorageNum == entity.StorageNum); line = provider.Update(entity); } if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return Content(this.ReturnJson.ToString()); }
/// <summary> /// 新增库位 /// 如果设置为默认库位,则其他的库位修改为非默认库位 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Add(LocationEntity entity) { using (TransactionScope ts = new TransactionScope()) { //设置默认值 if (entity.IsDefault == (int)EBool.Yes) { LocationEntity temp = new LocationEntity(); temp.IsDefault = (int)EBool.No; temp.IncludeIsDefault(true); temp.Where(a => a.LocalNum == entity.LocalNum); this.Location.Update(temp); } //绑定仓库信息 StorageProvider storageProvider = new StorageProvider(); List <StorageEntity> listStorage = storageProvider.GetList(); if (entity.StorageNum.IsEmpty()) { if (!listStorage.IsNullOrEmpty()) { StorageEntity storage = listStorage.FirstOrDefault(a => a.IsDefault == (int)EBool.Yes); if (storage != null) { entity.StorageNum = storage.StorageNum; entity.StorageType = storage.StorageType; } } } else { if (!listStorage.IsNullOrEmpty()) { StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == entity.StorageNum); if (storage != null) { entity.StorageType = storage.StorageType; } } } entity.IncludeAll(); int line = this.Location.Add(entity); if (line > 0) { Clear(); } ts.Complete(); return(line); } }
/// <summary> /// 新增库位 /// 如果设置为默认库位,则其他的库位修改为非默认库位 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Add(LocationEntity entity) { using (TransactionScope ts = new TransactionScope()) { //设置默认值 if (entity.IsDefault == (int)EBool.Yes) { LocationEntity temp = new LocationEntity(); temp.IsDefault = (int)EBool.No; temp.IncludeIsDefault(true); temp.Where(a => a.LocalNum == entity.LocalNum); this.Location.Update(temp); } //绑定仓库信息 StorageProvider storageProvider = new StorageProvider(); List<StorageEntity> listStorage = storageProvider.GetList(); if (entity.StorageNum.IsEmpty()) { if (!listStorage.IsNullOrEmpty()) { StorageEntity storage = listStorage.FirstOrDefault(a => a.IsDefault == (int)EBool.Yes); if (storage != null) { entity.StorageNum = storage.StorageNum; entity.StorageType = storage.StorageType; } } } else { if (!listStorage.IsNullOrEmpty()) { StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == entity.StorageNum); if (storage != null) { entity.StorageType = storage.StorageType; } } } entity.IncludeAll(); int line = this.Location.Add(entity); if (line > 0) { Clear(); } ts.Complete(); return line; } }
/// <summary> /// 仓库 /// </summary> /// <param name="roleNum"></param> /// <returns></returns> public static string GetStorageNumList(string storeNum) { StorageProvider provider = new StorageProvider(); List<StorageEntity> list = provider.GetList(); StringBuilder sb = new StringBuilder(); string storeTemplate = "<option value='{0}' {1}>{2}</option>"; sb.AppendFormat(storeTemplate, "", "", "请选择仓库"); if (!list.IsNullOrEmpty()) { foreach (StorageEntity store in list) { sb.AppendFormat(storeTemplate, store.StorageNum, store.StorageNum == storeNum ? "selected='selected'" : string.Empty, store.StorageName); } } return sb.ToString(); }
public ActionResult Audit(string StorageNum, string IsForbid) { StorageProvider provider = new StorageProvider(); StorageEntity entity = new StorageEntity(); entity.IncludeIsForbid(true); entity.IsForbid = ConvertHelper.ToType<int>(IsForbid); entity.Where(a => a.StorageNum == StorageNum); int line = provider.Update(entity); if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return Content(this.ReturnJson.ToString()); }
public ActionResult Add() { string StorageNum = WebUtil.GetQueryStringValue<string>("StorageNum"); if (StorageNum.IsEmpty()) { ViewBag.StorageType = EnumHelper.GetOptions<EStorageType>(string.Empty, "请选择仓库类型"); ViewBag.IsDefaultList = EnumHelper.GetOptions<EBool>(string.Empty, "请选择"); ViewBag.StorageStatus = EnumHelper.GetOptions<EBool>(string.Empty, "请选择"); ViewBag.Storage = new StorageEntity(); } else { StorageProvider provider = new StorageProvider(); StorageEntity entity = provider.GetSingleByNum(StorageNum); entity = entity == null ? new StorageEntity() : entity; ViewBag.StorageType = EnumHelper.GetOptions<EStorageType>(entity.StorageType, "请选择仓库类型"); ViewBag.IsDefaultList = EnumHelper.GetOptions<EBool>(entity.IsDefault, "请选择"); ViewBag.StorageStatus = EnumHelper.GetOptions<EBool>(entity.Status, "请选择"); ViewBag.Storage = entity; } return View(); }
/// <summary> /// 查询分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <LocationEntity> GetList(LocationEntity entity, ref PageInfo pageInfo) { try { entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); entity.OrderBy(a => a.ID, EOrderBy.DESC); int rowCount = 0; List <LocationEntity> listResult = this.Location.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; if (!listResult.IsNullOrEmpty()) { StorageProvider storageProvider = new StorageProvider(); List <StorageEntity> listStorage = storageProvider.GetList(); listStorage = listStorage.IsNull() ? new List <StorageEntity>() : listStorage; foreach (LocationEntity item in listResult) { StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == item.StorageNum); if (storage != null) { item.StorageName = storage.StorageName; } else { item.StorageName = ""; } } } return(listResult); } catch (Exception e) { log.Error(e.Message); } return(null); }
/// <summary> /// 查询分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List<LocationEntity> GetList(LocationEntity entity, ref PageInfo pageInfo) { try { entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); entity.OrderBy(a => a.ID, EOrderBy.DESC); int rowCount = 0; List<LocationEntity> listResult = this.Location.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; if (!listResult.IsNullOrEmpty()) { StorageProvider storageProvider = new StorageProvider(); List<StorageEntity> listStorage = storageProvider.GetList(); listStorage = listStorage.IsNull() ? new List<StorageEntity>() : listStorage; foreach (LocationEntity item in listResult) { StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == item.StorageNum); if (storage != null) { item.StorageName = storage.StorageName; } else { item.StorageName = ""; } } } return listResult; } catch (Exception e) { log.Error(e.Message); } return null; }
/// <summary> /// 获得所有的库位 /// </summary> /// <returns></returns> public List<LocationEntity> GetList() { List<LocationEntity> listResult = CacheHelper.Get<List<LocationEntity>>(CacheKey.JOOSHOW_LOCATION_CACHE); if (!listResult.IsNullOrEmpty()) { return listResult; } LocationEntity entity = new LocationEntity(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); entity.IncludeAll(); listResult = this.Location.GetList(entity); if (!listResult.IsNullOrEmpty()) { StorageProvider storageProvider = new StorageProvider(); List<StorageEntity> listStorage = storageProvider.GetList(); listStorage = listStorage.IsNull() ? new List<StorageEntity>() : listStorage; foreach (LocationEntity item in listResult) { StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == item.StorageNum); if (storage != null) { item.StorageName = storage.StorageName; } } CacheHelper.Insert(CacheKey.JOOSHOW_LOCATION_CACHE, listResult, null, DateTime.Now.AddHours(6)); } return listResult; }
/// <summary> /// 设置仓库 /// </summary> private void SetStorage() { StorageProvider provider = new StorageProvider(); List<StorageEntity> list = provider.GetList(); list = list.IsNull() ? new List<StorageEntity>() : list; ViewBag.MenuStorage = list; string storageNum = DefaultStore; storageNum = storageNum.IsEmpty() ? ResourceManager.GetSettingEntity("STORE_DEFAULT_PRODUCT").Value : storageNum; ViewBag.MenuStorageName = list.First(a => a.StorageNum == storageNum).StorageName; }
public ActionResult Delete(string StorageNum) { StorageProvider provider = new StorageProvider(); int line = provider.Delete(StorageNum); if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return Content(this.ReturnJson.ToString()); }
public ActionResult ToExcel() { string StorageName = WebUtil.GetFormValue<string>("StorageName", string.Empty); int StorageType = WebUtil.GetFormValue<int>("StorageType", -1); int IsForbid = WebUtil.GetFormValue<int>("IsForbid", -1); PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue }; StorageProvider provider = new StorageProvider(); StorageEntity entity = new StorageEntity(); if (IsForbid > -1) { entity.Where<StorageEntity>("IsForbid", ECondition.Eth, IsForbid); } if (StorageType > -1) { entity.Where<StorageEntity>("StorageType", ECondition.Eth, StorageType); } if (!StorageName.IsEmpty()) { entity.Begin<StorageEntity>() .Where<StorageEntity>("StorageName", ECondition.Like, "%" + StorageName + "%") .Or<StorageEntity>("StorageNum", ECondition.Like, "%" + StorageName + "%") .End<StorageEntity>() ; } List<StorageEntity> listResult = provider.GetList(entity, ref pageInfo); listResult = listResult.IsNull() ? new List<StorageEntity>() : listResult; if (listResult.IsNotNull()) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("序号 ")); dt.Columns.Add(new DataColumn("仓库编号 ")); dt.Columns.Add(new DataColumn("仓库名 ")); dt.Columns.Add(new DataColumn("仓库类型 ")); dt.Columns.Add(new DataColumn("是否禁用")); dt.Columns.Add(new DataColumn("是否默认")); dt.Columns.Add(new DataColumn("备注")); dt.Columns.Add(new DataColumn("创建时间")); int count = 1; foreach (StorageEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = count; row[1] = t.StorageNum; row[2] = t.StorageName; row[3] = EnumHelper.GetEnumDesc<EStorageType>(t.StorageType); row[4] = EnumHelper.GetEnumDesc<EBool>(t.IsForbid); row[5] = EnumHelper.GetEnumDesc<EBool>(t.IsDefault); row[6] = t.Remark; row[7] = t.CreateTime.ToString("yyyy-MM-dd"); dt.Rows.Add(row); count++; } string filePath = Server.MapPath("~/UploadFiles/"); if (!System.IO.Directory.Exists(filePath)) { System.IO.Directory.CreateDirectory(filePath); } string filename = string.Format("仓库管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss")); NPOIExcel excel = new NPOIExcel("仓库管理", "仓库", System.IO.Path.Combine(filePath, filename)); excel.ToExcel(dt); this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape()); } else { this.ReturnJson.AddProperty("d", "无数据导出!"); } return Content(this.ReturnJson.ToString()); }
public ActionResult GetList() { int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 1); int pageSize = WebUtil.GetFormValue<int>("pageSize", 10); string StorageName = WebUtil.GetFormValue<string>("StorageName", string.Empty); int StorageType = WebUtil.GetFormValue<int>("StorageType", -1); int IsForbid = WebUtil.GetFormValue<int>("IsForbid", -1); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; StorageProvider provider = new StorageProvider(); StorageEntity entity = new StorageEntity(); if (IsForbid > -1) { entity.Where<StorageEntity>("IsForbid", ECondition.Eth, IsForbid); } if (StorageType > -1) { entity.Where<StorageEntity>("StorageType", ECondition.Eth, StorageType); } if (!StorageName.IsEmpty()) { entity.Begin<StorageEntity>() .Where<StorageEntity>("StorageName", ECondition.Like, "%" + StorageName + "%") .Or<StorageEntity>("StorageNum", ECondition.Like, "%" + StorageName + "%") .End<StorageEntity>() ; } List<StorageEntity> listResult = provider.GetList(entity, ref pageInfo); string json = ConvertJson.ListToJson<StorageEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return Content(this.ReturnJson.ToString()); }