/// <summary>
        /// 导入Abi_PO
        /// </summary>
        /// <returns></returns>
        public void SaveABi_Po()
        {
            try
            {
                utils.WriteLog("开始导入abi_po");
                YB_PO_Report_Swap yb_po_report_swap = new YB_PO_Report_Swap();
                List<YB_PO_Report_Swap> list = yb_po_report_swap.GetYB_PO_Report_SwapList();
                if (list != null && list.Count > 0)
                {
                    utils.WriteLog("YB_PO_Report_Swap总数" + list.Count);
                    foreach (YB_PO_Report_Swap po in list)
                    {
                        utils.WriteLog("YB_PO_Report_Swap编号" + po.ID);
                        ABi_PO abi_po = new ABi_PO(po);

                        if (abi_po.IsNULL() == false)//如果不为空
                        {
                            if (abi_po.Save())//如果保存成功
                            {
                                utils.WriteLog("YB_PO_Report_Swap编号" + po.ID + "保存成功");
                                po.Status = "1";
                                po.SaveStatus();
                            }
                            else
                                utils.WriteErrorLog("YB_PO_Report_Swap编号" + po.ID + "保存失败");
                        }
                        else
                        {
                            utils.WriteErrorLog("YB_PO_Report_Swap编号" + po.ID + "生成abi_po失败");
                        }
                    }
                }
                utils.WriteLog("导入abi_po完成");
            }
            catch(Exception error)
            {
                utils.WriteErrorLog("导入abi_po发生异常"+error.Message);
            }
        }
Esempio n. 2
0
        public ABi_PO(YB_PO_Report_Swap po)
        {
            if (po.Lifnr.Length >= 6)
                po.Lifnr = po.Lifnr.Substring(po.Lifnr.Length-6,6);
            ABi_Vendor abi_wendor = new ABi_Vendor(po.Lifnr);//去abi_vendor找,如果没找到,等待下一轮处理
            if (string.IsNullOrEmpty(abi_wendor.VendorCode) == false)
            {
                this.aBi_Vendor_ID = abi_wendor.ABi_Vendor_ID;
            }
            else
            {
                utils.WriteLog(String.Format("YB_PO_Report_Swap编号:{0} 未找到供应商编号: {1}", po.Ebeln, po.Lifnr));
                return;
            }
            //根据Code在ABi表中找
            ABi_Company abi_company=new ABi_Company(po.Bukrs);
            CompanyCode = po.Bukrs;
            if (abi_company.ABi_Company_ID == 0)//如果没找到,插入一条
            {
                YB_CompanyCode yb = new YB_CompanyCode(po.Bukrs);
                abi_company.CompanyCode = yb.Companycode;
                abi_company.CompanyName = yb.Name;
                abi_company.SaveABi_Company();//插入一条
                abi_company = new ABi_Company(po.Bukrs);
                this.aBi_Company_ID = abi_company.ABi_Company_ID;
            }
            else//如果找到直接赋值
            {
                this.aBi_Company_ID = abi_company.ABi_Company_ID;
            }
            //查找bai_plant_id
            ABi_Plant abi_plant = new ABi_Plant(po.Werks);
            //如果在abi_plant查不到 则在abi_plant里面加一条数据
            if (abi_plant.ABi_Plant_ID == 0)
            {
                YB_Plant_Masterdata yb_plant = new YB_Plant_Masterdata(po.Werks);
                if (yb_plant.IsNULL() == false)
                {
                    abi_plant = new ABi_Plant();
                    abi_plant.PlantCode = yb_plant.Plant;
                    abi_plant.PlantName = yb_plant.Plant_name;
                    abi_plant.SaveABi_Plant();
                    this.aBi_Plant_ID = new ABi_Plant(po.Werks).ABi_Plant_ID;
                }
                else
                {
                    new ABi_Plant(po.Werks).SaveABi_Plant();
                    this.aBi_Plant_ID = new ABi_Plant(po.Werks).ABi_Plant_ID;
                }
            }
            else
                this.aBi_Plant_ID = abi_plant.ABi_Plant_ID;
            this.pONumber = po.Ebeln;
            this.pOItemNumber = po.Ebelp;
            this.pOCreator = po.Name_text;
            this.pOCreateDate = po.Aedat;
            this.paymentTerm = po.Zterm;
            this.meterialNumber = String.IsNullOrEmpty(po.Matnr) ? "" : long.Parse(po.Matnr).ToString();
            this.meterialName = po.Txz01;
            this.taxCode = po.Mwskz;
            this.isReturn = (!String.IsNullOrEmpty(po.retpo) && po.retpo == "X") ? 1 : 0 ;//退的订单,PO数据库中无该字段
            this.quantity = (isReturn == 0) ? po.Menge : -po.Menge;
            this.quantityUnit = po.Meins;
            this.netPrice = po.Netpr;
            this.pirceUnit = po.Peinh;
            this.currency = po.Waers;
            this.amount = (isReturn == 0) ? po.Netwr : -po.Netwr;
            this.deliveryDate = po.Eindt;
            this.purchaseGroup = po.Ekgrp;
            this.dateCreated =DateTime.Now;
            this.dateModified=DateTime.Now;
            switch (po.Loekz)
            {
                case "001": this.deletion = "0"; break;
                case "002": this.deletion = "0"; break;
                case "003": this.deletion = "1"; break;
            }

            //this.movieType=
            this.deliverCompleted = po.Elikz;
            this.POStatus = po.bsart;
        }