public ActionResult AddProduct() { string ProductNum = WebUtil.GetFormValue <string>("SnNum", string.Empty); string BarCode = WebUtil.GetFormValue <string>("BarCode", string.Empty); string ProductName = WebUtil.GetFormValue <string>("ProductName", string.Empty); string BatchNum = WebUtil.GetFormValue <string>("ProductBatch", string.Empty); string LocalNum = WebUtil.GetFormValue <string>("LocalNum", string.Empty); string Size = WebUtil.GetFormValue <string>("Size", string.Empty); string Color = WebUtil.GetFormValue <string>("Color", string.Empty); string Count = WebUtil.GetFormValue <string>("Count", string.Empty); double LocalQty = WebUtil.GetFormValue <double>("LocalQty", 0); double Num = WebUtil.GetFormValue <double>("Num", 0); double InPrice = WebUtil.GetFormValue <double>("Price", 0); double Cl = WebUtil.GetFormValue <double>("Cl", 0); double Ca = WebUtil.GetFormValue <double>("Ca", 0); double Cb = WebUtil.GetFormValue <double>("Cb", 0); InStorDetailEntity entity = new InStorDetailEntity(); entity.SnNum = SequenceProvider.GetSequence(typeof(InStorDetailEntity)); entity.OrderNum = string.Empty; entity.ProductName = ProductName; entity.BarCode = BarCode; entity.ProductNum = ProductNum; entity.Color = Color; entity.Count = Count; entity.Size = Size; entity.Num = Num; entity.IsPick = (int)EBool.No; entity.RealNum = 0; entity.InPrice = InPrice; entity.CreateTime = DateTime.Now; entity.LocalNum = LocalNum; entity.Cl = Cl; entity.Ca = Ca; entity.Cb = Cb; entity.RGB = ColorHelper.GetRgb16Color(LabRgb.LabToRgb(new double[] { Cl, Ca, Cb })); LocationEntity localtion = new LocationProvider().GetSingleByNumCache(LocalNum); if (localtion != null) { entity.LocalName = new LocationProvider().GetSingleByNumCache(LocalNum).LocalName; } else { entity.LocalName = ""; } entity.Amount = entity.InPrice * entity.Num; entity.StorageNum = this.DefaultPStore; entity.BatchNum = BatchNum; entity.TotalPrice = entity.Num * entity.InPrice; List <InStorDetailEntity> list = Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] as List <InStorDetailEntity>; list = list.IsNull() ? new List <InStorDetailEntity>() : list; list.Add(entity); Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] = list; return(Content(string.Empty)); }
public ActionResult Edit() { Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] = null; string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty); Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); InStorageEntity entity = new InStorageEntity(); entity.OrderNum = orderNum; entity = bill.GetOrder(entity); entity = entity == null ? new InStorageEntity() : entity; entity.InTypeLable = EnumHelper.GetEnumDesc <EInType>(entity.InType); entity.StatusLable = EnumHelper.GetEnumDesc <EAudite>(entity.Status); ViewBag.InStorage = entity; ViewBag.InType = EnumHelper.GetOptions <EInType>(entity.InType, "请选择入库单类型"); ViewBag.ProductType = EnumHelper.GetOptions <EProductType>(entity.Status, "请选择入库产品类型"); InStorDetailEntity detail = new InStorDetailEntity(); detail.OrderNum = orderNum; List <InStorDetailEntity> list = bill.GetOrderDetail(detail); list = list == null ? new List <InStorDetailEntity>() : list; if (list.IsNullOrEmpty() == false) { foreach (InStorDetailEntity item in list) { item.Size = item.Size.IsEmpty() ? "" : item.Size; item.Amount = item.Amount == 0 ? item.InPrice * item.Num : item.Amount; item.TotalPrice = item.Amount; } Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] = list; } ViewBag.Detail = list; return(View()); }
public JsonResult GetIsHaveBatch(string batchCode) { InStorDetailEntity detail = new InStorDetailEntity(); detail.Where(a => a.BatchNum == batchCode); var con = new DataFactory().InStorDetail; int icount = con.GetCount(detail); var re = new { num = icount }; return(Json(re)); }
/// <summary> /// 根据唯一编号查询入库单明细数据行 /// </summary> /// <returns></returns> public ActionResult GetDetailInfo() { string SnNum = WebUtil.GetFormValue <string>("SnNum"); string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); InStorDetailEntity entity = bill.GetDetail(SnNum); DataResult <InStorDetailEntity> dataResult = new DataResult <InStorDetailEntity>(); dataResult.Code = (int)EResponseCode.Success; dataResult.Message = "响应成功"; dataResult.Result = entity; return(Content(JsonHelper.SerializeObject(dataResult))); }
/// <summary> /// 查询入库当详细分页 /// </summary> /// <returns></returns> public ActionResult GetDetailList() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); string BarCode = WebUtil.GetFormValue <string>("BarCode"); string OrderNum = WebUtil.GetFormValue <string>("OrderNum"); string ProductName = WebUtil.GetFormValue <string>("ProductName"); string StorageNum = WebUtil.GetFormValue <string>("StorageNum"); string SupNum = WebUtil.GetFormValue <string>("SupNum"); string SupName = WebUtil.GetFormValue <string>("SupName"); string BeginTime = WebUtil.GetFormValue <string>("BeginTime"); string EndTime = WebUtil.GetFormValue <string>("EndTime"); string ContractOrder = WebUtil.GetFormValue <string>("ContractOrder", string.Empty); int Status = WebUtil.GetFormValue <int>("Status", 0); int InType = WebUtil.GetFormValue <int>("InType", 0); int PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1); int PageSize = WebUtil.GetFormValue <int>("PageSize", 10); InStorDetailEntity entity = new InStorDetailEntity(); entity.CompanyID = CompanyID; entity.BarCode = BarCode; entity.OrderNum = OrderNum; entity.ProductName = ProductName; entity.StorageNum = StorageNum; entity.SupNum = SupNum; entity.SupName = SupName; entity.BeginTime = BeginTime; entity.EndTime = EndTime; entity.Status = Status; entity.InType = InType; entity.ContractOrder = ContractOrder; PageInfo pageInfo = new PageInfo() { PageIndex = PageIndex, PageSize = PageSize }; Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); List <InStorDetailEntity> listResult = bill.GetDetailList(entity, ref pageInfo); DataListResult <InStorDetailEntity> dataResult = new DataListResult <InStorDetailEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = listResult, PageInfo = pageInfo }; return(Content(JsonHelper.SerializeObject(dataResult))); }
public ActionResult EditNum() { string snNum = WebUtil.GetFormValue <string>("SnNum", string.Empty); double num = WebUtil.GetFormValue <double>("num", 0); InStorageProvider provider = new InStorageProvider(); int line = provider.EditInOrderNum(snNum, num); List <InStorDetailEntity> list = Session[CacheKey.TEMPDATA_CACHE_INSTORDETAIL] as List <InStorDetailEntity>; if (!list.IsNullOrEmpty()) { if (list.Exists(a => a.SnNum == snNum)) { InStorDetailEntity detail = list.First(a => a.SnNum == snNum); detail.Num = num; detail.Amount = num * detail.Amount; } } return(Content(string.Empty)); }
/// <summary> /// 编辑入库单的详细项 /// </summary> /// <returns></returns> public ActionResult EditDetail() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); InStorDetailEntity entity = WebUtil.GetFormObject <InStorDetailEntity>("Detail"); Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(CompanyID); string returnValue = bill.EditDetail(entity); DataResult result = new DataResult(); if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue) { result.Code = (int)EResponseCode.Success; result.Message = "入库单详细项编辑成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "入库单详细项编辑失败"; } return(Content(JsonHelper.SerializeObject(result))); }
public static InStorDetail_CE ToCE(InStorDetailEntity item) { InStorDetail_CE target = new InStorDetail_CE(); target.ID = item.ID; target.SnNum = item.SnNum; target.OrderNum = item.OrderNum; target.ProductName = item.ProductName; target.BarCode = item.BarCode; target.ProductNum = item.ProductNum; target.BatchNum = item.BatchNum; target.Num = item.Num; target.IsPick = item.IsPick; target.RealNum = item.RealNum; target.InPrice = item.InPrice; target.Amount = item.Amount; target.CreateTime = item.CreateTime; target.LocalNum = item.LocalNum; target.StorageNum = item.StorageNum; return(target); }
/// <summary> /// 编辑入库单详细数量 /// </summary> /// <param name="snNum"></param> /// <param name="num"></param> /// <returns></returns> public int EditInOrderNum(string snNum, double num) { InStorDetailEntity detail = new InStorDetailEntity(); detail = new InStorDetailEntity(); detail.Include(a => new { a.OrderNum, a.Num, a.InPrice }); detail.Where(a => a.SnNum == snNum); detail = this.InStorDetail.GetSingle(detail); int line = 0; if (detail != null) { InStorDetailEntity editEntity = new InStorDetailEntity(); editEntity.IncludeNum(true).IncludeAmount(true); editEntity.Num = num; editEntity.Amount = num * detail.InPrice; editEntity.Where(a => a.SnNum == snNum); line = this.InStorDetail.Update(editEntity); string orderNum = detail.OrderNum; detail = new InStorDetailEntity(); detail.IncludeNum(true).IncludeAmount(true); detail.Where(a => a.OrderNum == orderNum); List <InStorDetailEntity> list = this.InStorDetail.GetList(detail); double total = list.Sum(a => a.Num); double amount = list.Sum(a => a.Amount); InStorageEntity entity = new InStorageEntity(); entity.Num = total; entity.Amount = amount; entity.IncludeNum(true).IncludeAmount(true); entity.Where(a => a.OrderNum == orderNum); line += this.InStorage.Update(entity); } return(line); }
public ActionResult AddProduct() { List <InStorDetailEntity> listDetail = Session[SessionKey.SESSION_INSTORAGE_DETAIL] as List <InStorDetailEntity>; listDetail = listDetail.IsNull() ? new List <InStorDetailEntity>() : listDetail; InStorDetailEntity entity = WebUtil.GetFormObject <InStorDetailEntity>("Entity"); if (entity != null) { entity.SnNum = ConvertHelper.NewGuid(); entity.CompanyID = this.CompanyID; entity.Amount = entity.InPrice * entity.Num; listDetail.Add(entity); } DataResult dataResult = new DataResult() { Code = (int)EResponseCode.Success, Message = "响应成功" }; return(Content(JsonHelper.SerializeObject(dataResult))); }
public ActionResult Detail() { string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty); string flag = WebUtil.GetQueryStringValue <string>("flag", "1"); Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(); InStorageEntity entity = new InStorageEntity(); entity.OrderNum = orderNum; entity = bill.GetOrder(entity); entity = entity == null ? new InStorageEntity(): entity; entity.InTypeLable = EnumHelper.GetEnumDesc <EInType>(entity.InType); entity.StatusLable = EnumHelper.GetEnumDesc <EAudite>(entity.Status); ViewBag.InStorage = entity; ViewBag.Flag = flag; InStorDetailEntity detail = new InStorDetailEntity(); detail.OrderNum = orderNum; List <InStorDetailEntity> list = bill.GetOrderDetail(detail); list = list == null ? new List <InStorDetailEntity>() : list; ViewBag.Detail = list; return(View()); }
/// <summary> /// 根据采购订单转化为入库单 /// 1: 采购订单生成入库单成功 /// 1001:采购订单不存在 /// 1002:采购订单已经全部入库,请勿重新入库 /// 1003: 订单已经被取消,不能入库 /// 1004: 采购订单中不存在入库物品 /// 1005: 存在不在采购单内的货品 /// </summary> /// <param name="SnNum">采购订单唯一编号</param> /// <param name="list">要入库的内容</param> /// <param name="StorageNum">仓库编号</param> /// <param name="CreateUser">操作人编号</param> /// <returns></returns> public DataResult ToInStorage(string SnNum, List <PurchaseDetailEntity> list, string StorageNum, string CreateUser) { PurchaseEntity entity = new PurchaseEntity(); entity.SnNum = SnNum; entity = this.GetOrder(entity); DataResult result = new DataResult(); if (entity == null) { result.Code = 1001; result.Message = "采购订单不存在"; return(result); } if (entity.Status < (int)EPurchaseStatus.InTheStock) { result.Code = 1001; result.Message = "采购订单审核流程不正确,不能生成入库单"; return(result); } if (entity.Status == (int)EPurchaseStatus.AllIn) { result.Code = 1002; result.Message = "采购订单已经全部入库,请勿重新入库"; return(result); } if (entity.Status == (int)EPurchaseStatus.OrderCancel) { result.Code = 1003; result.Message = "订单已经被取消,不能入库"; return(result); } PurchaseDetailEntity detailEntity = new PurchaseDetailEntity(); detailEntity.OrderSnNum = SnNum; List <PurchaseDetailEntity> listSource = this.GetOrderDetail(detailEntity); if (listSource.IsNullOrEmpty()) { result.Code = 1004; result.Message = "采购订单中不存在入库物品"; return(result); } //检查入库产品是否在采购单内 List <PurchaseDetailEntity> listExists = new List <PurchaseDetailEntity>(); foreach (PurchaseDetailEntity item in list) { if (!listSource.Exists(a => a.SnNum == item.SnNum)) { //不存在添加到集合 listExists.Add(item); } } if (!listExists.IsNullOrEmpty()) { string content = listExists.Select(a => string.Format("[{0}]{1}", a.BarCode, a.ProductName)).ToArray().ToString(); result.Code = 1005; result.Message = content + " 不在采购订单[" + entity.OrderNum + "]中,请重新确认再入库"; return(result); } InStorageEntity InEntity = new InStorageEntity(); InEntity.SnNum = ConvertHelper.NewGuid(); InEntity.InType = (int)EInType.Purchase; InEntity.ProductType = (int)EProductType.Goods; InEntity.StorageNum = StorageNum; InEntity.SupNum = entity.SupNum; InEntity.SupSnNum = entity.SupSnNum; InEntity.SupName = entity.SupName; InEntity.ContactName = entity.Contact; InEntity.Phone = entity.Phone; InEntity.Address = entity.Address; InEntity.ContractOrder = entity.SnNum; //0 无关联 1 采购 2 出库 3退货 InEntity.ContractType = 1; InEntity.Status = (int)EAudite.Wait; InEntity.IsDelete = (int)EIsDelete.NotDelete; InEntity.CreateTime = DateTime.Now; InEntity.OrderTime = DateTime.Now; InEntity.CreateUser = CreateUser; InEntity.CompanyID = this.CompanyID; List <InStorDetailEntity> listDetail = new List <InStorDetailEntity>(); foreach (PurchaseDetailEntity item in list) { InStorDetailEntity InDetail = new InStorDetailEntity(); InDetail.SnNum = ConvertHelper.NewGuid(); InDetail.OrderSnNum = InEntity.SnNum; InDetail.ProductNum = item.ProductNum; InDetail.ProductName = item.ProductName; InDetail.BarCode = item.BarCode; InDetail.BatchNum = item.BatchNum; InDetail.Num = item.Qty; InDetail.InPrice = item.Price; InDetail.Amount = item.Qty * item.Price; InDetail.ContractOrder = item.SnNum; InDetail.CreateTime = DateTime.Now; InDetail.LocalNum = item.LocalNum; InDetail.StorageNum = StorageNum; InDetail.CreateUser = CreateUser; InDetail.CompanyID = this.CompanyID; listDetail.Add(InDetail); } string returnValue = string.Empty; using (TransactionScope ts = new TransactionScope()) { Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder(this.CompanyID); returnValue = bill.Create(InEntity, listDetail); if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue) { foreach (PurchaseDetailEntity item in list) { if (item.RealNum + item.Qty >= item.Num) { item.Status = (int)EPurchaseStatus.AllIn; item.RealNum += item.Qty; } else if ((item.RealNum + item.Qty) < item.Num && (item.RealNum + item.Qty) > 0) { item.Status = (int)EPurchaseStatus.PartialIn; item.RealNum += item.Qty; } item.Include(a => new { a.RealNum, a.Status }); item.Where(a => a.SnNum == item.SnNum); this.PurchaseDetail.Update(item); } //再次查询校验状态 detailEntity = new PurchaseDetailEntity(); detailEntity.OrderSnNum = SnNum; listSource = this.GetOrderDetail(detailEntity); if (!listSource.IsNullOrEmpty()) { if (listSource.Count(a => a.Status == (int)EPurchaseStatus.PartialIn) > 0 || (listSource.Count(a => a.Status == (int)EPurchaseStatus.AllIn) < listSource.Count() && listSource.Count(a => a.Status == (int)EPurchaseStatus.AllIn) > 0) ) { entity.Status = (int)EPurchaseStatus.PartialIn; } else if (listSource.Count(a => a.Status == (int)EPurchaseStatus.AllIn) == listSource.Count()) { entity.Status = (int)EPurchaseStatus.AllIn; } entity.IncludeStatus(true); entity.Where(a => a.SnNum == entity.SnNum); this.Purchase.Update(entity); } result.Code = (int)EResponseCode.Success; result.Message = "入库单创建成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "入库单创建失败"; } ts.Complete(); } return(result); }