示例#1
0
        private static List <Warehouse> ERP_MES_Warehouse(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <Warehouse>();
            //RFC调用函数名
            string funcName = "ZWMS_T001L";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //处理标识
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("WERKS", typeof(string))); //工厂编码
            odt1.Columns.Add(new DataColumn("LGORT", typeof(string))); //库存地编码
            odt1.Columns.Add(new DataColumn("LGOBE", typeof(string))); //库存地描述
            odt1.Columns.Add(new DataColumn("XBUFX", typeof(string))); //冻结状态
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_TAB"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string factoryCode = dt.Rows[i]["WERKS"].ToString();
                string code        = dt.Rows[i]["LGORT"].ToString();
                string name        = dt.Rows[i]["LGOBE"].ToString();
                string state       = dt.Rows[i]["XBUFX"].ToString();
                var    warehouse   = new Warehouse {
                    Code = code, Name = name, Factory = new Organization {
                        Code = factoryCode
                    }
                };
                //if (factoryCode == "4200")
                //{
                //    warehouse.FactoryId = 2;
                //}
                //else
                //{

                //}
                lst.Add(warehouse);
            }
            return(lst);
        }
示例#2
0
        private static List <Customer> ERP_MES_Customer(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <Customer>();
            //RFC调用函数名
            string funcName = "ZWMS_KNA1";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //处理标识
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_KNA1";
            odt1.Columns.Add(new DataColumn("BUKRS", typeof(string))); //公司代码
            odt1.Columns.Add(new DataColumn("KUNNR", typeof(string))); //客户编号1
            odt1.Columns.Add(new DataColumn("NAME1", typeof(string))); //名称 1
            odt1.Columns.Add(new DataColumn("BZIRK", typeof(string))); //销售地区
            odt1.Columns.Add(new DataColumn("BZTXT", typeof(string))); //区名
            odt1.Columns.Add(new DataColumn("ABRVW", typeof(string))); //使用标识
            odt1.Columns.Add(new DataColumn("SORTL", typeof(string))); //排序字段
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_KNA1"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string corp     = dt.Rows[i]["BUKRS"].ToString();
                string code     = dt.Rows[i]["KUNNR"].ToString();
                string name     = dt.Rows[i]["NAME1"].ToString();
                string areaCode = dt.Rows[i]["BZIRK"].ToString();
                string areaName = dt.Rows[i]["BZTXT"].ToString();
                string state    = dt.Rows[i]["ABRVW"].ToString();
                var    customer = new Customer
                {
                    Code       = code,
                    Name       = name,
                    SalesArea  = areaCode,
                    CreateBy   = PlatformEnvironment.IdentityId,
                    CreateDate = DateTime.Now
                };
                lst.Add(customer);
            }
            return(lst);
        }
示例#3
0
        private static List <Supplier> ERP_MES_Supplier(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <Supplier>();
            //RFC调用函数名
            string funcName = "ZWMS_LFA1";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("BUKRS", typeof(string))); //公司代码
            odt1.Columns.Add(new DataColumn("LIFNR", typeof(string))); //供应商编码
            odt1.Columns.Add(new DataColumn("TXT30", typeof(string))); //供应商类型描述
            odt1.Columns.Add(new DataColumn("NAME1", typeof(string))); //供应商名称
            odt1.Columns.Add(new DataColumn("SPERZ", typeof(string))); //付款冻结
            odt1.Columns.Add(new DataColumn("KTOKK", typeof(string))); //供应商帐户组
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_TAB"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string code = dt.Rows[i]["LIFNR"].ToString();
                string type = dt.Rows[i]["TXT30"].ToString();
                string desc = dt.Rows[i]["KTOKK"].ToString();
                string name = dt.Rows[i]["NAME1"].ToString();
                name = string.IsNullOrEmpty(name) ? code : name;
                string frozen   = dt.Rows[i]["SPERZ"].ToString();
                var    supplier = new Supplier
                {
                    Code        = code,
                    Description = desc,
                    Name        = name,
                    ExpiryDate  = DateTime.Now.AddYears(1000),
                    Type        = type
                };
                lst.Add(supplier);
            }
            return(lst);
        }
示例#4
0
        private static List <PurchaseGroup> ERP_MES_Purchase(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <PurchaseGroup>();
            //RFC调用函数名
            string funcName = "ZWMS_T024";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("EKGRP", typeof(string)));
            odt1.Columns.Add(new DataColumn("EKNAM", typeof(string)));
            odt1.Columns.Add(new DataColumn("EKTEL", typeof(string)));
            odt1.Columns.Add(new DataColumn("TELFX", typeof(string)));
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_TAB"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string code     = dt.Rows[i]["EKGRP"].ToString();
                string employee = dt.Rows[i]["EKNAM"].ToString();//采购者
                //DomainControllerFactory.Create<EmployeeController>().get
                string phone = dt.Rows[i]["EKTEL"].ToString();
                string fax   = dt.Rows[i]["TELFX"].ToString();

                var model = new PurchaseGroup()
                {
                    Code = code, buyerName = employee, Phone = phone, Fax = fax
                };
                lst.Add(model);
            }
            return(lst);
        }
示例#5
0
        private static List <Factory> ERP_MES_CostCenter(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <Factory>();
            //RFC调用函数名
            string funcName = "ZWMS_CSKS";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("BUKRS", typeof(string))); //公司代码
            odt1.Columns.Add(new DataColumn("KOSTL", typeof(string))); //成本中心
            odt1.Columns.Add(new DataColumn("KTEXT", typeof(string))); //一般姓名
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_TAB"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string corpCode = dt.Rows[i]["BUKRS"].ToString();
                string costCode = dt.Rows[i]["KOSTL"].ToString();
                string name     = dt.Rows[i]["KTEXT"].ToString();
                var    model    = new Factory()
                {
                    Code = costCode, Name = name
                };

                lst.Add(model);
            }
            return(lst);
        }
