示例#1
0
        private void BtnHandle_Click(object sender, EventArgs e)
        {
            if (_bill == null || _bill.单据编号 == null)
            {
                MessageHelper.ShowInfo("请选择单据");
                return;
            }

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

            try
            {
                string strInfo = BillHandler.HandleMaterialAsk(_db, _bill.VWToBill(GlobalVar.Oper.DeptCode), details);
                if (strInfo != "OK")
                {
                    MessageHelper.ShowError(strInfo);
                }
                else
                {
                    EntitiesFactory.SaveDb(_db);
                    MessageHelper.ShowInfo("生成领用单成功");
                }
            }
            catch (Exception ex)
            {
                MessageHelper.ShowError(ex.ToString());
                throw;
            }
        }
示例#2
0
 /// <summary>
 ///     添加【叫料单】
 /// </summary>
 /// <param name="db"></param>
 /// <param name="bill">叫料单</param>
 /// <param name="details">叫料明细</param>
 /// <returns></returns>
 public static void AddMaterialAsk(SpareEntities db, TB_BILL bill, List <TB_ASK> details)
 {
     if (bill.BillNum == null)
     {
         SetBillNum(bill);                                                                              //设置单据编号
         details.ForEach(p => p.BillNum = bill.BillNum);                                                //设置明细编号
         NotifyController.AddNotify(db, bill.OperName, NotifyType.MaterialAskUpdate, bill.BillNum, ""); //添加【叫料提醒单】
     }
     else
     {
         NotifyController.AddNotify(db, bill.OperName, NotifyType.MaterialAsk, bill.BillNum, ""); //添加【叫料提醒单】
     }
     BillController.AddOrUpdate(db, bill);                                                        //添加【生产叫料单】单据
     foreach (var detail in details)
     {
         SpareAskController.AddOrUpdate(db, detail);//添加或修改【生产叫料单】明细
     }
 }