コード例 #1
0
ファイル: ClsDataLoadZWKC.cs プロジェクト: zpjune/WZBDH
        public bool SAPLoadData(ClsSAPDataParameter p_para)
        {
            bool Result = true;

            m_Conn = ClsUtility.GetConn();
            DataTable dtSWKC = new DataTable();

            try
            {
                string stedate = p_para.Sap_AEDAT.Substring(0, 6);
                //是第一次转换,先删除操作 ,再insert
                //  插入CONVERT_ZWKC表模型
                string strSqlEkko = @" begin delete from CONVERT_ZWKC; INSERT INTO  CONVERT_ZWKC (BWKEY,BWKEY_NAME,MATNR,SALK3,DLCODE,DLNAME,ZLCODE,ZLNAME,XLCODE,XLNAME,MATKL,PMNAME,LBKUM,DANJIA,DLDATE)
                                    SELECT   A.BWKEY,D.DW_NAME,A.MATNR,A.SALK3,C.DLCODE,C.DLNAME,C.ZLCODE,C.ZLNAME,C.XLCODE,C.XLNAME,B.MATKL,C.PMNAME,A.LBKUM,A.SALK3/A.LBKUM,'" + DateTime.Now.ToString("yyyyMMdd") + "'";
                strSqlEkko += @" FROM MBEW A 
                                    JOIN MARA B ON A.MATNR=B.MATNR
                                    JOIN WZ_WLZ C ON C.PMCODE=B.MATKL
                                    JOIN WZ_DW D ON D.DW_CODE=A.BWKEY 
                                    where A.SALK3>0
                                     ; commit;end ;";
                Result      = m_Conn.ExecuteSql(strSqlEkko);
            }
            catch (Exception exception)
            {
                Result = false;
                ClsErrorLogInfo.WriteSapLog("1", "CONVERT_ZWKC", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_ZWKC表过程中发生异常:\t\n" + exception);
                return(Result);
            }
            return(Result);
        }
コード例 #2
0
ファイル: ClsDataLoadBAOBIAO.cs プロジェクト: zpjune/WZBDH
        public static void SAPLoadData(ClsSAPDataParameter p_para)
        {
            bool   Result = true;
            string dldate = p_para.Sap_AEDAT;

            m_Conn = ClsUtility.GetConn();
            string sqlDelete = "begin DELETE FROM CONVERT_SWKCDETAILCKJE;commit; end;";

            if (m_Conn.ExecuteSql(sqlDelete))
            {
                string sql = "BEGIN  INSERT INTO CONVERT_SWKCDETAILCKJE(WERKS,WERKS_NAME,LGORT,MATNR,GESME,ZCKTZD,ZITEM,DLNAME,PMNAME,DLDATE,CKJE) ";
                sql   += "select A.WERKS,D.DW_NAME,A.LGORT,A.MATNR,A.ZFHSL,A.ZCKTZD,A.ZCITEM,C.DLNAME,C.PMNAME,'" + DateTime.Now.ToString("yyyyMMdd") + "',ROUND(E.SALK3/LBKUM*A.ZFHSL,2)";
                sql   += @" from  ZC10MMDG078 A 
                    JOIN WZ_DW D ON A.WERKS = D.DW_CODE
                    JOIN MBEW E ON E.BWKEY = A.WERKS AND E.MATNR = A.MATNR AND E.SALK3 > 0
                    JOIN WZ_WLZ C ON C.PMCODE = A.MATKL
                    WHERE A.ZSTATUS = '03'; COMMIT; END ;";
                Result = m_Conn.ExecuteSql(sql);
                if (Result)
                {
                    ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKCDETAILCKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKCDETAILCKJE表成功");
                }
                else
                {
                    ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKCDETAILCKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKCDETAILCKJE表失败");
                }
            }
            else
            {
                ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKCDETAILCKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "删除CONVERT_SWKCDETAILCKJE表失败");
            }
        }
コード例 #3
0
ファイル: ClsDataLoadRKJE.cs プロジェクト: zpjune/WZBDH
        public bool SAPLoadData(ClsSAPDataParameter p_para)
        {
            bool Result = true;

            m_Conn = ClsUtility.GetConn();
            string sqldelete = "begin delete from CONVERT_RKJE ;COMMIT; END;";

            try
            {
                Result = m_Conn.ExecuteSql(sqldelete);
            }
            catch (Exception ex)
            {
                ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "模型转换-删除CONVERT_RKJE表发生异常:" + ex.Message);
                return(false);
            }
            if (Result)
            {
                try
                {
                    ///根据入库单和凭证查询入库金额
                    string sql = "begin INSERT INTO CONVERT_RKJE(WERKS,WERKS_NAME,LGORT,LGORT_NAME,ZDHTZD,ZITEM,MBLNR,ZEILE,JE,BUDAT_MKPF,MENGE,DKCODE,MEINS,DLDATE)";
                    sql += "  SELECT A.WERKS, C.DW_NAME ,A.LGORT, D.KCDD_NAME,A.ZDHTZD,A.ZITEM,A.MBLNR, A.ZEILE,B.DMBTR,B.BUDAT_MKPF,B.MENGE,D.CKH,F.JBJLDW,'" + DateTime.Now.ToString("yyyyMMdd") + "'";
                    sql += "  FROM ZC10MMDG072 A";
                    sql += "  JOIN MSEG B ON A.MBLNR = B.MBLNR AND A.ZEILE = B.ZEILE";//凭证号和项目号
                    sql += "  JOIN WZ_DW C ON A.WERKS = C.DW_CODE";
                    sql += "  JOIN WZ_KCDD D ON A.WERKS = D.DWCODE AND A.LGORT = D.KCDD_CODE " +
                           " JOIN MARA E ON A.MATNR=E.MATNR  JOIN WZ_WLZ F ON F.PMCODE = E.MATKL " +
                           " ; commit; end ; ";
                    Result = m_Conn.ExecuteSql(sql);
                    if (Result)
                    {
                        ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "模型转换-插入CONVERT_RKJE表成功");
                    }
                    else
                    {
                        ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "模型转换-插入CONVERT_RKJE表失败");
                    }
                }
                catch (Exception ex)
                {
                    ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", p_para.Sap_AEDAT, "模型转换-插入CONVERT_RKJE表发生异常:" + ex.Message);
                    return(false);
                }
            }
            else
            {
                ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", p_para.Sap_AEDAT, "模型转换-删除CONVERT_RKJE表失败");
            }
            return(Result);
        }