示例#6
0
        private static List <Reasons> ERP_MES_MoveReason(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <Reasons>();
            //RFC调用函数名
            string funcName = "ZWMS_T157D";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("BWART", typeof(string))); //移动类型
            odt1.Columns.Add(new DataColumn("GRUND", typeof(string))); //移动原因
            odt1.Columns.Add(new DataColumn("GRTXT", typeof(string))); //移动原因
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_TAB"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string type   = dt.Rows[i]["BWART"].ToString();
                string reason = dt.Rows[i]["GRUND"].ToString();
                string txt    = dt.Rows[i]["GRTXT"].ToString();
                var    model  = new Reasons()
                {
                    Description = txt, Name = reason, MoveType = type
                };
                lst.Add(model);
            }
            return(lst);
        }
示例#7
0
        private static List <ItemSmallCategory> ERP_MES_Category(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <ItemSmallCategory>();
            //RFC调用函数名
            string funcName = "ZWMS_T023";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("MATKL", typeof(string))); //物料组代码
            odt1.Columns.Add(new DataColumn("WGBEZ", typeof(string))); //物料组描述
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_TAB"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string code = dt.Rows[i]["MATKL"].ToString();
                string name = dt.Rows[i]["WGBEZ"].ToString();
                name = string.IsNullOrEmpty(name) ? code : name;
                var cat = new ItemSmallCategory {
                    Code = code, Name = name, MediumCategory = new ItemMediumCategory {
                        Code = code, Name = name
                    }
                };
                lst.Add(cat);
            }
            return(lst);
        }
示例#8
0
        private static List <ProductBom> ERP_MES_Bom(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <ProductBom>();
            //RFC调用函数名
            string funcName = "ZWMS_BOM";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //处理标识
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_HEADER";
            odt1.Columns.Add(new DataColumn("WERKS", typeof(string))); //工厂
            odt1.Columns.Add(new DataColumn("MATNR", typeof(string))); //物料代码
            odt1.Columns.Add(new DataColumn("VERID", typeof(string))); //生产版本
            //odt1.Columns.Add(new DataColumn("ZTEXT", typeof(string)));//BOM 文本
            //odt1.Columns.Add(new DataColumn("STKTX", typeof(string)));//可选文本
            odt1.Columns.Add(new DataColumn("LOEKZ", typeof(string)));//BOM 删除标志
            ods.Tables.Add(odt1);

            DataTable odt2 = new DataTable();

            odt2.TableName = "T_ITEM";
            odt2.Columns.Add(new DataColumn("MATNR", typeof(string))); //物料代码
            odt2.Columns.Add(new DataColumn("IDNRK", typeof(string))); //BOM 组件
            odt2.Columns.Add(new DataColumn("MAKTX", typeof(string))); //物料描述(短文本)
            odt2.Columns.Add(new DataColumn("MENGE", typeof(string))); //组件数量
            odt2.Columns.Add(new DataColumn("MEINS", typeof(string))); //组件计量单位
            odt2.Columns.Add(new DataColumn("LGORT", typeof(string))); //库存地点
            odt2.Columns.Add(new DataColumn("RGEKZ", typeof(string))); //是否反冲
            ods.Tables.Add(odt2);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);

            //根据RFC执行后返回的数据处理业务逻辑
            //DataTable dt = ods.Tables["T_ITEM"];
            foreach (DataRow h in ods.Tables["T_HEADER"].Rows)
            {
                var    bom  = new ProductBom();
                string code = h["MATNR"].ToString();
                string ver  = h["VERID"].ToString();
                string flag = h["LOEKZ"].ToString();
                bom.Item = new Item {
                    Code = code
                };
                bom.Name    = code;
                bom.Code    = code;
                bom.Version = ver;
                foreach (DataRow i in ods.Tables["T_ITEM"].AsEnumerable().Where(p => h["MATNR"].ToString() == p["MATNR"].ToString()))
                {
                    var resover   = i["RGEKZ"].ToString();
                    var bomDetail = new ProductBomDetail()
                    {
                        Item = new Item {
                            Code = i["IDNRK"].ToString()
                        },
                        UnitQty   = Convert.ToDouble(i["MENGE"] ?? 0),
                        Unit      = i["MEINS"].ToString(),
                        Rgekz     = resover.IsNullOrEmpty() || resover == "0" ? 0 : 1,
                        Warehouse = i["LGORT"].ToSafeString()
                    };
                    bom.DetailList.Add(bomDetail);
                }
                lst.Add(bom);
            }
            return(lst);
        }
