Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] Stock value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var log = new StockLog();

            log.ItemId = value.ItemId; log.Quantity = value.Quantity;
            log.UserId = value.UserId; log.Date = value.Date;
            var stock = _stockRepository.Query().Where(s => s.ItemId == value.ItemId).FirstOrDefault();

            if (stock != null)
            {
                stock.Quantity += value.Quantity; log.StockId = stock.StockId;
                stock.MUserId   = value.MUserId; stock.MDate = value.MDate;
                await _stockRepository.UpdateAsync(stock);

                await _stocklogRepository.InsertAsync(log);

                return(Ok(stock));
            }
            await _stockRepository.InsertAsync(value);

            log.StockId = stock.StockId;
            await _stocklogRepository.InsertAsync(log);

            return(Created($"stock/{value.StockId}", value));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            StockLog stockLog = db.StockLogs.Find(id);

            db.StockLogs.Remove(stockLog);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,ProduitId,Type,Amount,Date")] StockLog stockLog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stockLog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(stockLog));
 }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,ProduitId,Type,Amount,Date")] StockLog stockLog)
        {
            if (ModelState.IsValid)
            {
                stockLog.Id = Guid.NewGuid();
                db.StockLogs.Add(stockLog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stockLog));
        }
Ejemplo n.º 5
0
        // GET: StockLogs/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockLog stockLog = db.StockLogs.Find(id);

            if (stockLog == null)
            {
                return(HttpNotFound());
            }
            return(View(stockLog));
        }
Ejemplo n.º 6
0
        public ActionResult InvoiceDetail(int orderId, int adminId)
        {
            var      order = orderService.Delivery(orderId);
            StockLog log   = new StockLog()
            {
                GoodsId         = order.GoodsId,
                OperationRecord = "发货",
                AdminId         = (int)Session["AdminId"],
                OperationTime   = DateTime.Now,
                WarehouseId     = order.WarehouseId,
                OrderId         = order.OrderId,
                VersionId       = order.VersionId,
                Stock           = -1,
            };

            warehouseService.AddWarehouseLog(log);
            return(RedirectToAction("InvoiceList"));
        }
Ejemplo n.º 7
0
 public void AddWarehouseLog(StockLog log)
 {
     _x.StockLog.Add(log);
     _x.SaveChanges();
 }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op   = RequestData.Get <string>("op");
            id   = RequestData.Get <string>("id");
            type = RequestData.Get <string>("type");
            ent  = StockCheck.Find(id);
            switch (RequestActionString)
            {
            case "WorkFlowEnd":
                ent.WorkFlowState = RequestData.Get <string>("state");
                ent.ExamineResult = RequestData.Get <string>("ApprovalState");
                ent.State         = "已结束";
                ent.DoUpdate();
                IList <StockCheckDetail> scdEnts = StockCheckDetail.FindAllByProperty("StockCheckId", id);
                foreach (StockCheckDetail scdEnt in scdEnts)
                {
                    if (scdEnt.StockCheckResult != "正常")
                    {
                        scdEnt.StockCheckState = "盘点结束";
                        scdEnt.DoUpdate();
                    }
                }
                if (ent.ExamineResult == "同意")
                {
                    foreach (StockCheckDetail scdEnt in scdEnts)
                    {
                        if (scdEnt.StockCheckResult != "正常")    //创建库存变更日志  并更改库存
                        {
                            StockLog slEnt = new StockLog();
                            slEnt.InOrOutDetailId = scdEnt.Id;
                            StockCheck scEnt = StockCheck.Find(scdEnt.StockCheckId);
                            slEnt.InOrOutBillNo = scEnt.StockCheckNo;
                            slEnt.OperateType   = "库存盘点";
                            slEnt.WarehouseId   = scEnt.WarehouseId;
                            slEnt.WarehouseName = scEnt.WarehouseName;
                            slEnt.StockQuantity = scdEnt.StockQuantity;
                            slEnt.Quantity      = scdEnt.StockCheckQuantity - scdEnt.StockQuantity;
                            slEnt.ProductId     = scdEnt.ProductId;
                            Product pEnt = Product.Find(scdEnt.ProductId);
                            slEnt.ProductName = pEnt.Name;
                            slEnt.ProductCode = pEnt.Code;
                            slEnt.ProductIsbn = pEnt.Isbn;
                            slEnt.ProductPcn  = pEnt.Pcn;
                            slEnt.CreateId    = UserInfo.UserID;
                            slEnt.CreateName  = UserInfo.Name;
                            slEnt.CreateTime  = System.DateTime.Now;
                            slEnt.DoCreate();
                            IList <StockInfo> siEnts = StockInfo.FindAllByProperties("ProductId", scdEnt.ProductId, "WarehouseId", ent.WarehouseId);
                            if (siEnts.Count > 0)
                            {
                                siEnts[0].StockQuantity = scdEnt.StockCheckQuantity;
                                siEnts[0].DoUpdate();
                            }
                        }
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    SetFormData(ent);
                }
            }
        }