コード例 #4
0
ファイル: ClsDataLoadBGY.cs プロジェクト: zpjune/WZBDH
        public bool SAPLoadData(ClsSAPDataParameter p_para)
        {
            bool Result = true;

            try
            {
                string dldate = p_para.Sap_AEDAT;
                m_Conn = ClsUtility.GetConn();
                strBuilder.Append("BEGIN  ");
                strBuilder.Append(" DELETE FROM CONVERT_BGYGZL ;");//先按选择日期删除数据
                strBuilder.Append("  COMMIT ;END;");
                if (m_Conn.ExecuteSql(strBuilder.ToString()))
                {
                    strBuilder.Length = 0;
                    strBuilder.Append(" begin ");
                    strBuilder.Append(@" INSERT INTO CONVERT_BGYGZL(WERKS,WERKS_NAME,TZD,ITEMS,MATNR,MATKL,PMNAME,MAKTX,
                                        JBJLDW,NSOLM,ERNAME,WORKER_NAME,TZDTYPE,DLDATE,ERDAT)
                                        select A.WERKS,D.DW_NAME,A.ZDHTZD,A.ZITEM,A.MATNR,E.MATKL,F.PMNAME,E.MAKTX,
                                        F.JBJLDW,B.NSOLM,B.ERNAM,C.WORKER_NAME,1,'" + DateTime.Now.ToString("yyyyMMdd") + "',ERDAT");
                    strBuilder.Append(@" from ZC10MMDG072 A
                                        join ZC10MMDG085A B on A.ZDHTZD=B.ZDHTZD and A.ZITEM=B.ZITEM 
                                        join WZ_BGY C on  C.WORKER_CODE=B.ERNAM
                                        join WZ_DW D ON D.DW_CODE=A.WERKS
                                        JOIN MARA E ON E.MATNR=A.MATNR
                                        JOIN WZ_WLZ F ON F.PMCODE=E.MATKL  ;");//根据日期插入入库单相关保管员信息
                    strBuilder.Append(" commit; end; ");
                    if (m_Conn.ExecuteSql(strBuilder.ToString()))
                    {
                        ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "模型转换-删除CONVERT_BGYGZL表入库通知单保管员信息成功");
                        strBuilder.Length = 0;
                        strBuilder.Append(" begin ");
                        strBuilder.Append(@" INSERT INTO CONVERT_BGYGZL(WERKS,WERKS_NAME,TZD,ITEMS,MATNR,MATKL,PMNAME,MAKTX,
                                        JBJLDW,NSOLM,ERNAME,WORKER_NAME,TZDTYPE,DLDATE,ERDAT)
                                        select A.WERKS,D.DW_NAME,A.ZCKTZD,A.ZCITEM,A.MATNR,E.MATKL,F.PMNAME,E.MAKTX,
                                        F.JBJLDW,B.NSOLM,B.ERNAM,C.WORKER_NAME,2,'" + DateTime.Now.ToString("yyyyMMdd") + "',ERDAT");
                        strBuilder.Append(@" from ZC10MMDG078 A
                                        join ZC10MMDG085A B on A.ZCKTZD=B.ZCKTZD and A.ZCITEM=B.ZCITEM 
                                        join WZ_BGY C on  C.WORKER_CODE=B.ERNAM
                                        join WZ_DW D ON D.DW_CODE=A.WERKS
                                        JOIN MARA E ON E.MATNR=A.MATNR
                                        JOIN WZ_WLZ F ON F.PMCODE=E.MATKL  ;");//根据日期插入出库单相关保管员信息
                        strBuilder.Append(" commit; end; ");
                        if (m_Conn.ExecuteSql(strBuilder.ToString()))
                        {
                            Result = true;
                            ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "模型转换-删除CONVERT_BGYGZL表出库通知单保管员信息成功");
                        }
                        else
                        {
                            Result = false;
                            ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "模型转换-删除CONVERT_BGYGZL表出库通知单保管员信息失败");
                        }
                    }
                    else
                    {
                        Result = false;
                        ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "模型转换-删除CONVERT_BGYGZL表入库通知单保管员信息失败");
                    }
                }
                else
                {
                    Result = false;
                    ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "模型转换-删除CONVERT_BGYGZL表失败");
                }
            }
            catch (Exception ex)
            {
                ClsErrorLogInfo.WriteSapLog("1", "RKJE", "ALL", p_para.Sap_AEDAT, "模型转换-插入CONVERT_BGYGZL表发生异常:" + ex.Message);
                return(false);
            }
            return(Result);
        }