示例#9
0
        private static List <SaleBill> ERP_MES_JHD(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <SaleBill>();
            //RFC调用函数名
            string funcName = "ZWMS_JHD";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //消息文本
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_HEADER";
            odt1.Columns.Add(new DataColumn("VBELN", typeof(string))); //交货
            odt1.Columns.Add(new DataColumn("VSTEL", typeof(string))); //装运点/接收点
            odt1.Columns.Add(new DataColumn("VKORG", typeof(string))); //销售机构
            odt1.Columns.Add(new DataColumn("LFART", typeof(string))); //交货类型
            //odt1.Columns.Add(new DataColumn("KOKRS", typeof(string)));//客户编号
            odt1.Columns.Add(new DataColumn("WADAT", typeof(string))); //计划货物移动日期
            odt1.Columns.Add(new DataColumn("LFDAT", typeof(string))); //交货日期
            odt1.Columns.Add(new DataColumn("WBSTK", typeof(string))); //货物移动状态总计
            ods.Tables.Add(odt1);


            DataTable odt2 = new DataTable();

            odt2.TableName = "T_ITEM";
            odt2.Columns.Add(new DataColumn("VBELN", typeof(string))); //交货
            odt2.Columns.Add(new DataColumn("POSNR", typeof(string))); //交货项目
            odt2.Columns.Add(new DataColumn("PSTYV", typeof(string))); //交货项目类别
            odt2.Columns.Add(new DataColumn("WERKS", typeof(string))); //工厂
            odt2.Columns.Add(new DataColumn("MATNR", typeof(string))); //物料号
            odt2.Columns.Add(new DataColumn("LGORT", typeof(string))); //库存地点

            odt2.Columns.Add(new DataColumn("CHARG", typeof(string))); //批号
            odt2.Columns.Add(new DataColumn("LICHN", typeof(string))); //供应商的批次
            odt2.Columns.Add(new DataColumn("KDMAT", typeof(string))); //客户物料
            odt2.Columns.Add(new DataColumn("PRODH", typeof(string))); //产品层次
            odt2.Columns.Add(new DataColumn("LFIMG", typeof(string))); //实际已交货量(按销售单位)
            odt2.Columns.Add(new DataColumn("VRKME", typeof(string))); //销售单位

            ods.Tables.Add(odt2);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);

            //根据RFC执行后返回的数据处理业务逻辑
            //DataTable dt = ods.Tables["T_ITEM"];
            foreach (DataRow h in ods.Tables["T_HEADER"].Rows)
            {
                var bill = new SaleBill();
                try
                {
                    string type  = h["LFART"].ToString();
                    string state = h["WBSTK"].ToString();

                    bill.No       = h["VBELN"].ToString();
                    bill.BillDate = DateTime.Now;
                    bill.Location = h["VSTEL"].ToString();
                    bill.Org      = h["VKORG"].ToString();
                    //bill.Location = h["LFART"].ToString();
                    DateTime planDate, deliveryDate;
                    if (DateTime.TryParse(h["WADAT"].ToString(), out planDate))
                    {
                        bill.PlanDate = Convert.ToDateTime(h["WADAT"].ToString());
                    }
                    //else
                    //    bill.PlanDate = Convert.ToDateTime(h["WADAT"].ToString());

                    if (DateTime.TryParse(h["LFDAT"].ToString(), out deliveryDate))
                    {
                        bill.DeliveryDate = Convert.ToDateTime(h["LFDAT"].ToString());
                    }
                    //bill.State = h["WBSTK"].ToString();

                    foreach (DataRow i in ods.Tables["T_ITEM"].AsEnumerable().Where(p => h["VBELN"].ToString() == p["VBELN"].ToString()))
                    {
                        var billDtl = new SaleBillDetail()
                        {
                            Item = new Item {
                                Code = i["MATNR"].ToString()
                            },
                            ProjectNo    = i["POSNR"].ToString(),
                            Qty          = Convert.ToDouble(i["LFIMG"] ?? 0),
                            Unit         = i["VRKME"].ToString(),
                            Factory      = i["WERKS"].ToString(),
                            BatchNo      = i["CHARG"].ToString(),
                            LotNo        = i["LICHN"].ToString(),
                            Warehouse    = i["LGORT"].ToString(),
                            BillType     = i["PSTYV"].ToString(),
                            ProductLevel = i["PRODH"].ToString(),
                        };
                        bill.SaleBillDetailList.Add(billDtl);
                    }
                    lst.Add(bill);
                }
                catch (Exception e)
                {
                    continue;
                }
            }
            return(lst);
        }
示例#10
0
        private static List <YfWipIssueBill> ERP_MES_YF(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <YfWipIssueBill>();
            //RFC调用函数名
            string funcName = "ZWMS_YFRESERVE";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //消息文本
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_HEADER";
            odt1.Columns.Add(new DataColumn("RSNUM", typeof(string))); //预留单号
            odt1.Columns.Add(new DataColumn("BDTER", typeof(string))); //组件的需求日期
            odt1.Columns.Add(new DataColumn("BWART", typeof(string))); //移动类型
            odt1.Columns.Add(new DataColumn("KOSTL", typeof(string))); //成本中心
            odt1.Columns.Add(new DataColumn("KOKRS", typeof(string))); //控制范围
            ods.Tables.Add(odt1);

            DataTable odt2 = new DataTable();

            odt2.TableName = "T_ITEM";
            odt2.Columns.Add(new DataColumn("RSNUM", typeof(string))); //预留单号
            odt2.Columns.Add(new DataColumn("RSPOS", typeof(string))); //预留单号项目编号
            odt2.Columns.Add(new DataColumn("WERKS", typeof(string))); //工厂
            odt2.Columns.Add(new DataColumn("MATNR", typeof(string))); //物料号
            odt2.Columns.Add(new DataColumn("LGORT", typeof(string))); //库存地点
            odt2.Columns.Add(new DataColumn("BDMNG", typeof(string))); //需求量
            odt2.Columns.Add(new DataColumn("MEINS", typeof(string))); //基本计量单位
            odt2.Columns.Add(new DataColumn("BDTER", typeof(string))); //组件的需求日期
            odt2.Columns.Add(new DataColumn("ENMNG", typeof(string))); //提货数

            ods.Tables.Add(odt2);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);

            //根据RFC执行后返回的数据处理业务逻辑
            //DataTable dt = ods.Tables["T_ITEM"];
            foreach (DataRow h in ods.Tables["T_HEADER"].Rows)
            {
                var bill = new YfWipIssueBill();

                string type = h["BWART"].ToString();
                string dept = h["KOSTL"].ToString();
                string ctrl = h["KOKRS"].ToString();

                bill.No         = h["RSNUM"].ToString();
                bill.BillDate   = Convert.ToDateTime(h["BDTER"].ToString());
                bill.CostCenter = new BD.Factories.Factory()
                {
                    Code = dept
                };

                foreach (DataRow i in ods.Tables["T_ITEM"].AsEnumerable().Where(p => h["RSNUM"].ToString() == p["RSNUM"].ToString()))
                {
                    var billDtl = new YfWipIssueBillDetail()
                    {
                        Item = new Item {
                            Code = i["MATNR"].ToString()
                        },
                        ProjectNo      = i["RSPOS"].ToString(),
                        Qty            = Convert.ToDouble(i["BDMNG"] ?? 0),
                        ActualQty      = Convert.ToDouble(i["ENMNG"] ?? 0),
                        Unit           = i["MEINS"].ToString(),
                        Factory        = i["WERKS"].ToString(),
                        IssueWarehouse = new INV.Hisense.Warehouses.Warehouses.Warehouse {
                            Code = i["LGORT"].ToString()
                        },
                        //Warehouse = i["LGORT"].ToString(),
                    };
                    bill.YfWipIssueBillDetailList.Add(billDtl);
                }
                lst.Add(bill);
            }
            return(lst);
        }
