Пример #1
0
        /// <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);
            }
        }
Пример #2
0
        public ABi_GR(YB_GR_Report_Swap po)
        {
            ABi_PO abi_po = new ABi_PO(po.Ebeln, po.Ebelp);
            if (abi_po.IsNULL() == false)
            {
                this.aBi_PO_ID = abi_po.ABi_PO_ID;
            }
            else
            {
                utils.WriteErrorLog("YB_PO_Report_Swap编号:" + po.Ebeln + "订单不存在" + po.Ebelp);
                return;
            }
            if (!String.IsNullOrEmpty(po.werks))
            {
                var plant = new ABi_Plant(po.werks);
                if (plant.ABi_Plant_ID > 0)
                {
                    this.ABi_Plant_ID = plant.ABi_Plant_ID;
                }
                else
                {
                    plant.SaveABi_Plant();
                    plant = new ABi_Plant(po.werks);
                    if (plant.ABi_Plant_ID > 0)
                    {
                        this.ABi_Plant_ID = plant.ABi_Plant_ID;
                    }
                }
            }
            else
                return;
            this.aBi_Company_ID = abi_po.ABi_Company_ID;
            this.aBi_Vendor_ID = abi_po.ABi_Vendor_ID;
            this.gRNumber = po.Belnr;
            this.gRItemNumber = po.Buzei;
            this.gRYear=Convert.ToDateTime(po.Gjahr+"-01-01 00:00:00");
            try
            {
                this.gRDate = Convert.ToDateTime(po.Budat);
            }
            catch
            {
                this.gRDate = DateTime.Now ;
            }
            this.quantity = po.Menge;//收获数量老数据库中是double类型
            this.quantityUnit = po.Meins;
            if (abi_po.IsNULL() == false)//统一计量单位
            {
                this.quantity = this.GetQuantityUnit(this.quantity, this.quantityUnit, abi_po);
                if (this.quantity != -65535)//如果是有效的就统一
                {
                    this.quantityUnit = abi_po.QuantityUnit;
                }
                else
                {
                    this.quantity = po.Menge;
                    this.quantityUnit = po.Meins;
                }
            }
            this.gRAmount = po.Dmbtr - po.Bnbtr;
            this.currency = po.Waers;
            try
            {
                this.refGRYear = Convert.ToDateTime(po.Gjahr+"-01-01 00:00:00");
            }
            catch
            {
            }
            this.refGRNumber = po.Lfbnr;
            this.refGRItemNumber = po.Lfpos;

            this.dateCreated=DateTime.Now;
            this.dateModified=DateTime.Now;
            this.moveType = po.Bwart;

            if (this.moveType == "161" && (String.IsNullOrEmpty(refGRNumber) || String.IsNullOrEmpty(refGRItemNumber)))
            {
                refGRNumber = GRNumber;
                RefGRItemNumber = GRItemNumber;
            }

            if (this.moveType == "102" || this.moveType == "106" || this.moveType == "122" || this.moveType == "161")
            {
                this.quantity = this.quantity * -1;//收获数量老数据库中是double类型
                this.GRAmount *= -1;
            }
        }
Пример #3
0
 public double GetQuantityUnit(double value, string quantityUnit, ABi_PO abi_po)
 {
     string selStr = "select * from ABi_Unit where UnitName='" + quantityUnit + "'";
     DataTable dt = this.GetDataTable(selStr);
     if (dt != null && dt.Rows.Count > 0)
     {
         DataRow dr=dt.Rows[0];
         value = value * Convert.ToInt32(dr["CurUnitRate"]) / Convert.ToInt32(dr["StandardUnitRate"]);
         selStr = "select * from ABi_Unit where UnitName='" + abi_po.QuantityUnit + "'";
         dt = this.GetDataTable(selStr);
         if (dt != null && dt.Rows.Count > 0)
         {
             dr = dt.Rows[0];
             value = value * Convert.ToInt32(dr["StandardUnitRate"]) / Convert.ToInt32(dr["CurUnitRate"]);
             return value;
         }
         else
             return -65535;
     }
     else
         return -65535;
 }