Beispiel #1
0
        /// <summary>
        /// 创建盘点作业
        /// </summary>
        /// <param name="model">盘点实体</param>
        /// <param name="productModel">盘点商品实体</param>
        /// <returns></returns>
        public override int AddWhInventory(Hyt.Model.InventorySheet.WhInventory model, List <WhInventoryProduct> productModel)
        {
            int sysNo = 0;

            using (var context = Context.UseTransaction(true))
            {
                try
                {
                    sysNo = Context.Insert("WhInventory", model).AutoMap(x => x.SysNo).ExecuteReturnLastId <int>("SysNo");
                    if (sysNo > 0)
                    {
                        foreach (var item in productModel)
                        {
                            item.InventorySysNo = sysNo;
                            Context.Insert("WhInventoryProduct", item).AutoMap(x => x.SysNo).ExecuteReturnLastId <int>("SysNo");
                        }
                    }
                    context.Commit();
                }
                catch (Exception)
                {
                    //回滚
                    sysNo = 0;
                    context.Rollback();
                }
            }
            return(sysNo);
        }
Beispiel #2
0
 public ActionResult EditInventory(string id)
 {
     Hyt.Model.InventorySheet.WhInventory model = new Hyt.Model.InventorySheet.WhInventory();
     ViewBag.Name  = MvcHtmlString.Create(MvcCreateHtml.EnumToString <Hyt.Model.InventorySheet.WhlnventoryEnum.WhlnventoryName>(null, null).ToString());
     ViewBag.Where = MvcHtmlString.Create(MvcCreateHtml.EnumToString <Hyt.Model.InventorySheet.WhlnventoryEnum.WhlnventoryWhere>(null, null).ToString());
     //ViewBag.Type = GetSyUserList((int)Hyt.Model.WorkflowStatus.SystemStatus.用户组状态.启用);
     //if (!string.IsNullOrEmpty(id))
     //{
     //    model = WhInventoryBo.Instance.GetModelId(Guid.Parse(id));
     //}
     return(View(model));
 }
Beispiel #3
0
 /// <summary>
 /// 创建盘点作业
 /// </summary>
 /// <param name="model">盘点实体</param>
 /// <param name="productModel">盘点商品实体</param>
 /// <returns></returns>
 public abstract int AddWhInventory(Hyt.Model.InventorySheet.WhInventory model, List <WhInventoryProduct> productModel);