示例#11
0
        private static List <WorkOrder> ERP_Get_Onhand(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <WorkOrder>();
            //RFC调用函数名
            string funcName = "ZMM_GETSTOCK_QTY";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            //DataTable export = new DataTable();
            //export.TableName = "Export";
            //export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            //ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "ZSTOCK";
            odt1.Columns.Add(new DataColumn("WERKS", typeof(string))); //工厂
            odt1.Columns.Add(new DataColumn("LGORT", typeof(string))); //仓位
            odt1.Columns.Add(new DataColumn("MATNR", typeof(string))); //物料号
            odt1.Columns.Add(new DataColumn("LIFNR", typeof(string))); //供应商编码
            odt1.Columns.Add(new DataColumn("SOBKZ", typeof(string))); //特殊库存  特殊库存标志(SOBKZ==K时,再看LGORT是否包含J,若包含J则是JIT物料,否则是客供。SOBKZ不等于K则是正常物料。)
            odt1.Columns.Add(new DataColumn("LABST", typeof(string))); //UU库存
            odt1.Columns.Add(new DataColumn("INSME", typeof(string))); //QI库存
            odt1.Columns.Add(new DataColumn("SPEME", typeof(string))); //冻结库存
            //odt1.Columns.Add(new DataColumn("GUANBI", typeof(string)));//物料类型


            ods.Tables.Add(odt1);
            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["ZSTOCK"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string factory    = dt.Rows[i]["WERKS"].ToString(); //工厂
                string warehouse  = dt.Rows[i]["LGORT"].ToString(); //仓位
                string itemCode   = dt.Rows[i]["MATNR"].ToString(); //物料编号
                string supplier   = dt.Rows[i]["LIFNR"].ToString(); //供应商编码
                double k_qty      = 0;
                double uu_qty     = 0;
                double qi_qty     = 0;
                double freeze_qty = 0;
                double.TryParse(dt.Rows[i]["SOBKZ"].ToString(), out k_qty);      //特殊库存
                double.TryParse(dt.Rows[i]["LABST"].ToString(), out uu_qty);     //UU库存
                double.TryParse(dt.Rows[i]["INSME"].ToString(), out qi_qty);     //QI库存
                double.TryParse(dt.Rows[i]["SPEME"].ToString(), out freeze_qty); //冻结库存


                var model = new WorkOrder()
                {
                };

                lst.Add(model);
            }
            return(lst);
        }
示例#12
0
        private static List <WxWipIssueBill> ERP_MES_WX(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <WxWipIssueBill>();
            //RFC调用函数名
            string funcName = "ZWMS_WXFLD";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //消息文本
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("ZBLNR", typeof(string))); //单号
            odt1.Columns.Add(new DataColumn("LIFNR", typeof(string))); //供应商
            odt1.Columns.Add(new DataColumn("LGORT", typeof(string))); //库存地点
            odt1.Columns.Add(new DataColumn("WERKS", typeof(string))); //工厂
            odt1.Columns.Add(new DataColumn("MATNR", typeof(string))); //物料号
            odt1.Columns.Add(new DataColumn("ZXLSL", typeof(string))); //数量
            odt1.Columns.Add(new DataColumn("CHARG", typeof(string))); //批号
            odt1.Columns.Add(new DataColumn("MEINS", typeof(string))); //基本计量单位
            ods.Tables.Add(odt1);

            //DataTable odt2 = new DataTable();
            //odt2.TableName = "T_TAB2";
            //odt2.Columns.Add(new DataColumn("ZBLNR", typeof(string)));//单号
            //odt2.Columns.Add(new DataColumn("LIFNR", typeof(string)));//供应商
            //ods.Tables.Add(odt2);


            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑

            var dtItem = ods.Tables["T_TAB"];
            var view   = dtItem.DefaultView;
            var dtHead = view.ToTable("T_HEAD", true, "ZBLNR", "LIFNR");

            foreach (DataRow h in dtHead.Rows)
            {
                var bill = new WxWipIssueBill();

                bill.No       = h["ZBLNR"].ToString().Trim();
                bill.Supplier = new BD.Suppliers.Supplier()
                {
                    Code = h["LIFNR"].ToString()
                };


                foreach (DataRow i in dtItem.AsEnumerable().Where(p => h["ZBLNR"].ToString() == p["ZBLNR"].ToString()))
                {
                    var billDtl = new WxWipIssueBillDetail()
                    {
                        Item = new Item {
                            Code = i["MATNR"].ToString()
                        },
                        //ProjectNo = i["EBELP"].ToString(),
                        Qty            = Convert.ToDouble(i["ZXLSL"] ?? 0),
                        Unit           = i["MEINS"].ToString(),
                        Factory        = i["WERKS"].ToString(),
                        BatchNo        = i["CHARG"].ToString(),
                        IssueWarehouse = new INV.Hisense.Warehouses.Warehouses.Warehouse {
                            Code = i["LGORT"].ToString()
                        },
                        //PickWarehouse = new INV.Hisense.Warehouses.Warehouses.Warehouse { Code = i["LGORT"].ToString() },
                    };
                    bill.WxWipIssueBillDetailList.Add(billDtl);
                }
                lst.Add(bill);
            }
            return(lst);
        }
