コード例 #1
0
        /// <summary>
        /// 收料通知
        /// </summary>
        /// <param name="plan">计划</param>
        /// <param name="planList">计划详细</param>
        /// <returns></returns>

        public ResponseData ReceiveGoodsPlan(Plan plan, List <PlanList> planList)
        {
            ResponseData response = new ResponseData();

            try
            {
                if (plan == null)
                {
                    response.Status   = false;
                    response.Describe = "计划单据对象为空!";
                    return(response);
                }
                if (planList == null)
                {
                    response.Status   = false;
                    response.Describe = "计划单据详单为空!";
                    return(response);
                }

                PlanMainModel planMainModel = bllPlan.GetModelByPlanCode(plan.PlanCode);
                if (planMainModel != null)
                {
                    bllPlan.DeleteByPlanCode(planMainModel.Plan_Code);
                }
                planMainModel         = new PlanMainModel();
                planMainModel.Plan_ID = Guid.NewGuid().ToString();

                planMainModel.Plan_Create_Time = DateTime.Now;
                planMainModel.Plan_Remark      = plan.Payee;
                planMainModel.Plan_Code        = plan.PlanCode;

                Plan_TypeModel planTypeModel = bllPlanType.GetModelByCode(plan.PlanType);

                if (planTypeModel == null)
                {
                    response.Status   = false;
                    response.Describe = "不存在[" + plan.PlanCode + "]类型计划!";
                    return(response);
                }

                planMainModel.Plan_Type_ID = planTypeModel.Plan_Type_ID;
                DateTime recDate       = DateTime.Now;
                bool     recDataStatus = DateTime.TryParse(plan.RecvDateTime, out recDate);
                if (recDataStatus == true)
                {
                    planMainModel.Plan_Bill_Time = recDate;
                }
                else
                {
                    response.Status   = false;
                    response.Describe = "收料时间格式错误!" + plan.RecvDateTime;
                    return(response);
                }

                planMainModel.Plan_From_User = plan.Settlement;
                planMainModel.Plan_Reserve1  = plan.SettlementGroup;
                planMainModel.Plan_From_Dept = plan.Supplyer;
                planMainModel.Plan_Status    = EnumPlanStatus.待执行.ToString();
                bllPlan.UpdatePlan(planMainModel);

                foreach (PlanList pl in planList)
                {
                    Plan_ListModel planListModel = new Plan_ListModel();
                    planListModel.Plan_ID      = planMainModel.Plan_ID;
                    planListModel.Plan_List_ID = Guid.NewGuid().ToString();
                    planListModel.Plan_List_Ordered_Quantity  = "0";
                    planListModel.Plan_List_Quantity          = pl.RecvNum;
                    planListModel.Plan_List_Finished_Quantity = "0";
                    planListModel.Plan_List_Remark            = pl.NeedCheck.ToString();

                    GoodsModel goods = bllGoods.GetModelByCode(pl.GoodsCode);
                    if (goods == null)
                    {
                        response.Status   = false;
                        response.Describe = "不存在[" + pl.GoodsCode + "]物料!";
                        return(response);
                    }

                    planListModel.Goods_ID           = goods.Goods_ID;
                    planListModel.Plan_List_Resever1 = pl.NeedGroup + "," + pl.RecvUnit + "," + pl.StockUnit;
                    planListModel.Plan_List_Resever2 = pl.Sum + "," + pl.UnitPrice + "," + pl.ValuationUnit;

                    bllPlanList.Add(planListModel);
                }


                response.Status   = true;
                response.Describe = "收料成功!";
                return(response);
            }
            catch (Exception ex)
            {
                response.Status   = false;
                response.Describe = "收料失败:" + ex.Message;
                return(response);
            }
        }