日期:2014-05-17  浏览次数:21107 次

谁能优化一下下面的代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SysSap.SAP.CONN;
using System.Xml.Linq;
using Model.baseCls.db;

namespace SysSap.SAP.Master
{
    public  class MasterOITM
    {

        public static string OITM(string ItemCode)
        {
            try
            {
                //查询物料主数据的信息
                SAPbobsCOM.Items oItems, iItems;
                oItems = (SAPbobsCOM.Items)DIConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
                iItems = (SAPbobsCOM.Items)DIConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
                int lRetCode;
                DIConn.oCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode;
                SqlHelper obj_SqlHelper = new SqlHelper();
                string estrSql = "Select ItemCode  From SAP_OITM A LEFT JOIN SAP_OITB B ON A.ItmsGrpCod=B.Grpid Where ItemCode ='" + ItemCode + "'";
                string eStr = obj_SqlHelper.runCol(estrSql);
                if (eStr != "")
                {
                    System.Data.DataTable Items, ItemsuserField, Items_Price, ItemWare, ItemWareuserField, ItemCardCode;//定义数据表
                    SAPbobsCOM.Recordset oRecordset;
                    oRecordset = (SAPbobsCOM.Recordset)DIConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                    string userField = @"Select A.name From   Syscolumns   A,Sysobjects   B 
                                   Where B.Name= 'SAP_OITM' And A.id=B.id And LEFT(a.name,2)='U_'";
          &n