示例#13
0
文件: RFC_Org.cs 项目: tvrjcf/Demo
        private static List <Organization> ERP_MES_Org(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst   = new List <Organization>();
            var group = DomainControllerFactory.Create <OrganizationController>().GetList(1).Concrete().FirstOrDefault();
            //RFC调用函数名
            string funcName = "ZWMS_T001W";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //处理标识
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("ORGID", typeof(string)));      //组织编码
            odt1.Columns.Add(new DataColumn("ORGNAME", typeof(string)));    //组织名称
            odt1.Columns.Add(new DataColumn("PR_ORGID", typeof(string)));   //上层编码
            odt1.Columns.Add(new DataColumn("PR_ORGNAME", typeof(string))); //上层名称
            odt1.Columns.Add(new DataColumn("WTYPE", typeof(string)));      //组织类型
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_TAB"];

            //for (int i = 0; i < dt.Rows.Count; i++)
            foreach (DataRow organ in ods.Tables["T_TAB"].Rows)
            {
                //string code = dt.Rows[i]["ORGID"].ToString();
                //string name = dt.Rows[i]["ORGNAME"].ToString();
                //string prCode = dt.Rows[i]["WERKS"].ToString();
                //string prName = dt.Rows[i]["NAME1"].ToString();
                //string type = dt.Rows[i]["WTYPE"].ToString();
                string code   = organ["ORGID"].ToString();
                string name   = organ["ORGNAME"].ToString();
                string prCode = organ["PR_ORGID"].ToString();
                string prName = organ["PR_ORGNAME"].ToString();
                string type   = organ["WTYPE"].ToString().Trim();

                var org = new Organization()
                {
                    Code       = code,
                    Name       = name,
                    CreateBy   = PlatformEnvironment.IdentityId,
                    CreateDate = DateTime.Now,
                    InvOrgId   = PlatformEnvironment.InvOrgId
                };
                if (type == "公司")
                {
                    org.LevelId = 1;
                }
                else if (type == "工厂")
                {
                    org.LevelId    = 2;
                    org.TreeParent = group;
                }
                lst.Add(org);
            }
            return(lst);
        }
示例#14
0
文件: RFC_Mo.cs 项目: tvrjcf/Demo
        private static List <WorkOrder> ERP_Get_Mo(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <WorkOrder>();
            //RFC调用函数名
            string funcName = "ZWMS_MO";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            odt1.Columns.Add(new DataColumn("WERKS", typeof(string)));  //工厂
            odt1.Columns.Add(new DataColumn("AUFNR", typeof(string)));  //订单号
            odt1.Columns.Add(new DataColumn("PLNBEZ", typeof(string))); //物料号
            odt1.Columns.Add(new DataColumn("MAKTX", typeof(string)));  //物料描述(短文本)
            odt1.Columns.Add(new DataColumn("GAMNG", typeof(string)));  //订单数量
            odt1.Columns.Add(new DataColumn("VAPLZ", typeof(string)));  //维护任务的工作中心
            odt1.Columns.Add(new DataColumn("LGORT", typeof(string)));  //收货库存地点
            odt1.Columns.Add(new DataColumn("FTRMS", typeof(string)));  //计划下达日期
            odt1.Columns.Add(new DataColumn("FTRMI", typeof(string)));  //实际下达日期
            odt1.Columns.Add(new DataColumn("AUART", typeof(string)));  //订单类型
            odt1.Columns.Add(new DataColumn("ERDAT", typeof(string)));  //创建日期
            odt1.Columns.Add(new DataColumn("VERID", typeof(string)));  //生产版本
            odt1.Columns.Add(new DataColumn("GUANBI", typeof(string))); //是否关闭
            odt1.Columns.Add(new DataColumn("BEIZHU", typeof(string))); //备注
            odt1.Columns.Add(new DataColumn("WEMPF", typeof(string)));  //车间
            odt1.Columns.Add(new DataColumn("STATE", typeof(string)));  //状态

            ods.Tables.Add(odt1);
            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["T_TAB"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string factory       = dt.Rows[i]["WERKS"].ToString();                    //工厂
                string work_order_no = dt.Rows[i]["AUFNR"].ToString();                    //工单号
                string item_code     = dt.Rows[i]["PLNBEZ"].ToString();                   //物料编号
                string work_center   = dt.Rows[i]["VAPLZ"].ToString();                    //工作中心
                string version       = dt.Rows[i]["VERID"].ToString();                    //生产版本
                double order_qty     = 0;
                double.TryParse(dt.Rows[i]["GAMNG"].ToString(), out order_qty);           //订单数量

                string   storage_location = dt.Rows[i]["LGORT"].ToString();               //库存地点
                DateTime plan_release_date;
                DateTime.TryParse(dt.Rows[i]["FTRMS"].ToString(), out plan_release_date); //计划下达日期
                DateTime act_begin_date;
                DateTime.TryParse(dt.Rows[i]["FTRMI"].ToString(), out act_begin_date);    //实际下达日期
                string   work_order_type = dt.Rows[i]["AUART"].ToString();                //订单类型
                DateTime create_date;
                DateTime.TryParse(dt.Rows[i]["ERDAT"].ToString(), out create_date);       //创建日期
                bool   closed   = dt.Rows[i]["GUANBI"].ToString().IsNullOrEmpty() ? false : true;
                string bz       = dt.Rows[i]["BEIZHU"].ToSafeString();                    //备注
                string sapState = dt.Rows[i]["STATE"].ToSafeString();                     //sap状态
                string workShop = dt.Rows[i]["WEMPF"].ToSafeString();                     //车间

                //var model = new WorkOrder()
                //{
                //    Factory = factory,
                //    WorkOrderNo = work_order_no,
                //    Item = new BD.Items.Item { Code = item_code },
                //    Workshop = new BD.Organizations.Organization { Code = workShop },
                //    OrderQty = (int)order_qty,
                //    ReceiptWarehouse = new INV.Hisense.Warehouses.Warehouses.Warehouse { Code = storage_location },
                //    PlanBeginDate = plan_release_date,
                //    ActuFinishDate = act_begin_date,
                //    S_Type = work_order_type,
                //    CreateDate = create_date,
                //    ProductVersion = version,
                //    Remark = bz,
                //    IsClosed = closed,
                //    Status = sapState.Contains("TECO") ? BD.WorkOrders.WorkOrderStatus.Close : BD.WorkOrders.WorkOrderStatus.Release
                //};

                //lst.Add(model);
            }
            return(lst);
        }
