示例#1
0
        public ActionResult AddOtherOutOfStorage(OtherOutOfStorage model, string ProductSysNo, string ProductCode, string BarCode, string ProductName, string Count, string UnitPrice, string Price, string Remarks, string CollectWarehouseSysNo, string CollectWarehouseName, int?PageType)
        {
            Result <object> result = new Result <object>();

            #region 其他出入库信息
            model.Type    = PageType == (int)OtherOutOfStorageTypeEnum.其他入库 ? (int)OtherOutOfStorageTypeEnum.其他入库 : (int)OtherOutOfStorageTypeEnum.其他出库;
            model.AddTime = DateTime.Now;
            model.Status  = (int)OtherOutOfStorageStatusEnum.审核中;
            #endregion

            #region 其他出入库商品明细
            model.ListData = new List <OtherOutOfStorageDetailed>();
            for (int i = 0; i < ProductSysNo.Trim(',').Split(',').Length; i++)
            {
                OtherOutOfStorageDetailed product = new OtherOutOfStorageDetailed();
                product.ProductSysNo          = Convert.ToInt32(ProductSysNo.Trim(',').Split(',')[i]);
                product.ProductCode           = ProductCode.Trim(',').Split(',')[i];
                product.BarCode               = BarCode.Trim(',').Split(',')[i];
                product.ProductName           = ProductName.Trim(',').Split(',')[i];
                product.Count                 = Convert.ToDecimal(Count.Trim(',').Split(',')[i]);
                product.UnitPrice             = Convert.ToDecimal(UnitPrice.Trim(',').Split(',')[i]);
                product.Price                 = Convert.ToDecimal(Price.Trim(',').Split(',')[i]);
                product.Remarks               = Remarks.Trim('^').Split('^')[i];
                product.CollectWarehouseSysNo = Convert.ToInt32(CollectWarehouseSysNo.Trim(',').Split(',')[i]);
                product.CollectWarehouseName  = CollectWarehouseName.Trim(',').Split(',')[i];
                model.ListData.Add(product);
            }
            #endregion
            if (Hyt.BLL.InventorySheet.WhInventoryBo.Instance.AddOtherOutOfStorage(model) > 0)
            {
                result.Status  = true;
                result.Message = "成功!";
                return(Json(result));
            }
            else
            {
                result.Status  = false;
                result.Message = "错误,提交失败!";
                return(Json(result));
            }
        }
示例#2
0
        public Resuldt <OtherOutOfStorageDetailed> OtherImportExcel(System.IO.Stream stream, int SysNo)
        {
            DataTable dt   = null;
            var       cols = OtherDicColsMapping.Select(p => p.Value).ToArray();

            try
            {
                dt = ExcelUtil.ImportExcel(stream, cols);
            }
            catch (Exception ex)
            {
                return(new Resuldt <OtherOutOfStorageDetailed>
                {
                    Message = string.Format("数据导入错误,请选择正确的excel文件"),
                    Status = false
                });
            }
            if (dt == null)
            {
                //not all the cols mapped
                return(new Resuldt <OtherOutOfStorageDetailed>
                {
                    Message = string.Format("请选择正确的excel文件!"),
                    Status = false
                });
            }

            if (dt.Rows.Count == 0)
            {
                return(new Resuldt <OtherOutOfStorageDetailed>
                {
                    Message = "导入的数据为空!",
                    Status = false
                });
            }
            Resuldt <OtherOutOfStorageDetailed> run       = new Resuldt <OtherOutOfStorageDetailed>();
            List <OtherOutOfStorageDetailed>    listModel = new List <OtherOutOfStorageDetailed>();
            int    fail    = 0;  //失败记录数
            int    success = 0;  //成功记录数
            string failstr = ""; //失败条数记录

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                OtherOutOfStorageDetailed model = new OtherOutOfStorageDetailed();
                var product = PdProductBo.Instance.GetProductErpCode(dt.Rows[i]["商品代码"].ToString(), dt.Rows[i]["商品条形码"].ToString());
                var ware    = Hyt.BLL.Web.WhWarehouseBo.Instance.GetModelErpCode(dt.Rows[i][7].ToString());
                if (product == null || ware == null)
                {
                    fail++;
                    failstr += (i + 2) + "、";
                    dt.Rows.Remove(dt.Rows[i]);
                }
                else
                {
                    #region 判断商品是否已入库,若未入库将商品插入至商品库存表
                    var Stock = IWhInventoryDao.Instance.GetuditPdProductStockTo(dt.Rows[i]["商品代码"].ToString().Trim(), dt.Rows[i][7].ToString().Trim());
                    if (Stock == null)
                    {
                        // WhInventoryBo
                        PdProductStock stockModel = new PdProductStock()
                        {
                            WarehouseSysNo    = ware.SysNo,
                            PdProductSysNo    = product.SysNo,
                            StockQuantity     = 0,
                            LockStockQuantity = 0,
                            CreatedDate       = DateTime.Now,
                            Barcode           = product.Barcode,
                            CostPrice         = 0,
                            CustomsNo         = "",
                            InStockTime       = "",
                            Remark            = "库存盘点自动入库"
                        };
                        PdProductStockBo.Instance.SaveProductStock(stockModel, 0);
                    }
                    #endregion

                    //重新获取商品库存信息
                    Stock = IWhInventoryDao.Instance.GetuditPdProductStockTo(dt.Rows[i]["商品代码"].ToString().Trim(), dt.Rows[i][7].ToString().Trim());
                    success++;
                    model.ProductCode           = product.ErpCode;
                    model.BarCode               = product.Barcode;
                    model.ProductName           = product.EasName;
                    model.Count                 = dt.Rows[i]["实收数量"] != DBNull.Value ? Convert.ToDecimal(dt.Rows[i]["实收数量"]) : Convert.ToDecimal(0.00);
                    model.UnitPrice             = dt.Rows[i]["单价"] != DBNull.Value ? Convert.ToDecimal(dt.Rows[i]["单价"]) : Convert.ToDecimal(0.00);
                    model.Price                 = (model.Count * model.UnitPrice);
                    model.Remarks               = dt.Rows[i]["备注"].ToString();
                    model.ProductSysNo          = product.SysNo;
                    model.CollectWarehouseName  = ware.BackWarehouseName;
                    model.CollectWarehouseCode  = ware.ErpCode;
                    model.CollectWarehouseSysNo = ware.SysNo;
                    listModel.Add(model);
                }
            }
            if (success > 0 && dt.Rows.Count > 0)
            {
                run.Data = dt;
            }
            if (success > 0 && listModel != null)
            {
                run.listModel = listModel;
            }
            run.Message = "导入成功" + success + "件商品,失败" + fail + "件商品;";
            if (fail > 0)
            {
                run.Message += "失败原因为:产品编码或仓库erp编码有误,不存在此件商品或仓库。失败条数为第" + failstr.Trim('、') + "条。";
            }
            run.Status = true;
            return(run);
        }