コード例 #5
0
ファイル: ClsDataLoadUserAction.cs プロジェクト: zpjune/WZBDH
        public bool SAPLoadData(ClsSAPDataParameter p_para)
        {
            bool Result = true;

            m_Conn = ClsUtility.GetConn();

            DataTable dtEKKODate = new DataTable();

            try
            {
                //查询EKKO的数据
                string strSqlIMPR = "select distinct AEDAT from EKKO t where dldate='" + p_para.Sap_AEDAT + "' ";
                dtEKKODate = m_Conn.GetSqlResultToDt(strSqlIMPR);
            }
            catch (Exception exception)
            {
                Result = false;
                ClsErrorLogInfo.WriteSapLog("1", "userAction", "ALL", p_para.Sap_AEDAT, "插入hb_useraction表过程中查询EKKO表发生异常:\t\n" + exception);
                return(Result);
            }
            foreach (DataRow subRowEKKODate in dtEKKODate.Rows)
            {
                if (subRowEKKODate["AEDAT"] == null || string.IsNullOrEmpty(subRowEKKODate["AEDAT"].ToString()))
                {
                    continue;
                }

                string strDate = subRowEKKODate["AEDAT"].ToString().Substring(0, 6);

                EKKO      strEKKO = new EKKO();
                DataTable dtEKKO  = new DataTable();
                try
                {
                    //查询EKKO的数据
                    string strSqlIMPR = "select distinct t.ERNAM from EKKO t where substr(aedat,0,6)='" + strDate + "'";
                    dtEKKO = m_Conn.GetSqlResultToDt(strSqlIMPR);
                }
                catch (Exception exception)
                {
                    Result = false;
                    ClsErrorLogInfo.WriteSapLog("1", "userAction", "ALL", p_para.Sap_AEDAT, "插入hb_useraction表过程中查询EKKO表发生异常:\t\n" + exception);
                    return(Result);
                }
                if (dtEKKO != null)
                {
                }
                else
                {
                    string sss = "";
                }

                strBuilder.Length = 0;
                strBuilder.Append(" Begin "); //开始执行SQL

                foreach (DataRow subRowEKKO in dtEKKO.Rows)
                {
                    strEKKO.strERNAM = subRowEKKO["ERNAM"].ToString();

                    strBuilder.Append(" DELETE FROM HB_USERACTION WHERE UA_DATE='" + strDate + "'  AND UA_YHBM='" + strEKKO.strERNAM + "';");

                    try
                    {
                        //用户名
                        strEKKO.strERNAMMC = m_Conn.GetSqlResultToStr("select distinct t.name_last from USR02 t where t.bname='" + strEKKO.strERNAM + "'");
                    }
                    catch (Exception exception1)
                    {
                        Result = false;
                        ClsErrorLogInfo.WriteSapLog("1", "userAction", "ALL", p_para.Sap_AEDAT, "插入hb_useraction表过程中查询USER_ADDR表发生异常:\t\n" + exception1);
                        return(Result);
                    }

                    try
                    {
                        string dwsql = "select t.department from USR02 t where t.bname='" + strEKKO.strERNAM + "'";
                        //公司编码 //公司名称
                        strEKKO.strBUKRSMC = m_Conn.GetSqlResultToStr(dwsql);
                    }
                    catch (Exception exception1)
                    {
                        Result = false;
                        ClsErrorLogInfo.WriteSapLog("1", "userAction", "ALL", p_para.Sap_AEDAT, "插入hb_useraction表过程中查询USR02表发生异常:\t\n" + exception1);
                        return(Result);
                    }

                    try
                    {
                        string strcountsql = " select LX,LOEKZ, count(1) as LXCOUNT from (";
                        strcountsql += " select trim(t.bsart) as LX, t.loekz as LOEKZ from EKKO t";
                        strcountsql += " where t.ernam='" + strEKKO.strERNAM + "' )";
                        strcountsql += " group by lx, loekz";

                        //业务单据量
                        DataTable dtcount = m_Conn.GetSqlResultToDt(strcountsql);

                        if (dtcount != null && dtcount.Rows.Count > 0)
                        {
                            YWCOUNT ywAll = new YWCOUNT();
                            ywAll.str_lxbm   = "ALL";
                            ywAll.str_lxmc   = getLXMC(ywAll.str_lxbm);
                            ywAll.intQBCount = 0;
                            ywAll.intYXCount = 0;
                            ywAll.intCXCount = 0;

                            YWCOUNT yw70 = SetYWCount("X008", dtcount);
                            if (!string.IsNullOrEmpty(yw70.str_lxbm))
                            {
                                ywAll.intQBCount = yw70.intQBCount;
                                ywAll.intYXCount = yw70.intYXCount;
                                ywAll.intCXCount = yw70.intCXCount;
                                strBuilder.Append(insertsql(strEKKO, yw70, strDate));
                            }

                            YWCOUNT yw71 = SetYWCount("X009", dtcount);
                            if (!string.IsNullOrEmpty(yw71.str_lxbm))
                            {
                                ywAll.intQBCount = yw71.intQBCount;
                                ywAll.intYXCount = yw71.intYXCount;
                                ywAll.intCXCount = yw71.intCXCount;
                                strBuilder.Append(insertsql(strEKKO, yw71, strDate));
                            }

                            YWCOUNT yw45 = SetYWCount(dtcount);
                            if (!string.IsNullOrEmpty(yw45.str_lxbm))
                            {
                                ywAll.intQBCount = yw45.intQBCount;
                                ywAll.intYXCount = yw45.intYXCount;
                                ywAll.intCXCount = yw45.intCXCount;
                                strBuilder.Append(insertsql(strEKKO, yw45, strDate));
                            }

                            if (ywAll.intQBCount > 0)
                            {
                                strBuilder.Append(insertsql(strEKKO, ywAll, strDate));
                            }
                        }
                    }
                    catch (Exception exception1)
                    {
                        Result = false;
                        ClsErrorLogInfo.WriteSapLog("1", "userAction", "ALL", p_para.Sap_AEDAT, "插入hb_useraction表过程中查询EKKO表业务量发生异常:\t\n" + exception1);
                        return(Result);
                    }
                }

                strBuilder.Append(" End;");  //SQL完成
                try
                {
                    if (strBuilder.ToString().Length < 14)
                    {
                        return(true);
                    }
                    //数据提交
                    Result = ClsUtility.ExecuteSqlToDb(strBuilder.ToString());
                }
                catch (Exception exception5)
                {
                    Result = false;
                    ClsErrorLogInfo.WriteSapLog("1", "userAction", "ALL", p_para.Sap_AEDAT, "插入hb_useraction表发生异常:" + exception5);
                }
            }
            return(Result);
        }