示例#15
0
        private static List <WorkOrder> ERP_Get_Onhand(Hashtable import, DataSet ids)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <WorkOrder>();
            //RFC调用函数名
            string funcName = "Z_RFC_GET_INVENTORY";
            //传输传给RFC函数的DataSet
            //DataSet ids = new DataSet();

            ////工厂
            //DataTable idt1 = new DataTable();
            //idt1.TableName = "T_WERKS";
            //idt1.Columns.Add("WERKS");
            //idt1.Rows.Add(idt1.NewRow());
            //idt1.Rows[0][0] = "4233";
            //ids.Tables.Add(idt1);

            //仓库
            //DataTable idt2 = new DataTable();
            //idt2.TableName = "T_LGORT";
            //idt2.Columns.Add("LOC");
            //idt2.Rows.Add(idt2.NewRow());
            //idt2.Rows[0][0] = "A001";
            //idt2.Rows.Add(idt2.NewRow());
            //idt2.Rows[1][0] = "H001";
            //idt2.Rows.Add(idt2.NewRow());
            //idt2.Rows[2][0] = "WA09";
            //ids.Tables.Add(idt2);

            //物料
            //DataTable idt3 = new DataTable();
            //idt3.TableName = "T_MATNR";
            //idt3.Columns.Add("MAT");
            //idt3.Rows.Add(idt3.NewRow());
            //idt3.Rows[0][0] = "1030020101";
            //ids.Tables.Add(idt3);

            //供应商
            //DataTable idt4 = new DataTable();
            //idt4.TableName = "T_VENDOR";
            //idt4.Columns.Add("VENDOR");
            //idt4.Rows.Add(idt4.NewRow());
            //idt4.Rows[0][0] = "";
            //ids.Tables.Add(idt4);

            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            //DataTable export = new DataTable();
            //export.TableName = "Export";
            //export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            //ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "ET_STOCK";
            odt1.Columns.Add(new DataColumn("WERKS", typeof(string)));   //工厂
            odt1.Columns.Add(new DataColumn("LGORT", typeof(string)));   //仓位
            odt1.Columns.Add(new DataColumn("MATNR", typeof(string)));   //物料
            odt1.Columns.Add(new DataColumn("MAKTX", typeof(string)));   //物料描述
            odt1.Columns.Add(new DataColumn("LIFNR", typeof(string)));   //供应商编码
            //odt1.Columns.Add(new DataColumn("SOBKZ", typeof(string)));//特殊库存  特殊库存标志(SOBKZ==K时,再看LGORT是否包含J,若包含J则是JIT物料,否则是客供。SOBKZ不等于K则是正常物料。)
            odt1.Columns.Add(new DataColumn("LABST", typeof(string)));   //UU库存
            odt1.Columns.Add(new DataColumn("INSME", typeof(string)));   //QI库存
            odt1.Columns.Add(new DataColumn("SPEME", typeof(string)));   //冻结库存
            odt1.Columns.Add(new DataColumn("STOCK_T", typeof(string))); //库存类型


            ods.Tables.Add(odt1);
            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, new Hashtable(), ids, ref ods);
            //根据RFC执行后返回的数据处理业务逻辑
            DataTable dt = ods.Tables["ET_STOCK"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string factory    = dt.Rows[i]["WERKS"].ToString(); //工厂
                string warehouse  = dt.Rows[i]["LGORT"].ToString(); //仓位
                string itemCode   = dt.Rows[i]["MATNR"].ToString(); //物料编号
                string supplier   = dt.Rows[i]["LIFNR"].ToString(); //供应商编码
                double k_qty      = 0;
                double uu_qty     = 0;
                double qi_qty     = 0;
                double freeze_qty = 0;
                //double.TryParse(dt.Rows[i]["SOBKZ"].ToString(), out k_qty);//特殊库存
                double.TryParse(dt.Rows[i]["LABST"].ToString(), out uu_qty);     //UU库存
                double.TryParse(dt.Rows[i]["INSME"].ToString(), out qi_qty);     //QI库存
                double.TryParse(dt.Rows[i]["SPEME"].ToString(), out freeze_qty); //冻结库存


                var model = new WorkOrder()
                {
                };

                lst.Add(model);
            }
            return(lst);
        }
