Пример #1
0
        private void ItemBtnReturn_Click(object sender, EventArgs e)
        {
            if (_bill == null || _bill.单据编号 == null)
            {
                MessageHelper.ShowInfo("请选择单据");
                return;
            }

            if (_bill.状态 != (int)BillState.Finished)
            {
                MessageHelper.ShowInfo("选中单据状态错误,无法执行");
                return;
            }
            var details = SpareOutController.GetList(_db, _bill.单据编号);

            try
            {
                string strInfo = BillHandler.HandleMaterialReturn(_db, _bill.VWToBill(GlobalVar.Oper.DeptCode), details);
                if (strInfo != "OK")
                {
                    MessageHelper.ShowError(strInfo);
                }
                else
                {
                    MessageHelper.ShowInfo("生成领用还回单成功");
                    EntitiesFactory.SaveDb(_db);
                }
            }
            catch (Exception ex)
            {
                MessageHelper.ShowError(ex.ToString());
                throw;
            }
        }
Пример #2
0
 private void BtnDeliver_Click(object sender, EventArgs e)
 {
     if (_bill == null || _bill.单据编号 == null)
     {
         MessageHelper.ShowInfo("请选择单据");
         return;
     }
     if (MessageHelper.ShowQuestion("确定要执行选定的领用单?") == DialogResult.Yes)
     {
         SpareEntities db      = EntitiesFactory.CreateSpareInstance();
         var           outlist = SpareOutController.GetList(db, _bill.单据编号);
         foreach (var spout in outlist)
         {
             if (string.IsNullOrEmpty(spout.TakeUser))
             {
                 MessageHelper.ShowError("领用详细中的领用人信息不能为空!");
                 return;
             }
         }
         BillHandler.FinishMaterialOut(db, _bill.VWToBill(GlobalVar.Oper.DeptCode), outlist);
         EntitiesFactory.SaveDb(db);
         NotifyController.AddStockSafeQty(db, GlobalVar.Oper.OperName);
         MessageHelper.ShowInfo("保存成功!");
     }
 }
Пример #3
0
 /// <summary>
 ///     执行【领用申请单】,生成【领用单】
 /// </summary>
 /// <param name="db"></param>
 /// <param name="billAsk">申请单</param>
 /// <param name="details">申请明细</param>
 /// <returns></returns>
 public static string HandleMaterialAsk(SpareEntities db, TB_BILL billAsk, List <TB_ASK> details)
 {
     try
     {
         //校验【领用单】状态是否为批准
         if (billAsk.State != (int)BillState.Approve)
         {
             return("申请单状态错误,不应为:" + billAsk.State);
         }
         var partPickList = new List <TB_OUT>();
         foreach (var detail in details)
         {
             var pList = SpareOutController.GetList(db, detail);
             if (pList.Count == 0 || pList.Sum(p => p.OutQty) < detail.Qty)
             {
                 return("库存不足,生成领用单失败!");
             }
             partPickList.AddRange(pList);
         }
         var billPick = new TB_BILL
         {
             BillNum       = "",
             SourceBillNum = billAsk.BillNum,
             BillType      = (int)BillType.MaterialDeliver,
             SubBillType   = (int)billAsk.SubBillType,
             BillTime      = DateTime.Now,
             OperName      = billAsk.OperName,
             SplyId        = billAsk.SplyId,
             State         = (int)BillState.New,
             Remark        = "",
         };
         SetBillNum(billPick);
         partPickList.ForEach(p => p.BillNum = billPick.BillNum);
         BillController.AddOrUpdate(db, billPick);
         SpareOutController.AddList(db, partPickList);
         BillController.UpdateState(db, billAsk, BillState.Handling); //更新【叫料单】状态为:执行中
         NotifyController.AddNotify(db, billPick.OperName, NotifyType.MaterialOut, billAsk.BillNum, "");
         return("OK");
     }
     catch (Exception ex)
     {
         BillController.UpdateState(db, billAsk, BillState.Failed);
         billAsk.Remark = ex.ToString();
         return(ex.ToString());
     }
 }