Ejemplo n.º 9
0
        private void CreateLog()
        {
            IList <InWarehouseDetailDetail> iwddEnts = InWarehouseDetailDetail.FindAll();//入库

            foreach (InWarehouseDetailDetail iwddEnt in iwddEnts)
            {
                StockLog    slEnt = new StockLog();
                InWarehouse iwEnt = null;
                if (!string.IsNullOrEmpty(iwddEnt.InWarehouseDetailId))
                {
                    slEnt.InOrOutDetailId = iwddEnt.InWarehouseDetailId;
                    InWarehouseDetail iwdEnt = InWarehouseDetail.Find(iwddEnt.InWarehouseDetailId);
                    iwEnt = InWarehouse.Find(iwdEnt.InWarehouseId);
                }
                else
                {
                    slEnt.InOrOutDetailId = iwddEnt.OtherInWarehouseDetailId;
                    OtherInWarehouseDetail oiwdEnt = OtherInWarehouseDetail.Find(iwddEnt.OtherInWarehouseDetailId);
                    iwEnt = InWarehouse.Find(oiwdEnt.InWarehouseId);
                }
                slEnt.InOrOutBillNo = iwEnt.InWarehouseNo;
                slEnt.OperateType   = "产品入库";
                slEnt.WarehouseId   = iwEnt.WarehouseId;
                slEnt.WarehouseName = iwEnt.WarehouseName;
                //IList<StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, iwddEnt.ProductId, StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                //if (siEnts.Count > 0)
                //{
                //    slEnt.StockQuantity = siEnts[0].StockQuantity;
                //}
                slEnt.Quantity  = iwddEnt.Quantity;
                slEnt.ProductId = iwddEnt.ProductId;
                Product pEnt = Product.TryFind(iwddEnt.ProductId);
                if (pEnt != null)
                {
                    slEnt.ProductName = pEnt.Name;
                    slEnt.ProductCode = pEnt.Code;
                    slEnt.ProductIsbn = pEnt.Isbn;
                    slEnt.ProductPcn  = pEnt.Pcn;
                    slEnt.CreateId    = iwddEnt.CreateId;
                    slEnt.CreateName  = iwddEnt.CreateName;
                    slEnt.CreateTime  = iwddEnt.CreateTime;
                    slEnt.DoCreate();
                }
            }
            //生成出库日志
            IList <DelieryOrderPart> dopEnts = DelieryOrderPart.FindAllByProperty(DelieryOrderPart.Prop_State, "已出库");

            foreach (DelieryOrderPart dopEnt in dopEnts)
            {
                StockLog slEnt = new StockLog();
                slEnt.InOrOutDetailId = dopEnt.Id;
                DeliveryOrder doEnt = DeliveryOrder.Find(dopEnt.DId);
                slEnt.InOrOutBillNo = doEnt.Number;
                slEnt.OperateType   = "产品出库";
                slEnt.WarehouseId   = doEnt.WarehouseId;
                slEnt.WarehouseName = doEnt.WarehouseName;
                //IList<StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, iwddEnt.ProductId, StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                //if (siEnts.Count > 0)
                //{
                //    slEnt.StockQuantity = siEnts[0].StockQuantity;
                //}
                slEnt.Quantity = dopEnt.OutCount;
                if (!string.IsNullOrEmpty(dopEnt.ProductId))
                {
                    slEnt.ProductId = dopEnt.ProductId;
                    Product pEnt = Product.TryFind(dopEnt.ProductId);
                    if (pEnt != null)
                    {
                        slEnt.ProductName = pEnt.Name;
                        slEnt.ProductCode = pEnt.Code;
                        slEnt.ProductIsbn = pEnt.Isbn;
                        slEnt.ProductPcn  = pEnt.Pcn;
                        slEnt.CreateId    = dopEnt.CreateId;
                        slEnt.CreateName  = dopEnt.CreateName;
                        slEnt.CreateTime  = dopEnt.CreateTime;
                        slEnt.DoCreate();
                    }
                }
            }
            //盘点操作库存日志
            string sql = "select * from SHHG_AimExamine..StockCheckDetail where StockCheckResult!='正常' and StockCheckState='盘点结束'";
            IList <EasyDictionary> scdDics = DataHelper.QueryDictList(sql);

            foreach (EasyDictionary scdDic in scdDics)
            {
                StockLog slEnt = new StockLog();
                slEnt.InOrOutDetailId = scdDic.Get <string>("Id");
                StockCheck scEnt = StockCheck.Find(scdDic.Get <string>("StockCheckId"));
                slEnt.InOrOutBillNo = scEnt.StockCheckNo;
                slEnt.OperateType   = "库存盘点";
                slEnt.WarehouseId   = scEnt.WarehouseId;
                slEnt.WarehouseName = scEnt.WarehouseName;
                slEnt.StockQuantity = scdDic.Get <Int32>("StockQuantity");
                slEnt.Quantity      = scdDic.Get <Int32>("StockCheckQuantity") - scdDic.Get <Int32>("StockQuantity");
                slEnt.ProductId     = scdDic.Get <string>("ProductId");
                Product pEnt = Product.TryFind(slEnt.ProductId);
                if (pEnt != null)
                {
                    slEnt.ProductName = pEnt.Name;
                    slEnt.ProductCode = pEnt.Code;
                    slEnt.ProductIsbn = pEnt.Isbn;
                    slEnt.ProductPcn  = pEnt.Pcn;
                    slEnt.CreateId    = scEnt.CreateId;
                    slEnt.CreateName  = scEnt.CreateName;
                    slEnt.CreateTime  = scEnt.CreateTime;
                    slEnt.DoCreate();
                }
            }
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");
            id = RequestData.Get <string>("id");
            switch (RequestActionString)
            {
            case "IsIsbn":
                string          val     = RequestData.Get <string>("Value");
                IList <Product> proEnts = Product.FindAll("from Product where Isbn='" + val + "'");
                if (proEnts.Count > 0)
                {
                    PageState.Add("IsIsbn", true);
                }
                else
                {
                    PageState.Add("IsIsbn", false);
                }
                break;

            case "GetPackageInfo":
                string Isbn = RequestData.Get <string>("Isbn");
                sql = "select * from SHHG_AimExamine..Products where FirstSkinIsbn='" + Isbn + "' and FirstSkinCapacity is not null";
                IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
                if (dics.Count > 0)
                {
                    PageState.Add("ProductIsbn", dics[0].Get <string>("Isbn").ToUpper());
                    PageState.Add("ProductQuan", dics[0].Get <int>("FirstSkinCapacity"));
                }
                sql  = "select * from SHHG_AimExamine..Products where SecondSkinIsbn='" + Isbn + "' and SecondSkinCapacity is not null";
                dics = DataHelper.QueryDictList(sql);
                if (dics.Count > 0)
                {
                    PageState.Add("ProductIsbn", dics[0].Get <string>("Isbn").ToUpper());
                    PageState.Add("ProductQuan", dics[0].Get <int>("SecondSkinCapacity"));
                }
                break;

            case "ScanSkin":    //判断包装编号是否存在
                string       skinNo = RequestData.Get <string>("SkinNo");
                IList <Skin> sEnts  = Skin.FindAll("from Skin where SkinNo='" + skinNo + "'");
                if (sEnts.Count > 0)    //如果该包装的记录不存在
                {
                    PageState.Add("SkinExist", true);
                }
                else
                {
                    PageState.Add("SkinExist", false);
                }
                break;

            case "ScanCompressor":
                string             seriesNo = RequestData.Get <string>("SeriesNo");
                IList <Compressor> cEnts    = Compressor.FindAll("from Compressor where SeriesNo='" + seriesNo + "'");
                if (cEnts.Count == 0)
                {
                    PageState.Add("CompressorExist", false);
                }
                else
                {
                    PageState.Add("CompressorExist", true);
                }
                break;

            case "InWarehouse":
                InWarehouse    iwEnt      = InWarehouse.TryFind(id);
                IList <string> entStrList = RequestData.GetList <string>("data");
                if (entStrList != null && entStrList.Count > 0)
                {
                    for (int j = 0; j < entStrList.Count; j++)
                    {
                        Newtonsoft.Json.Linq.JObject objL = JsonHelper.GetObject <Newtonsoft.Json.Linq.JObject>(entStrList[j]);
                        if (Convert.ToInt32(objL.Value <string>("ActuallyQuantity")) > 0)    //只有输入了入库数量才会增加实际入库记录
                        {
                            InWarehouseDetailDetail iwddEnt = new InWarehouseDetailDetail(); //新建一个实际入库详细信息
                            if (iwEnt.InWarehouseType == "采购入库")
                            {
                                iwddEnt.InWarehouseDetailId   = objL.Value <string>("Id");
                                iwddEnt.PurchaseOrderDetailId = objL.Value <string>("PurchaseOrderDetailId");
                            }
                            else    //其他入库的情形
                            {
                                iwddEnt.OtherInWarehouseDetailId = objL.Value <string>("Id");
                            }
                            iwddEnt.Quantity  = Convert.ToInt32(objL.Value <string>("ActuallyQuantity"));
                            iwddEnt.ProductId = objL.Value <string>("ProductId");
                            iwddEnt.Remark    = objL.Value <string>("Remark");
                            iwddEnt.DoCreate();

                            StockLog slEnt = new StockLog();    //创建库存变更日志
                            slEnt.InOrOutDetailId = objL.Value <string>("Id");
                            slEnt.InOrOutBillNo   = iwEnt.InWarehouseNo;
                            slEnt.OperateType     = "产品入库";
                            slEnt.WarehouseId     = iwEnt.WarehouseId;
                            slEnt.WarehouseName   = iwEnt.WarehouseName;
                            IList <StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, objL.Value <string>("ProductId"), StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                            if (siEnts.Count > 0)
                            {
                                slEnt.StockQuantity = siEnts[0].StockQuantity;
                            }
                            slEnt.Quantity  = Convert.ToInt32(objL.Value <string>("ActuallyQuantity"));
                            slEnt.ProductId = objL.Value <string>("ProductId");
                            Product pEnt = Product.Find(objL.Value <string>("ProductId"));
                            slEnt.ProductName = pEnt.Name;
                            slEnt.ProductCode = pEnt.Code;
                            slEnt.ProductIsbn = pEnt.Isbn;
                            slEnt.ProductPcn  = pEnt.Pcn;
                            slEnt.DoCreate();

                            ProcessSkin(objL.Value <string>("SkinArray"), objL.Value <string>("ISBN"), iwEnt.Id);
                            ProcessCompressor(objL.Value <string>("SeriesArray"), objL.Value <string>("ISBN"), iwEnt.Id);
                            processremark(objL.Value <string>("Remark"), pEnt, iwEnt.Id);

                            //如果实际入库数量和未入库的数量相等 则入库状态为已入库
                            if (objL.Value <string>("ActuallyQuantity") == objL.Value <string>("NoIn"))
                            {
                                if (iwEnt.InWarehouseType == "采购入库")
                                {
                                    InWarehouseDetail iwdEnt = InWarehouseDetail.Find(objL.Value <string>("Id"));
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SkinArray")))
                                    {
                                        iwdEnt.SkinArray = objL.Value <string>("SkinArray").ToString();
                                    }
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SeriesArray")))
                                    {
                                        iwdEnt.SeriesArray = objL.Value <string>("SeriesArray").ToString();
                                    }
                                    iwdEnt.InWarehouseState = "已入库";
                                    iwdEnt.DoUpdate();
                                }
                                else
                                {
                                    OtherInWarehouseDetail oiwdEnt = OtherInWarehouseDetail.Find(objL.Value <string>("Id"));
                                    oiwdEnt.InWarehouseState = "已入库";
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SkinArray")))
                                    {
                                        oiwdEnt.SkinArray = objL.Value <string>("SkinArray").ToString();
                                    }
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SeriesArray")))
                                    {
                                        oiwdEnt.SeriesArray = objL.Value <string>("SeriesArray").ToString();
                                    }
                                    oiwdEnt.DoUpdate();
                                }
                            }
                            else    //如果未入库的数量不等于现在输入的数量。只更新包装和压缩机序列号集合
                            {
                                if (iwEnt.InWarehouseType == "采购入库")
                                {
                                    InWarehouseDetail iwdEnt = InWarehouseDetail.Find(objL.Value <string>("Id"));
                                    iwdEnt.Remark = objL.Value <string>("Remark");
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SkinArray")))
                                    {
                                        iwdEnt.SkinArray = objL.Value <string>("SkinArray").ToString();
                                    }
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SeriesArray")))
                                    {
                                        iwdEnt.SeriesArray = objL.Value <string>("SeriesArray").ToString();
                                    }
                                    iwdEnt.DoUpdate();
                                }
                                else
                                {
                                    OtherInWarehouseDetail oiwdEnt = OtherInWarehouseDetail.Find(objL.Value <string>("Id"));
                                    oiwdEnt.Remark = objL.Value <string>("Remark");
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SkinArray")))
                                    {
                                        oiwdEnt.SkinArray = objL.Value <string>("SkinArray").ToString();
                                    }
                                    if (!string.IsNullOrEmpty(objL.Value <string>("SeriesArray")))
                                    {
                                        oiwdEnt.SeriesArray = objL.Value <string>("SeriesArray").ToString();
                                    }
                                    oiwdEnt.DoUpdate();
                                }
                            }
                            //修改库存
                            InStorage(iwddEnt.ProductId, iwddEnt.Quantity.Value, iwEnt.WarehouseId);
                        }
                    }
                }
                ProcessInWarehouse(iwEnt);
                if (iwEnt.InWarehouseType == "采购入库")    //处理采购单和采购单详细
                {
                    ProcessPurchaseOrderAndDetail(iwEnt);
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 更新库存
        /// </summary>
        /// <param name="childjson">出库单出库商品json</param>
        private void UpdateStockInfo(IList <string> strList, DeliveryOrder deorder)
        {
            string db       = ConfigurationManager.AppSettings["ExamineDB"];
            string strguids = "";

            Dictionary <string, object> dic = null;

            StockInfo stoinfo = null;

            for (int i = 0; i < strList.Count; i++)
            {
                dic = FromJson(strList[i]) as Dictionary <string, object>;

                if (dic != null)
                {
                    //记录日志begin
                    if (dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "")
                    {
                        StockLog slEnt = new StockLog();//创建库存变更日志
                        slEnt.InOrOutDetailId = dic["Id"] + "";
                        slEnt.InOrOutBillNo   = deorder.Number;
                        slEnt.OperateType     = "产品出库";
                        slEnt.WarehouseId     = deorder.WarehouseId;
                        slEnt.WarehouseName   = deorder.WarehouseName;
                        IList <StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, dic["ProductId"], StockInfo.Prop_WarehouseId, deorder.WarehouseId);
                        if (siEnts.Count > 0)
                        {
                            slEnt.StockQuantity = siEnts[0].StockQuantity;
                        }
                        slEnt.Quantity  = Convert.ToInt32(dic["SmCount"]);
                        slEnt.ProductId = dic["ProductId"] + "";
                        Product pEnt = Product.Find(dic["ProductId"]);
                        slEnt.ProductCode = pEnt.Code;
                        slEnt.ProductName = pEnt.Name;
                        slEnt.ProductIsbn = pEnt.Isbn;
                        slEnt.ProductPcn  = pEnt.Pcn;
                        slEnt.DoCreate();
                    }
                    //记录日志end

                    //更新唯一编号的状态
                    if (dic.ContainsKey("Guids") && dic["Guids"] + "" != "")
                    {
                        string guids = dic["Guids"] + "";
                        guids    = guids.Substring(0, guids.Length - 1);
                        strguids = "'" + guids.Replace(",", "','") + "'";

                        DataHelper.ExecSql("update " + db + "..Compressor set [state]='已出库',CustomerId='" + deorder.CId + "',DeliveryOrderId='" + deorder.Id + "' where SeriesNo in (" + strguids + ")");
                    }
                    //更新库存 OutCount
                    stoinfo = StockInfo.FindAllByProperties("ProductId", dic["ProductId"], "WarehouseId", deorder.WarehouseId).FirstOrDefault <StockInfo>();
                    if (stoinfo != null)
                    {
                        //SmCount 本次出库数量
                        stoinfo.StockQuantity -= (dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "" ? Convert.ToInt32(dic["SmCount"]) : 0);
                        stoinfo.DoUpdate();
                    }
                    else
                    {
                        stoinfo = new StockInfo
                        {
                            ProductCode   = dic["Code"] + "",
                            ProductId     = dic["ProductId"] + "",
                            ProductName   = dic["Name"] + "",
                            StockQuantity = -(dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "" ? Convert.ToInt32(dic["SmCount"]) : 0),
                            WarehouseId   = deorder.WarehouseId,
                            WarehouseName = deorder.WarehouseName
                        };
                        stoinfo.DoCreate();
                    }
                }
            }
        }