示例#16
0
        private static List <Item> ERP_Get_Item(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <Item>();
            //RFC调用函数名
            string funcName = "ZWMS_MARA";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //处理标识
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_ITEM";
            odt1.Columns.Add(new DataColumn("MATNR", typeof(string)));     //物料代码
            odt1.Columns.Add(new DataColumn("MAKTX", typeof(string)));     //物料描述
            odt1.Columns.Add(new DataColumn("MEINS", typeof(string)));     //基本单位
            odt1.Columns.Add(new DataColumn("MATKL", typeof(string)));     //物料组
            odt1.Columns.Add(new DataColumn("WGBEZ", typeof(string)));     //物料组名称
            odt1.Columns.Add(new DataColumn("MTART", typeof(string)));     //物料类型
            odt1.Columns.Add(new DataColumn("DEL_FLG", typeof(string)));   //删除标志
            odt1.Columns.Add(new DataColumn("CR_DATE", typeof(string)));   //创建日期
            odt1.Columns.Add(new DataColumn("MDF_DATE", typeof(string)));  //修改日期
            odt1.Columns.Add(new DataColumn("ZKHJX", typeof(string)));     //客户型号
            odt1.Columns.Add(new DataColumn("ZJCXH", typeof(string)));     //基本型号
            odt1.Columns.Add(new DataColumn("ZNM", typeof(string)));       //内码
            odt1.Columns.Add(new DataColumn("ZFMATNR", typeof(string)));   //成品替代料
            odt1.Columns.Add(new DataColumn("ZZMATNR", typeof(string)));   //MDM物料编码
            odt1.Columns.Add(new DataColumn("ZCATEGORY", typeof(string))); //品类(小)
            ods.Tables.Add(odt1);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);

            //根据RFC执行后返回的数据处理业务逻辑

            foreach (DataRow item in ods.Tables["T_ITEM"].Rows)
            //for (int i = 0; i < dt.Rows.Count; i++)
            {
                string code         = item["MATNR"].ToString();
                string desc         = item["MAKTX"].ToString().Trim();
                string unit         = item["MEINS"].ToString();
                string categoryCode = item["MATKL"].ToString();
                string categoryName = item["WGBEZ"].ToString();
                string type         = item["MTART"].ToString();
                State  state        = item["MTART"].ToString() != "4" ? State.Enable : State.Disable;
                //DateTime crateDate = item["CR_DATE"].ToString() == "0000-00-00" ? Convert.ToDateTime("1900-1-1") : Convert.ToDateTime(item["CR_DATE"].ToString());
                //DateTime _MDF_DATE = item["MDF_DATE"].ToString() == "0000-00-00" ? (item["CR_DATE"].ToString() == "0000-0-0" ? Convert.ToDateTime("1900-1-1") : _CR_DATE) : Convert.ToDateTime(item["MDF_DATE"].ToString());
                var newItem = new Item
                {
                    Code            = code,
                    Name            = desc,
                    Description     = desc,
                    MeasurementUnit = unit,
                    Category        = new ItemSmallCategory {
                        Code = categoryCode, Name = categoryName
                    },
                    ItemType      = type,
                    State         = state,
                    CustomerType  = item["ZKHJX"].ToString(),
                    BaseModel     = item["ZJCXH"].ToString(),
                    InerCode      = item["ZNM"].ToString(),
                    ReplaceItem   = item["ZFMATNR"].ToString(),
                    MdmItemCode   = item["ZZMATNR"].ToString(),
                    SmallCategory = item["ZCATEGORY"].ToString(),
                };
                lst.Add(newItem);
            }
            return(lst);
        }
示例#17
0
文件: RFC_MoBom.cs 项目: tvrjcf/Demo
        private static List <WorkOrderBom> ERP_MES_MoBom(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <WorkOrderBom>();
            //RFC调用函数名
            string funcName = "ZWMS_MOBOM";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTYPE", typeof(string))); //处理标识
            export.Columns.Add(new DataColumn("RTMSG", typeof(string))); //消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_TAB";
            // odt1.Columns.Add(new DataColumn("WERKS", typeof(string)));//工厂
            odt1.Columns.Add(new DataColumn("AUFNR", typeof(string))); //工单号
            odt1.Columns.Add(new DataColumn("MATNR", typeof(string))); //产品代码

            odt1.Columns.Add(new DataColumn("IDNRK", typeof(string))); //BOM 组件
            odt1.Columns.Add(new DataColumn("MAKTX", typeof(string))); //物料描述
            odt1.Columns.Add(new DataColumn("NOMNG", typeof(string))); //定额消耗数量
            odt1.Columns.Add(new DataColumn("ERFMG", typeof(string))); //组件数量
            odt1.Columns.Add(new DataColumn("MEINS", typeof(string))); //组件计量单位
            odt1.Columns.Add(new DataColumn("LGORT", typeof(string))); //库存地点发料
            odt1.Columns.Add(new DataColumn("XLOEK", typeof(string))); //删除标志
            odt1.Columns.Add(new DataColumn("RGEKZ", typeof(string))); //是否反冲
            ods.Tables.Add(odt1);
            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);

            //根据RFC执行后返回的数据处理业务逻辑
            foreach (DataRow h in ods.Tables["T_TAB"].Rows)
            {
                if (h["XLOEK"].ToString().Trim().ToUpper() == "X")
                {
                    continue;
                }
                string mo        = h["AUFNR"].ToString();
                string item_code = h["IDNRK"].ToString();
                string qty       = h["ERFMG"].ToString();
                string singe_qty = h["NOMNG"].ToString();
                string warehouse = h["LGORT"].ToString();
                string unit      = h["MEINS"].ToString();

                var bom = new WorkOrderBom();
                bom.WorkOrder = new WorkOrder {
                    WorkOrderNo = mo
                };
                bom.Item = new Item {
                    Code = item_code
                };
                bom.RequireQty      = Convert.ToDouble(qty);
                bom.SingleQty       = Convert.ToDouble(singe_qty);
                bom.SourceWarehouse = new Warehouse {
                    Code = warehouse
                };
                bom.Unit         = unit;
                bom.IsRecoilItem = h["RGEKZ"].ToString().Trim().ToUpper() == "X";
                lst.Add(bom);
            }
            return(lst);
        }
