示例#1
0
        /// <summary>
        /// 生成PO变更单
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="type">0\不制作变更单;1\只变更时间;2\其他类型PO变更单;</param>
        /// <returns></returns>
        public UFIDA.U9.PM.POChange.POModifyData GetPOModify(DataRow dr, ref string type)
        {
            type = "0";
            UFIDA.U9.PM.POChange.POModifyData poModify = new UFIDA.U9.PM.POChange.POModifyData();
            #region 变更数据
            //poModify.POShiplineModify = new List<UFIDA.U9.PM.POChange.POShiplineModifyData>();
            //poModify.POLineModify = new List<UFIDA.U9.PM.POChange.POLineModifyData>();
            //poModify.POAddressModify = new List<UFIDA.U9.PM.POChange.POAddressModifyData>();
            //poModify.POContactModify = new List<UFIDA.U9.PM.POChange.POContactModifyData>();
            //poModify.PODiscountModify = new List<UFIDA.U9.PM.POChange.PODiscountModifyData>();
            //poModify.POFeeModify = new List<UFIDA.U9.PM.POChange.POFeeModifyData>();
            //poModify.POMenoModify = new List<UFIDA.U9.PM.POChange.POMenoModifyData>();
            //poModify.POTaxModify = new List<UFIDA.U9.PM.POChange.POTaxModifyData>();
            #endregion
            poModify.ActionType = 0;//更新类型,默认值
            poModify.ApprovedBy = "";
            //poModify.ApprovedOn = DateTime.Now;
            poModify.CancelApprovedBy = "";
            //poModify.CancelApprovedOn = DateTime.Now;
            poModify.Demo         = "系统自动生成单据";       //备注
            poModify.DocumentType = 1001708070112532; //单据类型
            //poModify.DocumentType_SKey
            poModify.IsModifyVersion = true;          //更新订单版本
            poModify.ModifyIndex     = Convert.ToInt32(dr["POModifiedTimes"].ToString()) + 1;
            poModify.ModifyReason    = 0;
            poModify.PO      = Convert.ToInt64(dr["POID"]);
            poModify.PODocNo = dr["PODocNo"].ToString();
            //poModify.PO_SKey
            poModify.Status          = 0;//开立
            poModify.WFCurrentState  = -1;
            poModify.WFOriginalState = -1;
            //采购订单计划行变更表
            poModify.POShiplineModify = new List <UFIDA.U9.PM.POChange.POShiplineModifyData>();
            //poModify.POShiplineModify.Add(GetPOShiplineModifyData(dr));
            //POModifyLine PO变更单单行
            poModify.POModifyLine = new List <UFIDA.U9.PM.POChange.POModifyLineData>();



            int      SupplierConfirmQtyTU = Convert.ToInt32(Convert.ToDouble(dr["SupplierConfirmQtyTU"].ToString()));
            int      SMQty          = Convert.ToInt32(Convert.ToDouble(dr["SMQty"].ToString()));
            int      RescheduleQty  = Convert.ToInt32(Convert.ToDouble(dr["RescheduleQty"].ToString()));
            DateTime OriginalDate   = Convert.ToDateTime(dr["OriginalDate"].ToString());
            DateTime RescheduleDate = Convert.ToDateTime(dr["RescheduleDate"].ToString());
            if (SupplierConfirmQtyTU == SMQty)          //库存主单位数量=采购确认数量
            {
                if (SMQty == RescheduleQty)             //只修改日期
                {
                    if (OriginalDate != RescheduleDate) //修改日期
                    {
                        UFIDA.U9.PM.POChange.POModifyLineData pomodifyLine = new UFIDA.U9.PM.POChange.POModifyLineData();
                        pomodifyLine          = GetPOModifyLineData(dr, 2, "DeliveryDate", "要求交货日", "System.DateTime", "OriginalDate", "RescheduleDate");
                        pomodifyLine.POModify = poModify;
                        poModify.POModifyLine.Add(pomodifyLine);

                        UFIDA.U9.PM.POChange.POModifyLineData pomodifyLine2 = new UFIDA.U9.PM.POChange.POModifyLineData();
                        pomodifyLine2          = GetPOModifyLineData(dr, 2, "NeedPODate", "应下订单日", "System.DateTime", "OriginalDate", "RescheduleDate");
                        pomodifyLine2.POModify = poModify;
                        poModify.POModifyLine.Add(pomodifyLine2);

                        UFIDA.U9.PM.POChange.POModifyLineData pomodifyLine3 = new UFIDA.U9.PM.POChange.POModifyLineData();
                        pomodifyLine3          = GetPOModifyLineData(dr, 2, "PlanArriveDate", "计划到货日", "System.DateTime", "OriginalDate", "RescheduleDate");
                        pomodifyLine3.POModify = poModify;
                        poModify.POModifyLine.Add(pomodifyLine3);
                        type = "1";
                    }
                    else
                    {
                        type = "0";
                    }
                }
                else if (SMQty > RescheduleQty)
                {
                    if (OriginalDate == RescheduleDate)//直接改小数量
                    {
                    }
                    else//原始行修改,拆行,拆行的数量=重排数量,时间=重排时间
                    {
                    }
                }
                else//SMQty<RescheduleQty
                {
                    if (OriginalDate == RescheduleDate)//直接修改数量
                    {
                    }
                    else//直接修改数量和时间,不需要拆行
                    {
                    }
                }
            }
            else//库存主单位数量!=采购确认数量,需要拆行
            {
                if (SMQty == RescheduleQty)
                {
                    if (OriginalDate != RescheduleDate)//拆行,原始行做修改,新拆一行
                    {
                    }
                    else
                    {
                        type = "0";
                    }
                }
                else if (SMQty > RescheduleQty)
                {
                    if (OriginalDate != RescheduleDate)//修改数量和时间
                    {
                    }
                    else//只修改数量
                    {
                    }
                }
            }
            return(poModify);
        }