コード例 #6
0
        public bool SAPLoadData(ClsSAPDataParameter p_para)
        {
            string dldate = p_para.Sap_AEDAT;
            bool   Result = true;

            m_Conn = ClsUtility.GetConn();
            try
            {
                string week = DateTime.Today.DayOfWeek.ToString();
                if (week == "Thursday")
                {
                    string sql = " begin insert into CONVERT_SWKC_RECORD SELECT * FROM CONVERT_SWKC ;COMMIT; END;  ";
                    m_Conn.ExecuteSql(sql);
                }
                //string sqlLQUA = @"begin delete from CONVERT_SWKC where KCTYPE=0;
                //                    INSERT INTO CONVERT_SWKC (WERKS,MATKL,MATNR,MAKTX,
                //                     MEINS,GESME,LGORT,LGPLA,ERDAT,WERKS_NAME,LGORT_NAME,ZSTATUS,YXQ,DLDATE,KCTYPE)
                //                     SELECT A.WERKS,C.MATKL,A.MATNR,C.MAKTX,
                //                     F.JBJLDW,A.GESME,A.LGORT,substr(A.LGPLA,0,4),case when SUBSTR(A.WDATU, 0, 8)='00000000' then A.BDATU ELSE A.WDATU END,D.DW_NAME,E.KCDD_NAME,'04','',to_char(sysdate,'yyyymmdd'),0
                //                     FROM LQUA A JOIN(
                //                    select WERKS,MATNR,substr(lgpla,0,2) DKCODE,LGORT,max(BDATU) BDATU,max(LQNUM) LQNUM
                //                    from LQUA where regexp_like(lgpla,'^[0-9]+[0-9]$')
                //                     group by werks,matnr,LGORT,substr(lgpla,0,2)) B ON A.WERKS=B.WERKS AND A.MATNR=B.MATNR AND substr(A.lgpla,0,2)=B.DKCODE AND A.LGORT=B.LGORT AND A.BDATU=B.BDATU AND A.LQNUM=B.LQNUM
                //                     JOIN MARA C ON A.MATNR=C.MATNR
                //                     join WZ_DW D ON D.DW_CODE=A.Werks
                //                    LEFT join WZ_KCDD E ON E.DWCODE=A.WERKS AND E.KCDD_CODE=A.LGORT
                //                    JOIN WZ_WLZ F ON F.PMCODE=C.MATKL ; COMMIT; end;"; //查询lqua表库存,lapla 为数字得,子查询是按物料编码取最新一条数据,主要取里面得BDATU,WDATU
                //regexp_like(lgpla,'^[0-9]+[0-9]$')过滤lapla不是数字的
                string sqlLQUA = @"
                                     SELECT A.WERKS,C.MATKL,A.MATNR,trim(C.MAKTX)MAKTX,
                                     F.JBJLDW MEINS,nvl(A.GESME,0)GESME,A.LGORT,substr(A.LGPLA,0,4)LGPLA2,A.LGPLA ,case when SUBSTR(A.WDATU, 0, 8)='00000000' then A.BDATU ELSE A.WDATU END ERDAT,
                                        D.DW_NAME WERKS_NAME,E.KCDD_NAME,'04' ZSTATUS,''YXQ,to_char(sysdate,'yyyymmdd')DLDATE,0 KCTYPE
                                     FROM LQUA A 
                                     JOIN MARA C ON A.MATNR=C.MATNR
                                     join WZ_DW D ON D.DW_CODE=A.Werks
                                     LEFT join WZ_KCDD E ON E.DWCODE=A.WERKS AND E.KCDD_CODE=A.LGORT
                                    JOIN WZ_WLZ F ON F.PMCODE=C.MATKL where regexp_like(lgpla,'^0\d{9}$') AND substr(A.LGTYP,0,1)<>'9' "; //查询lqua表库存,lapla 为数字得,子查询是按物料编码取最新一条数据,主要取里面得BDATU,WDATU
                //regexp_like(lgpla,'^[0-9]+[0-9]$')过滤lapla不是数字的

                DataTable dt = m_Conn.GetSqlResultToDt(sqlLQUA);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string        sqlruku   = @"select nvl(C.MENGE,0)MENGE,C.BUDAT_MKPF,A.MATNR,A.ZDHTZD, A.ZITEM,B.LGPLA,A.WERKS,A.LGORT
                                        from ZC10MMDG072 A
                                        JOIN ZC10MMDG085B B ON A.ZDHTZD=B.ZDHTZD AND A.ZITEM=B.ZITEM  and regexp_like(B.lgpla,'^0\d{9}$') 
                                        JOIN MSEG C ON C.MBLNR=A.MBLNR AND C.ZEILE=A.ZEILE and C.BWART IN('105','101') 
                                        WHERE exists (SELECT 1 FROM LQUA d WHERE d.MATNR=A.MATNR and regexp_like(d.lgpla,'^0\d{9}$')  ) 
                                        order by C.BUDAT_MKPF desc,a.matnr,a.zdhtzd,a.zitem ";
                    DataTable     dtruku    = m_Conn.GetSqlResultToDt(sqlruku);
                    StringBuilder sb        = new StringBuilder();
                    string        sqlinsert = "INSERT INTO CONVERT_SWKC (WERKS,MATKL,MATNR,MAKTX,MEINS,GESME,LGORT,LGPLA,ERDAT,WERKS_NAME,LGORT_NAME,ZSTATUS,YXQ,DLDATE,KCTYPE)values ('";
                    foreach (DataRow row in dt.Rows)
                    {
                        DataRow[] rowsRK = dtruku.Select("MATNR='" + row["MATNR"] + "' and WERKS='" + row["WERKS"] + "' and  LGORT='" + row["LGORT"] + "' and LGPLA='" + row["LGPLA"] + "' ");
                        if (rowsRK != null && rowsRK.Length > 0)
                        {
                            double sumSL = 0;
                            int    flag  = 0;
                            foreach (DataRow rowRK in rowsRK)
                            {
                                sumSL = sumSL + double.Parse(rowRK["MENGE"].ToString());
                                if (sumSL >= double.Parse(row["GESME"].ToString()))
                                {
                                    sb.AppendLine("");
                                    sb.Append(sqlinsert);
                                    sb.Append(row["WERKS"].ToString() + "','");
                                    sb.Append(row["MATKL"].ToString() + "','");
                                    sb.Append(row["MATNR"].ToString() + "','");
                                    sb.Append(row["MAKTX"].ToString().Replace("/*", "*").Replace("&", " ").Replace("'", "").Trim() + "','");
                                    sb.Append(row["MEINS"].ToString() + "','");
                                    sb.Append(row["GESME"].ToString() + "','");
                                    sb.Append(row["LGORT"].ToString() + "','");
                                    sb.Append(row["LGPLA2"].ToString() + "','");
                                    sb.Append(rowRK["BUDAT_MKPF"].ToString() + "','");
                                    sb.Append(row["WERKS_NAME"].ToString() + "','");
                                    sb.Append(row["KCDD_NAME"].ToString() + "','");
                                    sb.Append(row["ZSTATUS"].ToString() + "','");
                                    sb.Append(row["YXQ"].ToString() + "','");
                                    sb.Append(row["DLDATE"].ToString() + "',");
                                    sb.Append(row["KCTYPE"].ToString() + ");");
                                    flag = 1;
                                    break;
                                }
                            }
                            if (flag == 0)
                            {
                                sb.AppendLine("");
                                sb.Append(sqlinsert);
                                sb.Append(row["WERKS"].ToString() + "','");
                                sb.Append(row["MATKL"].ToString() + "','");
                                sb.Append(row["MATNR"].ToString() + "','");
                                sb.Append(row["MAKTX"].ToString().Replace("/*", "*").Replace("&", " ").Replace("'", "").Trim() + "','");
                                sb.Append(row["MEINS"].ToString() + "','");
                                sb.Append(row["GESME"].ToString() + "','");
                                sb.Append(row["LGORT"].ToString() + "','");
                                sb.Append(row["LGPLA2"].ToString() + "','");
                                sb.Append(row["ERDAT"].ToString() + "','");
                                sb.Append(row["WERKS_NAME"].ToString() + "','");
                                sb.Append(row["KCDD_NAME"].ToString() + "','");
                                sb.Append(row["ZSTATUS"].ToString() + "','");
                                sb.Append(row["YXQ"].ToString() + "','");
                                sb.Append(row["DLDATE"].ToString() + "',");
                                sb.Append(row["KCTYPE"].ToString() + ");");
                            }
                        }
                        else
                        {
                            sb.AppendLine("");
                            sb.Append(sqlinsert);
                            sb.Append(row["WERKS"].ToString() + "','");
                            sb.Append(row["MATKL"].ToString() + "','");
                            sb.Append(row["MATNR"].ToString() + "','");
                            sb.Append(row["MAKTX"].ToString().Replace("/*", "*").Replace("&", " ").Replace("'", "").Trim() + "','");
                            sb.Append(row["MEINS"].ToString() + "','");
                            sb.Append(row["GESME"].ToString() + "','");
                            sb.Append(row["LGORT"].ToString() + "','");
                            sb.Append(row["LGPLA2"].ToString() + "','");
                            sb.Append(row["ERDAT"].ToString() + "','");
                            sb.Append(row["WERKS_NAME"].ToString() + "','");
                            sb.Append(row["KCDD_NAME"].ToString() + "','");
                            sb.Append(row["ZSTATUS"].ToString() + "','");
                            sb.Append(row["YXQ"].ToString() + "','");
                            sb.Append(row["DLDATE"].ToString() + "',");
                            sb.Append(row["KCTYPE"].ToString() + ");");
                        }
                    }

                    string insertSWKC = @"begin delete from CONVERT_SWKC where KCTYPE=0;";
                    insertSWKC += "  COMMIT; end;";
                    Result      = m_Conn.ExecuteSql(insertSWKC);
                    insertSWKC  = "  begin  ";
                    insertSWKC += sb.ToString();
                    insertSWKC += "  COMMIT; end;";
                    Result      = m_Conn.ExecuteSql(insertSWKC);
                    if (Result)
                    {
                        ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKC", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKC表上架部分成功");
                    }
                    else
                    {
                        ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKC", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKC表上架部分失");
                    }
                }
                else
                {
                    ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKC", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKC表上架部分失败--没数据");
                }
                string sqlSWKCDetail = @"  begin DELETE FROM CONVERT_SWKCDETAIL;
                                            INSERT INTO CONVERT_SWKCDETAIL(WERKS,WERKS_NAME,LGORT,MATNR,GESME,ERDATE,DLNAME,PMNAME,DLDATE)
                                            SELECT A.WERKS,D.DW_NAME,A.LGORT,A.MATNR,A.GESME 
                                            ,case when SUBSTR(A.WDATU, 0, 8)='00000000' then A.BDATU ELSE A.WDATU END,F.DLNAME,F.PMNAME,to_char(sysdate,'yyyymmdd')
                                             FROM LQUA A JOIN(
                                            select WERKS,MATNR,substr(lgpla,0,2) DKCODE,LGORT,max(BDATU) BDATU,max(LQNUM) LQNUM
                                            from LQUA where regexp_like(lgpla,'^[0-9]+[0-9]$') --AND  matnr='000000011000683835'
                                             group by werks,matnr,LGORT,substr(lgpla,0,2)) B ON A.WERKS=B.WERKS AND A.MATNR=B.MATNR AND substr(A.lgpla,0,2)=B.DKCODE AND A.LGORT=B.LGORT AND A.BDATU=B.BDATU AND A.LQNUM=B.LQNUM
                                             JOIN MARA C ON A.MATNR=C.MATNR
                                             join WZ_DW D ON D.DW_CODE=A.Werks
                                            JOIN WZ_WLZ F ON F.PMCODE=C.MATKL ;COMMIT;end;";
                Result = m_Conn.ExecuteSql(sqlSWKCDetail);
                if (Result)
                {
                    ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKCDETAIL", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKCDETAIL表上架部分成功");
                }
                else
                {
                    ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKCDETAIL", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKCDETAIL表上架部分失败");
                }

                strBuilder.Length = 0;
                strBuilder.Append(@" begin INSERT INTO CONVERT_SWKC (WERKS,ZDHTZD,ZITEM,MATKL,MATNR,MAKTX,
                                                    MEINS,GESME,LGORT,LGPLA,ERDAT,WERKS_NAME,LGORT_NAME,ZSTATUS,YXQ,DLDATE,KCTYPE)                                          
                                                     select t.WERKS,t.ZDHTZD,t.ZITEM,d.MATKL,  t.MATNR,trim(d.MAKTX)MAKTX,
                                                     e.JBJLDW,k.VMENGE01,t.LGORT,'' LGPLA ,t.ZCJRQ, b.DW_NAME,c.KCDD_NAME,'03','','" + dldate + "',0 ");
                strBuilder.Append(@" from ZC10MMDG072 t
                                                       join ZC10MMDG076 k on t.ZDHTZD =k.ZDHTZD and t.ZITEM=k.ZITEM
                                                     join WZ_DW b ON b.DW_CODE=t.Werks
                                                     join WZ_KCDD c ON c.DWCODE=t.WERKS AND c.KCDD_CODE=t.LGORT
                                                    join    MARA d on d.matnr=t.matnr
                                                    join WZ_WLZ e on e.PMCODE=d.MATKL
                                                     where ZSTATUS ='03' and  k.ZJYRQ between TO_CHAR(trunc(sysdate)-14,'yyyymmdd') and TO_CHAR(sysdate,'yyyymmdd')
                                                     and k.ZJYRQ<>'00000000'
                                                ; commit; end; ");//插入质检状态的入库单作为另一部分库存
                Result = m_Conn.ExecuteSql(strBuilder.ToString());
                if (Result)
                {
                    ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKC", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKC表质检部分成功");
                }
                else
                {
                    ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKC", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKC表质检部分失败");
                }

                string sqlupdateje = @"UPDATE CONVERT_SWKCDETAIL A SET A.SCJE=(select ROUND(B.SALK3/LBKUM*A.GESME,2) 
                                                        FROM MBEW B
                                                        WHERE B.SALK3>0 AND A.MATNR=B.MATNR AND  A.WERKS=B.BWKEY)";
                if (!m_Conn.ExecuteSql(sqlupdateje))
                {
                    ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKCDETAIL", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "更新CONVERT_SWKCDETAIL表金额失败");
                }
                ClsDataLoadBAOBIAO.SAPLoadData(p_para);//下架未过账库存金额模型
            }
            catch (Exception ex)
            {
                strBuilder.Length = 0;
                ClsErrorLogInfo.WriteSapLog("1", "CONVERT_SWKC", "ALL", DateTime.Now.ToString("yyyy-MM-dd"), "插入CONVERT_SWKC表发生异常:" + ex.Message);
                return(false);
            }
            return(Result);
        }