示例#18
0
        private static List <PurchaseOrder> ERP_MES_Po(Hashtable import)
        {
            RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString());
            //RFC rfc = new RFC("SAPTest");
            var lst = new List <PurchaseOrder>();
            //RFC调用函数名
            string funcName = "ZWMS_PO";
            //传输传给RFC函数的DataSet
            DataSet ids = new DataSet();
            //构建RFC传入表DataTable

            //返回数据的DataSet框架
            DataSet ods = new DataSet();
            //构建Export参数DataTable
            DataTable export = new DataTable();

            export.TableName = "Export";
            export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本
            ods.Tables.Add(export);
            //构建RFC传出表DataTable
            DataTable odt1 = new DataTable();

            odt1.TableName = "T_EKKO";
            odt1.Columns.Add(new DataColumn("BUKRS", typeof(string)));   //公司代码
            odt1.Columns.Add(new DataColumn("EBELN", typeof(string)));   //采购凭证号
            odt1.Columns.Add(new DataColumn("LIFNR", typeof(string)));   //供应商或债权人的帐号
            odt1.Columns.Add(new DataColumn("ZADRESS", typeof(string))); //地址
            odt1.Columns.Add(new DataColumn("SSQSS", typeof(string)));   //质检控制码
            odt1.Columns.Add(new DataColumn("AEDAT", typeof(string)));   //记录的创建日期
            odt1.Columns.Add(new DataColumn("LAND1", typeof(string)));   //国家代码
            odt1.Columns.Add(new DataColumn("ORT01", typeof(string)));   //城市
            odt1.Columns.Add(new DataColumn("ORT02", typeof(string)));   //地区
            odt1.Columns.Add(new DataColumn("STRAS", typeof(string)));   //住宅号及街道
            odt1.Columns.Add(new DataColumn("LANDX", typeof(string)));   //国家名称
            ods.Tables.Add(odt1);


            DataTable odt2 = new DataTable();

            odt2.TableName = "T_EKPO";
            odt2.Columns.Add(new DataColumn("EBELN", typeof(string))); //采购凭证号
            odt2.Columns.Add(new DataColumn("EBELP", typeof(string))); //采购凭证的项目编号
            odt2.Columns.Add(new DataColumn("MATNR", typeof(string))); //物料号
            odt2.Columns.Add(new DataColumn("SSQSS", typeof(string))); //质检控制码
            odt2.Columns.Add(new DataColumn("WERKS", typeof(string))); //工厂
            odt2.Columns.Add(new DataColumn("LGORT", typeof(string))); //库存地点
            odt2.Columns.Add(new DataColumn("MENGE", typeof(string))); //采购订单数量
            odt2.Columns.Add(new DataColumn("MEINS", typeof(string))); //采购订单的计量单位
            odt2.Columns.Add(new DataColumn("RETPO", typeof(string))); //退货标识 X为退货
            odt2.Columns.Add(new DataColumn("PSTYP", typeof(string))); //采购项目类别
            odt2.Columns.Add(new DataColumn("INSMK", typeof(string))); //库存类型
            odt2.Columns.Add(new DataColumn("WAMNG", typeof(string))); //发货数量
            odt2.Columns.Add(new DataColumn("LOEKZ", typeof(string))); //删除标记
            odt2.Columns.Add(new DataColumn("ELIKZ", typeof(string))); //交货完成(接收完成)
            ods.Tables.Add(odt2);

            //执行RFC函数
            bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods);

            //根据RFC执行后返回的数据处理业务逻辑
            //DataTable dt = ods.Tables["T_ITEM"];
            foreach (DataRow h in ods.Tables["T_EKKO"].Rows)
            {
                var    po      = new PurchaseOrder();
                string address = h["ZADRESS"].ToString();
                po.PoNumber = h["EBELN"].ToString();
                po.Supplier = new BD.Suppliers.Supplier {
                    Code = h["LIFNR"].ToString()
                };
                po.CountryCode = h["LAND1"].ToString();
                po.CountryName = h["LANDX"].ToString();
                po.City        = h["ORT01"].ToString();
                po.Area        = h["ORT02"].ToString();
                po.Street      = h["STRAS"].ToString();
                po.CreateDate  = Convert.ToDateTime(h["AEDAT"].ToString());
                foreach (DataRow i in ods.Tables["T_EKPO"].AsEnumerable().Where(p => h["EBELN"].ToString() == p["EBELN"].ToString()))
                {
                    var poDetail = new PurchaseOrderDetail()
                    {
                        IqcFlag = i["SSQSS"].ToString().Trim(),
                        Item    = new Item {
                            Code = i["MATNR"].ToString()
                        },
                        ProjectNo      = i["EBELP"].ToString().Trim(),
                        Quantity       = Convert.ToDouble(i["MENGE"] ?? 0),
                        Unit           = i["MEINS"].ToString(),
                        Factory        = i["WERKS"].ToString(),
                        Warehouse      = i["LGORT"].ToString(),
                        PurchaseType   = (PurchaseType?)Convert.ToInt32(i["PSTYP"]),
                        IsReturn       = i["RETPO"].ToString().ToUpper() == "X",
                        ErpReceivedQty = Convert.ToDouble(i["WAMNG"] ?? 0),
                        State          = i["ELIKZ"].ToString().ToUpper() == "X" ? PoState.Received : PoState.New,
                    };
                    po.PurchaseOrderDetailList.Add(poDetail);
                }
                lst.Add(po);
            }
            return(lst);
        }