// *** 初始化数据 结束 // **************************************** // 采购需求计算 public string Calculate_Demand(string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, string f1, string db) { string json = ""; using (zcscdb4Entities zcscdb4 = new zcscdb4Entities()) { string sql = "select dbo.s_me007('1', '" + s1 + "', '" + s2 + "', '" + s3 + "', '" + s4 + "', '" + s5 + "', '" + s6 + "', '" + s7 + "', '" + s8 + "', '', '', '', '', '', '', '', '', '', '', '', '', ' ''0101'',''0102'' ', '', '', '', '" + db + "')"; var sql1 = zcscdb4.Database.SqlQuery <string>(sql).FirstOrDefault(); if (sql1 != null) { var rs = zcscdb4.Database.SqlQuery <Perchase_Demand>(sql1); json = JsonConvert.SerializeObject(rs); } } return(json); }
// 采购单 转 工厂销售单 public string v2f(string db, string[] ccodes) { string msg = ""; string success = ""; string error = ""; using (zcscdb4Entities zcscdb4 = new zcscdb4Entities()) { // wcf服务准备 Add_Tiptop_cxmt410Client act = new Add_Tiptop_cxmt410Client(); // 循环每个订单 foreach (string ccode in ccodes) { // 存储过程sp_me01 string sql = "select dbo.sp_me01('21','','','" + db + "','" + ccode + "','','','','','','','','','','')"; var rs = zcscdb4.Database.SqlQuery <zcscdb4_sp_me01_21>(sql).AsEnumerable().ToList(); // 转DataTable - dt Type elementType = typeof(zcscdb4_sp_me01_21); //var ds = new DataSet(); var dt = new DataTable(); //ds.Tables.Add(t); elementType.GetProperties().ToList().ForEach(propInfo => dt.Columns.Add(propInfo.Name, Nullable.GetUnderlyingType(propInfo.PropertyType) ?? propInfo.PropertyType)); foreach (zcscdb4_sp_me01_21 item in rs) { var row = dt.NewRow(); elementType.GetProperties().ToList().ForEach(propInfo => row[propInfo.Name] = propInfo.GetValue(item, null) ?? DBNull.Value); dt.Rows.Add(row); } // wcf服务参数准备 DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); dt1 = dt.Clone(); dt2 = dt.Copy(); dt1.TableName = "oea_file"; dt2.TableName = "oeb_file"; foreach (DataRow dr in dt2.Rows) { dt1.ImportRow(dr); break; } // wcf 服务执行 try { act.Add(dt1, dt2); success += ccode + "、"; } catch (Exception ex) { new SaveError(ex, o, o, o, o, o, db, ccode); error += ccode + "、"; } } act.Close(); msg = "成功:" + success + "/n\n<br />失败:" + error; } return(msg); }