Beispiel #4
0
        public ActionResult AddWhInventory(string WhInventoryStr, int Type, string whereStr, string TypeIdStr, string brandIdStr)
        {
            if (string.IsNullOrEmpty(WhInventoryStr))
            {
                return(Json(new Result {
                    Status = false, Message = "请选择需要盘点的仓库!"
                }, JsonRequestBehavior.AllowGet));
            }
            List <CBPdProductStockList> pager = null;

            #region 获取库存商品
            if (Type == (int)Hyt.Model.InventorySheet.WhlnventoryEnum.WhlnventoryType.仓位商品)
            {
                if (!string.IsNullOrEmpty(whereStr))
                {
                    whereStr = whereStr.Replace("物料代码", "p.ErpCode");
                    whereStr = whereStr.Replace("物料名称", "p.EasName");
                    whereStr = whereStr.Replace("仓位代码", "w.erpCode");
                    whereStr = whereStr.Replace("仓位名称", "w.WarehouseName");
                    whereStr = whereStr.Replace("条形码", "p.Barcode");
                }
                pager = PdProductStockBo.Instance.GetPdProductStockListData(WhInventoryStr.Trim(','), whereStr, "", "");
            }
            if (Type == (int)Hyt.Model.InventorySheet.WhlnventoryEnum.WhlnventoryType.品牌)
            {
                if (string.IsNullOrEmpty(brandIdStr))
                {
                    return(Json(new Result {
                        Status = false, Message = "请选择需要盘点的商品品牌!"
                    }, JsonRequestBehavior.AllowGet));
                }
                pager = PdProductStockBo.Instance.GetPdProductStockListData(WhInventoryStr.Trim(','), "", brandIdStr.Trim(','), "");
            }
            if (Type == (int)Hyt.Model.InventorySheet.WhlnventoryEnum.WhlnventoryType.商品类别)
            {
                if (string.IsNullOrEmpty(TypeIdStr))
                {
                    return(Json(new Result {
                        Status = false, Message = "请选择需要盘点的商品类别!"
                    }, JsonRequestBehavior.AllowGet));
                }
                pager = PdProductStockBo.Instance.GetPdProductStockListData(WhInventoryStr.Trim(','), "", "", TypeIdStr.Trim(','));
            }
            if (pager == null || pager.Count == 0)
            {
                return(Json(new Result {
                    Status = false, Message = "没有可用的数据,不能备份!"
                }, JsonRequestBehavior.AllowGet));
            }
            #endregion

            #region 获取盘点代码
            var sl   = (Hyt.BLL.InventorySheet.WhInventoryBo.Instance.GetWhInventoryCount() + 1);
            var Code = "";
            if (sl.ToString().Length == 1)
            {
                Code = DateTime.Now.ToString("yyyyMMdd") + "000" + sl;
            }
            if (sl.ToString().Length == 2)
            {
                Code = DateTime.Now.ToString("yyyyMMdd") + "00" + sl;
            }
            if (sl.ToString().Length == 3)
            {
                Code = DateTime.Now.ToString("yyyyMMdd") + "0" + sl;
            }
            if (sl.ToString().Length == 4)
            {
                Code = DateTime.Now.ToString("yyyyMMdd") + sl;
            }
            #endregion

            #region 创建盘点作业
            Hyt.Model.InventorySheet.WhInventory model = new Hyt.Model.InventorySheet.WhInventory()
            {
                Code              = Code,
                CreatedBy         = CurrentUser.Base.SysNo,
                CreatedName       = CurrentUser.Base.UserName,
                Status            = (int)Hyt.Model.InventorySheet.WhlnventoryEnum.WhlnventoryStatus.未处理,
                InventoryWhere    = whereStr,
                WhInventorySysNo  = WhInventoryStr.Trim(','),
                ProductTypeSysNo  = TypeIdStr.Trim(','),
                ProductBrandSysNo = brandIdStr.Trim(','),
                AddTime           = DateTime.Now
            };
            List <WhInventoryProduct> produceModelList = new List <WhInventoryProduct>();
            foreach (var item in pager)
            {
                var produceModel = new WhInventoryProduct()
                {
                    WarehouseSysNo    = item.WarehouseSysNo,
                    ProductSysNo      = item.ProductSysNo,
                    ZhangCunQuantity  = Convert.ToDecimal(item.StockQuantity),
                    InventoryQuantity = Convert.ToDecimal(item.StockQuantity),
                    adjustmenQuantity = 0,
                    Quantity          = 0,
                    Status            = -1,
                    Remarks           = ""
                };
                produceModelList.Add(produceModel);
            }
            int sysno = Hyt.BLL.InventorySheet.WhInventoryBo.Instance.AddWhInventory(model, produceModelList);
            if (sysno > 0)
            {
                return(Json(new Result {
                    Status = true, Message = "成功"
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new Result {
                    Status = true, Message = "失败"
                }, JsonRequestBehavior.AllowGet));
            }
            #endregion
        }
Beispiel #5
0
 /// <summary>
 /// 创建盘点作业
 /// </summary>
 /// <param name="model">盘点实体</param>
 /// <param name="productModel">盘点商品实体</param>
 /// <returns></returns>
 public int AddWhInventory(Hyt.Model.InventorySheet.WhInventory model, List <WhInventoryProduct> productModel)
 {
     return(IWhInventoryDao.Instance.AddWhInventory(model, productModel));
 }