public bool AuditingOutStockOrder(string OutStockID) { bool flag = false; try { VOutStock stock = new VOutStock(); List <VOutStockDetail> list = new List <VOutStockDetail>(); ProductsStockDAL kdal = new ProductsStockDAL(); stock = new OutStockDAL().getByID(OutStockID); list = new OutStockDetailDAL().getListByOutID(OutStockID); for (int i = 0; i < list.Count; i++) { ProductsStock stock2; OutStockDetail detail = list[i]; if (kdal.isHaveEitity(stock.HouseDetailID, detail.ProductsID)) { stock2 = new ProductsStock(); stock2.HouseDetailID = stock.HouseDetailID; stock2.ProductsID = detail.ProductsID; stock2.Num = detail.Quantity; kdal.updateCutNum(stock2); } else { stock2 = new ProductsStock(); stock2.HouseDetailID = stock.HouseDetailID; stock2.ProductsID = detail.ProductsID; stock2.Num = -detail.Quantity; kdal.insertNewEitity(stock2); } } flag = true; } catch { } return(flag); }
/// <summary> /// 生成新出库单号 /// </summary> /// <returns></returns> public string GetNewBillNO() { string maxNo = new OutStockDAL().GetMaxBillNO(); string newNo = DateTime.Now.ToString("yyyyMMdd"); if (string.IsNullOrEmpty(maxNo) || maxNo.Length < 12) { newNo = newNo + "0001"; } else { if (newNo == maxNo.Substring(0, 8)) { newNo = (double.Parse(maxNo) + 1).ToString(); } else { newNo = newNo + "0001"; } } return(newNo); }
/// <summary> /// 出库 /// </summary> /// <param name="bill">出库单</param> /// <returns></returns> public string OutStorage(OutStockBill bill) { string result = ""; bill.ID = Guid.NewGuid().ToString(); bill.CREATEUSER = this.LoginUser.UserID; bill.CREATETIME = DateTime.Now; bill.UPDATEUSER = this.LoginUser.UserID; bill.UPDATETIME = bill.CREATETIME; //设置明细 int seq = 1; foreach (OutStockDetail detail in bill.Details) { detail.ID = Guid.NewGuid().ToString("N"); detail.Seq = seq; seq++; detail.BillID = bill.ID; detail.CREATEUSER = bill.CREATEUSER; detail.CREATETIME = bill.CREATETIME; detail.UPDATEUSER = bill.UPDATEUSER; detail.UPDATETIME = bill.UPDATETIME; } StockDAL stockDal = new StockDAL(); OutStockDAL outDal = new OutStockDAL(); using (IDataSession session = AppDataFactory.CreateMainSession()) { try { stockDal.Session = session; outDal.Session = session; foreach (OutStockDetail detail in bill.Details) { WHMatAmount outStock = new WHMatAmount(); outStock.Warehouse = bill.Warehouse; outStock.SaveSite = detail.SaveSite; outStock.MatBarCode = detail.IDCode; outStock.MatID = detail.MatID; outStock.ProductAmount = detail.OutAmount; outStock.ProductPrice = detail.OutPrice; outStock.ProductSum = detail.OutSum; outStock.Unit = detail.UnitCode; outStock.MainAmount = detail.MainUnitAmount; result = stockDal.OutStock(outStock); if (result != "") { break; } } if (result != "") { session.RollbackTs(); return(result); } outDal.Insert(bill); session.CommitTs(); } catch (Exception ex) { session.RollbackTs(); throw ex; } } return(result); }