コード例 #7
0
ファイル: ClsDataLoadWZ.cs プロジェクト: zpjune/WZBDH
        public bool SAPLoadData(ClsSAPDataParameter p_para)
        {
            bool Result = true;

            m_Conn = ClsUtility.GetConn();

            #region 查询主表信息
            ZC025 strZC025 = new ZC025();

            DataTable dtZC025 = new DataTable();
            try
            {
                StringBuilder sbSqlZC025 = new StringBuilder();
                sbSqlZC025.Append(" select");
                sbSqlZC025.Append(" a.RSNUM,a.RSDAT,a.CPUTM,a.ZJHLX0,a.ZJHLX0T,a.WERKS,");
                sbSqlZC025.Append(" to_number(b.RSPOS) as XMH,b.MATNR,'' MAKTX,'' MATKL,'' WGBEZ,'' ERDAT,'' ERZET");
                sbSqlZC025.Append(" from ZC10MMDG025 a ,RESB b where a.RSNUM=b.RSNUM and a.DLDATE='" + p_para.Sap_AEDAT + "'");
                sbSqlZC025.Append(" union all ");
                sbSqlZC025.Append(" select");
                sbSqlZC025.Append(" a.RSNUM,a.RSDAT,a.CPUTM,a.ZJHLX0,a.ZJHLX0T,a.WERKS,");
                sbSqlZC025.Append(" to_number(b.POSNR) as XMH,b.MATNR,b.ARKTX MAKTX,'' MATKL,'' WGBEZ,b.ERDAT,b.ERZET");
                sbSqlZC025.Append(" from ZC10MMDG025 a ,VBAP b where a.RSNUM=b.vbeln and a.DLDATE='" + p_para.Sap_AEDAT + "'");
                sbSqlZC025.Append(" union ");
                sbSqlZC025.Append(" select");
                sbSqlZC025.Append(" a.RSNUM,a.RSDAT,a.CPUTM,a.ZJHLX0,a.ZJHLX0T,a.WERKS,");
                sbSqlZC025.Append(" to_number(b.RSPOS)as XMH,b.MATNR,'' MAKTX,'' MATKL,'' WGBEZ,'' ERDAT,'' ERZET");
                sbSqlZC025.Append(" from ZC10MMDG025 a ,ZC10MMDG026 b where a.RSNUM=b.RSNUM and a.DLDATE='" + p_para.Sap_AEDAT + "'");
                sbSqlZC025.Append(" union ");
                sbSqlZC025.Append(" select");
                sbSqlZC025.Append(" a.RSNUM,a.RSDAT,a.CPUTM,a.ZJHLX0,a.ZJHLX0T,a.WERKS,");
                sbSqlZC025.Append(" to_number(b.RSPOS) as XMH,b.MATNR,'' MAKTX,'' MATKL,'' WGBEZ,'' ERDAT,'' ERZET");
                sbSqlZC025.Append(" from ZC10MMDG025 a ,ZP10MMDG203_HZ b where a.RSNUM=b.RSNUM and a.DLDATE='" + p_para.Sap_AEDAT + "'");
                dtZC025 = m_Conn.GetSqlResultToDt(sbSqlZC025.ToString());
            }
            catch (Exception exception)
            {
                Result = false;
                ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表过程中查询ZC10MMDG025表发生异常:\t\n" + exception);
                return(Result);
            }

            DataTable dtZC025B = new DataTable();
            try
            {
                string sbSqlZC025B = " select";
                sbSqlZC025B += " REQ_NUM,BDTER,CPUTM,REQ_ITEM,MATNR,ZJHLX0,WERKS,MAKTX,MATKL,WGBEZ,ZJHLX1,ZJHLX2,BWART";
                sbSqlZC025B += " from ZC10MMDG025B WHERE REQ_NUM IS NOT NULL and DLDATE='" + p_para.Sap_AEDAT + "'";

                dtZC025B = m_Conn.GetSqlResultToDt(sbSqlZC025B);
            }
            catch (Exception exception)
            {
                Result = false;
                ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表过程中查询ZC10MMDG025B表发生异常:\t\n" + exception);
                return(Result);
            }

            DataRow drZC025 = null;
            foreach (DataRow subRowZC025B in dtZC025B.Rows)
            {
                drZC025            = dtZC025.NewRow();
                drZC025["RSNUM"]   = subRowZC025B["REQ_NUM"].ToString();  //需求计划号
                drZC025["RSDAT"]   = subRowZC025B["BDTER"].ToString();    //需求计划提报日期
                drZC025["CPUTM"]   = subRowZC025B["CPUTM"].ToString();    //需求计划提报时间
                drZC025["ZJHLX0"]  = subRowZC025B["ZJHLX0"].ToString();   //需求计划类型
                drZC025["ZJHLX0T"] = string.Empty;                        //需求计划文本
                drZC025["WERKS"]   = subRowZC025B["WERKS"].ToString();    //工厂
                drZC025["XMH"]     = subRowZC025B["REQ_ITEM"].ToString(); //需求项目号
                drZC025["MATNR"]   = subRowZC025B["MATNR"].ToString();    //物料号
                drZC025["MAKTX"]   = subRowZC025B["MAKTX"].ToString();    //物料描述
                drZC025["MATKL"]   = subRowZC025B["MATKL"].ToString();    //物料组
                drZC025["WGBEZ"]   = subRowZC025B["WGBEZ"].ToString();    //物料组描述
                drZC025["ERDAT"]   = string.Empty;                        //创建日期
                drZC025["ERZET"]   = string.Empty;                        //创建时间

                dtZC025.Rows.Add(drZC025);
            }

            #endregion

            int commitcount = 0;
            int commitMax   = 500;
            strBuilder.Length = 0;
            strBuilder.Append(" Begin "); //开始执行SQL
            List <string> ls = new List <string>();

            foreach (DataRow subRowZC025 in dtZC025.Rows)
            {
                if (!ls.Contains(subRowZC025["RSNUM"].ToString()))
                {
                    strBuilder.Append(" DELETE FROM HB_WZ WHERE WL_JHH='" + subRowZC025["RSNUM"].ToString() + "';");
                    ls.Add(subRowZC025["RSNUM"].ToString());
                }

                strZC025.strRSNUM   = subRowZC025["RSNUM"].ToString();                  //需求计划号
                strZC025.strRSDAT   = subRowZC025["RSDAT"].ToString().Replace(".", ""); //需求计划提报日期
                strZC025.strCPUTM   = subRowZC025["CPUTM"].ToString();                  //需求计划提报时间
                strZC025.strZJHLXO  = subRowZC025["ZJHLX0"].ToString();                 //需求计划类型
                strZC025.strZJHLX0T = subRowZC025["ZJHLX0T"].ToString();                //需求计划文本
                strZC025.strWERKS   = subRowZC025["WERKS"].ToString();                  //工厂
                strZC025.strRSPOS   = subRowZC025["XMH"].ToString();                    //需求项目号
                strZC025.strMATNR   = subRowZC025["MATNR"].ToString();                  //物料号
                strZC025.strARKTX   = subRowZC025["MAKTX"].ToString();                  //物料描述
                strZC025.strMATKL   = subRowZC025["MATKL"].ToString();                  //物料组
                strZC025.strWGBEZ   = subRowZC025["WGBEZ"].ToString();                  //物料组描述
                strZC025.strERDAT   = subRowZC025["ERDAT"].ToString();                  //创建日期
                strZC025.strERZET   = subRowZC025["ERZET"].ToString();                  //创建时间
                //工厂名称
                DataTable dtGC = new DataTable();
                try
                {
                    string sbGC = " select name1 from  T001W where WERKS='" + strZC025.strWERKS + "'";
                    dtGC = m_Conn.GetSqlResultToDt(sbGC);
                }
                catch (Exception exception)
                {
                    Result = false;
                    ClsErrorLogInfo.WriteSapLog("1", "cg", "ALL", p_para.Sap_AEDAT, "插入hb_wzcg表过程中查询ZC10MMDG025B表发生异常:\t\n" + exception);
                    return(Result);
                }
                if (dtGC != null && dtGC.Rows.Count > 0)
                {
                    strZC025.strWNAME = (dtGC.Rows[0]["NAME1"] ?? string.Empty).ToString();
                }

                #region 采购

                DataTable dtZC026 = new DataTable();
                try
                {
                    string strSqlZC026 = "select RSNUM,RSPOS,AEDAT,MATNR,MAKTX,MATKL,";
                    strSqlZC026 += " WGBEZ,ZEBELN,ZEBELP";
                    strSqlZC026 += " from ZC10MMDG026";
                    strSqlZC026 += " where  RSNUM='" + strZC025.strRSNUM + "' and TO_NUMBER(RSPOS)=" + Convert.ToInt16(strZC025.strRSPOS).ToString();
                    dtZC026      = m_Conn.GetSqlResultToDt(strSqlZC026);
                }
                catch (Exception exception2)
                {
                    Result = false;
                    ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表过程中查询ZC10MMDG026表发生异常:\t\n" + exception2);
                    return(Result);
                }

                //二级单位
                DataTable dtZP203_HZ = new DataTable();
                try
                {
                    string strSqlZP203_HZ = "select BANFN,BNFPO,AEDAT,MATNR,MATKL,EBELN,EBELP";
                    strSqlZP203_HZ += " from ZP10MMDG203_HZ";
                    strSqlZP203_HZ += " where RSNUM='" + strZC025.strRSNUM + "' and TO_NUMBER(RSPOS)=" + Convert.ToInt16(strZC025.strRSPOS);
                    strSqlZP203_HZ += " and  MATNR='" + strZC025.strMATNR + "'";
                    dtZP203_HZ      = m_Conn.GetSqlResultToDt(strSqlZP203_HZ);
                }
                catch (Exception exception2)
                {
                    Result = false;
                    ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表过程中查询ZP10MMDG203_HZ表发生异常:\t\n" + exception2);
                    return(Result);
                }

                //二级单位和公司级合并数据
                if (dtZP203_HZ != null && dtZP203_HZ.Rows.Count > 0)
                {
                    DataRow drZC026 = null;
                    foreach (DataRow subRowZP203 in dtZP203_HZ.Rows)
                    {
                        drZC026 = dtZC026.NewRow();

                        drZC026["RSNUM"]  = subRowZP203["BANFN"].ToString(); //采购申请号
                        drZC026["RSPOS"]  = subRowZP203["BNFPO"].ToString(); //采购申请行项目号
                        drZC026["AEDAT"]  = subRowZP203["AEDAT"].ToString(); //采购申请生成日期
                        drZC026["MATNR"]  = subRowZP203["MATNR"].ToString(); //采购物料号
                        drZC026["MAKTX"]  = string.Empty;                    //采购物料描述
                        drZC026["MATKL"]  = subRowZP203["MATKL"].ToString(); //采购物料组
                        drZC026["WGBEZ"]  = string.Empty;                    //采购物料组描述
                        drZC026["ZEBELN"] = subRowZP203["EBELN"].ToString(); //采购订单
                        drZC026["ZEBELP"] = subRowZP203["EBELP"].ToString(); //采购订单项目号
                        dtZC026.Rows.Add(drZC026);
                    }
                }

                #endregion

                ZC026 strZC026 = new ZC026();
                foreach (DataRow subRowZC026 in dtZC026.Rows)
                {
                    strZC026.strZCGJHNUM = subRowZC026["RSNUM"].ToString();  //采购计划号
                    strZC026.strZCGJHPOS = subRowZC026["RSPOS"].ToString();  //采购计划项目
                    strZC026.strAEDAT    = subRowZC026["AEDAT"].ToString();  //采购申请生成日期
                    strZC026.strMATNR    = subRowZC026["MATNR"].ToString();  //采购物料号
                    strZC026.strMAKTX    = subRowZC026["MAKTX"].ToString();  //采购物料描述
                    strZC026.strMATKL    = subRowZC026["MATKL"].ToString();  //采购物料组
                    strZC026.strWGBEZ    = subRowZC026["WGBEZ"].ToString();  //采购物料组描述
                    strZC026.strZEBELN   = subRowZC026["ZEBELN"].ToString(); //采购订单
                    strZC026.strZEBELP   = subRowZC026["ZEBELP"].ToString(); //采购订单项目号
                    DataTable dtEKPO = new DataTable();
                    if (strZC026.strZEBELN != null && strZC026.strZEBELN != "")
                    {
                        try
                        {
                            string strSqlEKPO = "select EBELN,EBELP,BUKRS,AEDAT,NETPR,MENGE,NETWR,MEINS  from EKPO";
                            strSqlEKPO += " where EBELN='" + strZC026.strZEBELN + "' and EBELP ='" + strZC026.strZEBELP + "'";
                            strSqlEKPO += " and (LOEKZ<>'L' or LOEKZ IS NULL)";

                            dtEKPO = m_Conn.GetSqlResultToDt(strSqlEKPO);
                        }
                        catch (Exception exception2)
                        {
                            Result = false;
                            ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表过程中查询EKPO表发生异常:\t\n" + exception2);
                            return(Result);
                        }
                    }
                    else
                    {
                        try
                        {
                            string strSqlEKPO = "select EBELN,EBELP,BUKRS,AEDAT,NETPR,MENGE,NETWR,MEINS from EKPO";
                            strSqlEKPO += " where BANFN='" + strZC026.strZCGJHNUM + "' and TO_NUMBER(BNFPO)=" + Convert.ToInt16(strZC026.strZCGJHPOS);
                            strSqlEKPO += " and (LOEKZ<>'L' or LOEKZ IS NULL)";

                            dtEKPO = m_Conn.GetSqlResultToDt(strSqlEKPO);
                        }
                        catch (Exception exception2)
                        {
                            Result = false;
                            ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表过程中查询EKPO表发生异常:\t\n" + exception2);
                        }
                    }
                    if (dtEKPO != null && dtEKPO.Rows.Count > 0)
                    {
                        strZC026.strZEBELN = (dtEKPO.Rows[0]["EBELN"] ?? string.Empty).ToString(); //采购订单
                        strZC026.strZEBELP = (dtEKPO.Rows[0]["EBELP"] ?? string.Empty).ToString(); //采购订单项目号
                    }
                    #region 采购订单生成


                    if (dtEKPO != null && dtEKPO.Rows.Count > 0)
                    {
                        foreach (DataRow subRowEKPO in dtEKPO.Rows)
                        {
                            #region EKKO数据查询
                            EKKPO strEKKPO = new EKKPO();
                            strEKKPO.strMENGE = subRowEKPO["MENGE"].ToString();
                            strEKKPO.strNETWR = subRowEKPO["NETWR"].ToString();
                            strEKKPO.strNETPR = subRowEKPO["NETPR"].ToString();
                            strEKKPO.strMEINS = subRowEKPO["MEINS"].ToString();

                            DataTable dtEKKO = new DataTable();
                            try
                            {
                                string strSqlEKKO = "select a.AEDAT,a.LIFNR,b.NAME1 from EKKO a,LFA1 b ";//ERP1.0取数方式
                                strSqlEKKO += " where a.EBELN='" + subRowEKPO["EBELN"].ToString() + "'";
                                strSqlEKKO += " and a.LIFNR=b.LIFNR";
                                dtEKKO      = m_Conn.GetSqlResultToDt(strSqlEKKO);
                            }
                            catch (Exception exception2)
                            {
                                Result = false;
                                ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表过程中查询EKPO表发生异常:\t\n" + exception2);
                                return(Result);
                            }
                            if (dtEKKO != null && dtEKKO.Rows.Count > 0)
                            {
                                strEKKPO.strAEDAT = (dtEKKO.Rows[0]["AEDAT"] ?? string.Empty).ToString();
                                strEKKPO.strLIFNR = (dtEKKO.Rows[0]["LIFNR"] ?? string.Empty).ToString();
                                strEKKPO.strNAME1 = (dtEKKO.Rows[0]["NAME1"] ?? string.Empty).ToString();
                            }
                            #endregion

                            #region 插入sql
                            strBuilder.Append(" INSERT INTO HB_WZ");
                            strBuilder.Append(" (WL_ID,WL_JHH,WL_JHLX,WL_JHLXWB,WL_GC,WL_GCMC,WL_XMH");
                            strBuilder.Append(",WL_WL,WL_WLMS,WL_WLZ,WL_WLZMS,WL_JHCJRQ,WL_CGDD,WL_CGDDXMH");
                            strBuilder.Append(",WL_GYS,WL_GYSMC,WL_CGSL,WL_JLDW,WL_CGDJ,WL_CGZJ,WL_CGDDRQ)");
                            strBuilder.Append(" VALUES(");
                            strBuilder.Append("SQ_WZCGSJ.NEXTVAL,");
                            strBuilder.Append("'" + strZC025.strRSNUM + "',");   //需求计划号
                            strBuilder.Append("'" + strZC025.strZJHLXO + "',");  //需求计划类型
                            strBuilder.Append("'" + strZC025.strZJHLX0T + "',"); //需求计划文本
                            strBuilder.Append("'" + strZC025.strWERKS + "',");   //工厂
                            strBuilder.Append("'" + strZC025.strWNAME + "',");   //工厂名称
                            strBuilder.Append("'" + strZC025.strRSPOS + "',");   //需求项目号
                            strBuilder.Append("'" + strZC026.strMATNR + "',");   //采购物料号
                            strBuilder.Append("'" + strZC026.strMAKTX + "',");   //采购物料描述
                            strBuilder.Append("'" + strZC026.strMATKL + "',");   //采购物料组
                            strBuilder.Append("'" + strZC026.strWGBEZ + "',");   //采购物料组描述
                            strBuilder.Append("'" + strZC025.strRSDAT + "',");   //需求计划提报日期
                            strBuilder.Append("'" + strZC026.strZEBELN + "',");  //采购订单
                            strBuilder.Append("'" + strZC026.strZEBELP + "',");  //采购订单项目号
                            strBuilder.Append("'" + strEKKPO.strLIFNR + "',");   //供应商
                            strBuilder.Append("'" + strEKKPO.strNAME1 + "',");   //供应商名称
                            strBuilder.Append("'" + strEKKPO.strMENGE + "',");   //采购数量
                            strBuilder.Append("'" + strEKKPO.strMEINS + "',");   //采购数量
                            strBuilder.Append("'" + strEKKPO.strNETPR + "',");   //采购单价
                            strBuilder.Append("'" + strEKKPO.strNETWR + "',");   //采购总价
                            strBuilder.Append("'" + strEKKPO.strAEDAT + "'");    //采购订单创建日期
                            strBuilder.Append(");");

                            #endregion

                            #region 提交sql
                            commitcount++;
                            if (commitcount % commitMax == 0)
                            {
                                strBuilder.Append(" End;");  //SQL完成
                                try
                                {
                                    if (strBuilder.ToString().Length < 14)
                                    {
                                        strBuilder.Length = 0;
                                        strBuilder.Append(" Begin "); //开始执行SQL
                                        continue;
                                    }
                                    //数据提交
                                    Result            = ClsUtility.ExecuteSqlToDb(strBuilder.ToString());
                                    strBuilder.Length = 0;
                                    strBuilder.Append(" Begin "); //开始执行SQL
                                }
                                catch (Exception exception5)
                                {
                                    Result = false;
                                    ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表发生异常:" + exception5);
                                }
                            }
                            #endregion
                            #endregion
                        }
                    }
                }
            }

            strBuilder.Append(" End;");  //SQL完成
            try
            {
                if (strBuilder.ToString().Length < 14)
                {
                    return(true);
                }
                //数据提交
                Result = ClsUtility.ExecuteSqlToDb(strBuilder.ToString());
            }
            catch (Exception exception5)
            {
                Result = false;
                ClsErrorLogInfo.WriteSapLog("1", "cgsj", "ALL", p_para.Sap_AEDAT, "插入hb_wz表发生异常:" + exception5);
            }

            return(Result);
        }