示例#2
0
        /// <summary>
        /// 创建变更单按钮(弃用)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnPOModify_Clickx(object sender, EventArgs e)
        {
            List <UFIDA.U9.PM.POChange.POModifyData> liPOModifyDate = new List <UFIDA.U9.PM.POChange.POModifyData>(); //只变更日期的变更单
            List <UFIDA.U9.PM.POChange.POModifyData> liPOModify     = new List <UFIDA.U9.PM.POChange.POModifyData>(); //变更数量的变更单
            List <long> liAutoApprove = new List <long>();                                                            //新生成的变更单ID集合(需要自动审核的)
            //MRP重排建议与对应的PO集合
            DataSet       ds = new DataSet();
            DataTable     dt = new DataTable();
            DataParamList dp = new DataParamList();

            DataAccessor.RunSP("sp_Auctus_BE_GetReschedule", dp, out ds);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string type = "0";//0只改时间和取消操作

                UFIDA.U9.PM.POChange.POModifyData poModify = new UFIDA.U9.PM.POChange.POModifyData();
                //填充POModify实体
                if (dr["RType"].ToString() == "1")//更新操作
                {
                    poModify = GetPOModify(dr, ref type);
                    if (type == "1")
                    {
                        liPOModifyDate.Add(poModify);
                    }
                    else if (type == "2")
                    {
                        liPOModify.Add(poModify);
                    }
                }
                else if (dr["RType"].ToString() == "2")//TODO:取消操作,调用“关闭采购订单计划行服务”
                {
                }
            }
            if (liPOModifyDate.Count > 0)
            {
                for (int i = 0; i < liPOModifyDate.Count - 1; i++)
                {
                    for (int j = i + 1; j < liPOModifyDate.Count; j++)
                    {
                        if (liPOModifyDate[i].PODocNo == liPOModifyDate[j].PODocNo)
                        {
                            List <UFIDA.U9.PM.POChange.POModifyLineData>     ll  = new List <UFIDA.U9.PM.POChange.POModifyLineData>();
                            List <UFIDA.U9.PM.POChange.POShiplineModifyData> ll2 = new List <UFIDA.U9.PM.POChange.POShiplineModifyData>();
                            foreach (UFIDA.U9.PM.POChange.POModifyLineData item in liPOModifyDate[j].POModifyLine)
                            {
                                item.POModify = liPOModifyDate[i];
                                ll.Add(item);
                            }
                            foreach (UFIDA.U9.PM.POChange.POShiplineModifyData item in liPOModifyDate[j].POShiplineModify)
                            {
                                item.POModify = liPOModifyDate[i];
                                ll2.Add(item);
                            }
                            //liPOModifyDate[i].POModifyLine.AddRange(liPOModifyDate[j].POModifyLine);
                            liPOModifyDate[i].POModifyLine.AddRange(ll);
                            liPOModifyDate[i].POShiplineModify.AddRange(ll2);
                            liPOModifyDate.RemoveAt(j);
                            j--;
                        }
                    }
                }
                foreach (UFIDA.U9.PM.POChange.POModifyData item in liPOModifyDate)
                {
                    PurchaseOrderChangeListBP.Proxy.SavePOModifyBPProxy bpProxy = new PurchaseOrderChangeListBP.Proxy.SavePOModifyBPProxy();
                    bpProxy.POModify = item;
                    long i = bpProxy.Do();
                    liAutoApprove.Add(i);
                }
                #region 自动审审核采购变更单
                if (liAutoApprove.Count > 0)
                {
                    List <PurchaseOrderChangeListBP.POModifyDTOData> li  = new List <PurchaseOrderChangeListBP.POModifyDTOData>();
                    PurchaseOrderChangeListBP.POModifyDTOData        dto = new PurchaseOrderChangeListBP.POModifyDTOData();
                    dto.IDKey            = liAutoApprove[0];
                    dto.IDKey_SKey       = new BusinessEntity.EntityKey(liAutoApprove[0], "UFIDA.U9.PM.POChange.POModify");
                    liPOModifyDate[0].ID = liAutoApprove[0];
                    dto.POModify         = liPOModifyDate[0];
                    //UFIDA.U9.PM.POChange.POModifyData data = new UFIDA.U9.PM.POChange.POModifyData();



                    li.Add(dto);

                    //PurchaseOrderChangeListBP.Proxy.POModifySubmitBPProxy submitBpProxy = new PurchaseOrderChangeListBP.Proxy.POModifySubmitBPProxy();
                    //submitBpProxy.POModifyDTOs = li;
                    //submitBpProxy.Do();


                    //PurchaseOrderChangeListBP.Proxy.POModifyApproveBPProxy approveBpProxy = new PurchaseOrderChangeListBP.Proxy.POModifyApproveBPProxy();
                    //approveBpProxy.POModifyDTOs = li;
                    //approveBpProxy.Do();
                }

                #endregion
            }
            //TODO:数量变更单据
            //if (liPOModify.Count > 0)
            //{
            //    foreach (UFIDA.U9.PM.POChange.POModifyData item in liPOModifyDate)
            //    {
            //        PurchaseOrderChangeListBP.Proxy.SavePOModifyBPProxy bpProxy = new PurchaseOrderChangeListBP.Proxy.SavePOModifyBPProxy();
            //        bpProxy.POModify = item;
            //        bpProxy.Do();
            //    }
            //}
        }