SystemModuleLogicPartial.cs 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:SystemModuleLogic.cs
  5. * 2.功能描述:产品档案数据查询处理
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/09/12 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Text;
  14. using Dongke.IBOSS.PRD.Basics.DataAccess;
  15. using Dongke.IBOSS.PRD.Service.DataModels;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Oracle.DataAccess.Client;
  18. namespace Dongke.IBOSS.PRD.Service.SystemModuleLogic
  19. {
  20. /// <summary>
  21. /// 产品档案数据查询处理
  22. /// </summary>
  23. public partial class SystemModuleLogic
  24. {
  25. #region 产品档案
  26. /// <summary>
  27. /// 查询产品信息
  28. /// </summary>
  29. /// <param name="sUserInfo">用户基本信息</param>
  30. /// <param name="goodsEntity">产品信息</param>
  31. /// <returns>DataSet</returns>
  32. /// <remarks>
  33. /// 陈冰 2014.09.01 新建
  34. /// </remarks>
  35. public static DataSet SerachGoods(SUserInfo sUserInfo, GoodsEntity goodsEntity)
  36. {
  37. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  38. try
  39. {
  40. con.Open();
  41. if (!string.IsNullOrWhiteSpace(goodsEntity.GoodsCodeOnly))
  42. {
  43. string sql = "select goodsid from tp_mst_goods g where g.goodscode = :goodscode";
  44. OracleParameter[] paras1 = new OracleParameter[]{
  45. new OracleParameter(":goodscode",OracleDbType.Varchar2,
  46. goodsEntity.GoodsCodeOnly,ParameterDirection.Input),
  47. };
  48. return con.GetSqlResultToDs(sql, paras1);
  49. }
  50. OracleParameter[] paras = new OracleParameter[]{
  51. new OracleParameter("account",OracleDbType.Int32,
  52. sUserInfo.AccountID,ParameterDirection.Input),
  53. new OracleParameter("goodsID",OracleDbType.Int32,
  54. goodsEntity.GoodsID,ParameterDirection.Input),
  55. new OracleParameter("goodsCode",OracleDbType.NVarchar2,
  56. goodsEntity.GoodsCode,ParameterDirection.Input),
  57. new OracleParameter("goodsName",OracleDbType.NVarchar2,
  58. goodsEntity.GoodsName,ParameterDirection.Input),
  59. new OracleParameter("goodsSpecification",OracleDbType.NVarchar2,
  60. goodsEntity.GoodsSpecification,ParameterDirection.Input),
  61. new OracleParameter("goodsModel",OracleDbType.NVarchar2,
  62. goodsEntity.GoodsModel,ParameterDirection.Input),
  63. new OracleParameter("goodsTypeCode",OracleDbType.NVarchar2,
  64. goodsEntity.GoodsTypeCode,ParameterDirection.Input),
  65. new OracleParameter("glazeTypeID",OracleDbType.Int32,
  66. goodsEntity.GlazeTypeID,ParameterDirection.Input),
  67. new OracleParameter("ceaseFlag",OracleDbType.NVarchar2,
  68. goodsEntity.CeaseFlag,ParameterDirection.Input),
  69. new OracleParameter("remarks",OracleDbType.NVarchar2,
  70. goodsEntity.Remarks,ParameterDirection.Input),
  71. new OracleParameter("valueFlag",OracleDbType.NVarchar2,
  72. goodsEntity.ValueFlag,ParameterDirection.Input),
  73. new OracleParameter("rs_result",OracleDbType.RefCursor,ParameterDirection.Output),
  74. new OracleParameter("rs_result_img",OracleDbType.RefCursor,ParameterDirection.Output),
  75. };
  76. foreach (OracleParameter item in paras)
  77. {
  78. if (item.Value + "" == "")
  79. {
  80. item.Value = DBNull.Value;
  81. }
  82. }
  83. DataSet ds = con.ExecStoredProcedure("PRO_MST_SerachGoods", paras);
  84. return ds;
  85. }
  86. catch (Exception ex)
  87. {
  88. throw ex;
  89. }
  90. finally
  91. {
  92. if (con.ConnState == ConnectionState.Open)
  93. {
  94. con.Close();
  95. }
  96. }
  97. }
  98. /// <summary>
  99. /// 新建产品档案
  100. /// </summary>
  101. /// <param name="sUserInfo">用户基本信息</param>
  102. /// <param name="goodsEntity">产品实体</param>
  103. /// <param name="imgList">产品图片集合</param>
  104. /// <param name="attList">缺陷位置ID集合</param>
  105. /// <returns>int受影响行数</returns>
  106. /// <remarks>
  107. /// 庄天威 2014.09.04 新建
  108. /// </remarks>
  109. public static int AddGoods(SUserInfo sUserInfo, GoodsEntity goodsEntity
  110. , List<GoodsImageEntity> imgList, List<GoodsAttachmentEntity> attList)
  111. {
  112. int returnRows;
  113. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  114. if (goodsEntity.MudQuantity == null)
  115. {
  116. goodsEntity.MudQuantity = 0;
  117. }
  118. if (goodsEntity.GlazeQuantity == null)
  119. {
  120. goodsEntity.GlazeQuantity = 0;
  121. }
  122. if (goodsEntity.Remarks == null)
  123. {
  124. goodsEntity.Remarks = "";
  125. }
  126. if (goodsEntity.GoodsSpecification == null)
  127. {
  128. goodsEntity.GoodsSpecification = "";
  129. }
  130. if (goodsEntity.GoodsModel == null)
  131. {
  132. goodsEntity.GoodsModel = "";
  133. }
  134. try
  135. {
  136. oracleTrConn.Connect();
  137. // 物料编码重复验证 add by chenxy 2017-07-11 begin
  138. // 有不同编码,同物料编码的情况 delete by chenxy 2017-11-10
  139. //string sqlString = "SELECT g.goodscode \n" +
  140. //" FROM tp_mst_goods g\n" +
  141. //" WHERE g.materialcode = :materialcode";
  142. //OracleParameter[] checkParas = new OracleParameter[]{
  143. // new OracleParameter(":materialcode",goodsEntity.MaterialCode),
  144. //};
  145. //string goodscode = oracleTrConn.GetSqlResultToStr(sqlString, checkParas);
  146. //if (!string.IsNullOrWhiteSpace(goodscode))
  147. //{
  148. // return -10;
  149. //}
  150. // 物料编码重复验证 add by chenxy 2017-07-11 end
  151. StringBuilder sbSql = new StringBuilder();
  152. sbSql.Append("select SEQ_MST_Goods_GoodsID.nextval from dual");
  153. int id = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  154. sbSql.Clear();
  155. sbSql.Append(" INSERT INTO TP_MST_GOODS");
  156. sbSql.Append("(GoodsID,GoodsCode,GoodsName,GoodsSpecification,GoodsModel,GoodsTypeID,");
  157. sbSql.Append("GlazeTypeID,MudWeight,GlazeWeight,LusterwareWeight,ProductionCycle,CeaseFlag,Goods_Line_Type,");
  158. sbSql.Append("StartingDate,AutoLossCycle,DeliverLimitCycle,PlateLimitNum,UnitPrice,ReservedDays,");
  159. sbSql.Append("PackageNum,OutletDistance,MaterialCode,MaterialRemark,printcopies,");
  160. sbSql.Append("MouldWeight,MouldCost,ScrapSumFlag,SEATCOVERCODE,");
  161. sbSql.Append("WaterLabelCode,StandardGroutingNum,MouldMaterialCode,MouldOutputCount,logoid,");
  162. sbSql.Append("Remarks,AccountID,ValueFlag,CreateUserID,UpdateUserID)");
  163. sbSql.Append("VALUES( :GoodsId, :GoodsCode, :GoodsName, :GoodsSpecification, :GoodsModel, :GoodsTypeID,");
  164. sbSql.Append(" :GlazeTypeID, :MudWeight, :GlazeWeight,:LusterwareWeight, :ProductionCycle, :CeaseFlag,:Goods_Line_Type,");
  165. sbSql.Append(" :StartingDate, :AutoLossCycle, :DeliverLimitCycle,:PlateLimitNum,:UnitPrice,:ReservedDays,");
  166. sbSql.Append(" :PackageNum, :OutletDistance, :MaterialCode,:MaterialRemark,:printcopies,");
  167. sbSql.Append(" :MouldWeight, :MouldCost,:ScrapSumFlag,:SEATCOVERCODE,");
  168. sbSql.Append(" :WaterLabelCode, :StandardGroutingNum, :MouldMaterialCode, :MouldOutputCount,:logoid,");
  169. sbSql.Append(" :Remarks, :AccountID, :ValueFlag, :CreateUserID, :UpdateUserID)");
  170. OracleParameter[] paras = new OracleParameter[]{
  171. new OracleParameter(":GoodsId",id),
  172. new OracleParameter(":GoodsCode",goodsEntity.GoodsCode),
  173. new OracleParameter(":GoodsName",goodsEntity.GoodsName),
  174. new OracleParameter(":GoodsSpecification",goodsEntity.GoodsSpecification),
  175. new OracleParameter(":GoodsModel",goodsEntity.GoodsModel),
  176. new OracleParameter(":GoodsTypeID",goodsEntity.GoodsTypeID),
  177. new OracleParameter(":GlazeTypeID",goodsEntity.GlazeTypeID),
  178. new OracleParameter(":MudWeight",goodsEntity.MudQuantity),
  179. new OracleParameter(":GlazeWeight",goodsEntity.GlazeQuantity),
  180. new OracleParameter(":LusterwareWeight",goodsEntity.LusterwareWeight),
  181. new OracleParameter(":ProductionCycle",goodsEntity.ProductionCycle),
  182. new OracleParameter(":CeaseFlag",goodsEntity.CeaseFlag),
  183. new OracleParameter(":Goods_Line_Type",goodsEntity.GoodsLineType),
  184. new OracleParameter(":StartingDate",goodsEntity.StartingDate),
  185. new OracleParameter(":AutoLossCycle",goodsEntity.AutoLossCycle),
  186. new OracleParameter(":DeliverLimitCycle",goodsEntity.DeliverLimitCycle),
  187. new OracleParameter(":PlateLimitNum",goodsEntity.PlateLimitNum),
  188. new OracleParameter(":ReservedDays",goodsEntity.ReservedDays),
  189. new OracleParameter(":UnitPrice",goodsEntity.UnitPrice),
  190. new OracleParameter(":PackageNum",goodsEntity.PackageNum),
  191. new OracleParameter(":OutletDistance",goodsEntity.OutletDistance),
  192. new OracleParameter(":MaterialCode",goodsEntity.MaterialCode),
  193. new OracleParameter(":MouldWeight",goodsEntity.MouldWeight),
  194. new OracleParameter(":MouldCost",goodsEntity.MouldCost),
  195. new OracleParameter(":ScrapSumFlag",goodsEntity.ScrapSumFlag),
  196. new OracleParameter(":MaterialRemark",goodsEntity.MaterialRemark),
  197. new OracleParameter(":printcopies",goodsEntity.PrintCopies),
  198. new OracleParameter(":SEATCOVERCODE", goodsEntity.SeatCoverCode),
  199. new OracleParameter(":WaterLabelCode", goodsEntity.WaterLabelCode),
  200. new OracleParameter(":StandardGroutingNum", goodsEntity.StandardGroutingNum),
  201. new OracleParameter(":MouldMaterialCode", goodsEntity.MouldMaterialCode),
  202. new OracleParameter(":MouldOutputCount", goodsEntity.MouldOutputCount),
  203. new OracleParameter(":logoid", goodsEntity.LogoID),
  204. new OracleParameter(":Remarks",goodsEntity.Remarks),
  205. new OracleParameter(":AccountID",sUserInfo.AccountID),
  206. new OracleParameter(":ValueFlag",goodsEntity.ValueFlag),
  207. //new OracleParameter(":CreateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  208. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  209. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  210. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  211. //new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,DateTime.Now,ParameterDirection.Input)
  212. };
  213. returnRows = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), paras);
  214. //SAP物料信息
  215. string sql = "delete from TP_MST_GoodsLogoSAP where goodsid = " + id;
  216. returnRows += oracleTrConn.ExecuteNonQuery(sql);
  217. sql = "insert into TP_MST_GOODSLOGOSAP\n" +
  218. " (GOODSID, LOGOID, GOODSCODE, MATERIALCODE, MATERIALREMARK, CREATEUSERID, WaterLabelCode)\n" +
  219. "values\n" +
  220. " (:GOODSID, :LOGOID, :GOODSCODE, :MATERIALCODE, :MATERIALREMARK, :CREATEUSERID, :WaterLabelCode)";
  221. foreach (DataRow item in goodsEntity.SAPInfo.Rows)
  222. {
  223. string sapcode = item["MATERIALCODE"] + "";
  224. string sapremark = item["MATERIALREMARK"] + "";
  225. if (string.IsNullOrWhiteSpace(sapcode))
  226. {
  227. continue;
  228. }
  229. if (string.IsNullOrEmpty(sapremark))
  230. {
  231. sapremark = " ";
  232. }
  233. paras = new OracleParameter[]{
  234. new OracleParameter(":GOODSID",id),
  235. new OracleParameter(":LOGOID",item["LOGOID"]),
  236. new OracleParameter(":GOODSCODE",goodsEntity.GoodsCode),
  237. new OracleParameter(":MATERIALCODE",sapcode),
  238. new OracleParameter(":MATERIALREMARK",sapremark),
  239. new OracleParameter(":CREATEUSERID",sUserInfo.UserID),
  240. new OracleParameter(":WaterLabelCode",item["WaterLabelCode"]),
  241. };
  242. returnRows += oracleTrConn.ExecuteNonQuery(sql, paras);
  243. }
  244. //此处添加图片信息
  245. foreach (GoodsImageEntity img in imgList)
  246. {
  247. int imgReturn = 0;
  248. sbSql.Clear();
  249. sbSql.Append("select SEQ_MST_GoodsImage_ID.nextval from dual");
  250. int imgId = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  251. sbSql.Clear();
  252. sbSql.Append("Insert into TP_MST_GoodsImage");
  253. sbSql.Append("(GoodsImageID,GoodsID,Thumbnail,Image,AccountID,ValueFlag,");
  254. sbSql.Append("CreateUserID,UpdateUserID)");
  255. sbSql.Append(" VALUES(:GoodsImageID,:GoodsID,:Thumbnail,:Image,:AccountID,:ValueFlag,");
  256. sbSql.Append(":CreateUserID,:UpdateUserID)");
  257. OracleParameter[] imgParas = new OracleParameter[] {
  258. new OracleParameter(":GoodsImageID",OracleDbType.Int32,imgId,ParameterDirection.Input),
  259. new OracleParameter(":GoodsID",OracleDbType.Int32,id,ParameterDirection.Input),
  260. new OracleParameter(":Thumbnail",OracleDbType.Blob,img.Thumbnail,ParameterDirection.Input),
  261. new OracleParameter(":Image",OracleDbType.Blob,img.Image,ParameterDirection.Input),
  262. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  263. new OracleParameter(":ValueFlag",OracleDbType.Int32,img.ValueFlag,ParameterDirection.Input),
  264. //new OracleParameter(":CreateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  265. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  266. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  267. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  268. //new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,DateTime.Now,ParameterDirection.Input)
  269. };
  270. imgReturn = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), imgParas);
  271. }
  272. //此处添加产品附件
  273. //int AttReturn = AddAttachment(oracleTrConn, attList, id, sUserInfo);
  274. //此处添加缺陷位置关联
  275. //int dpCount = SaveGoodsDefectPosition(oracleTrConn, dpList, id, sUserInfo);
  276. oracleTrConn.Commit();
  277. oracleTrConn.Disconnect();
  278. }
  279. catch (Exception ex)
  280. {
  281. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  282. {
  283. oracleTrConn.Rollback();
  284. oracleTrConn.Disconnect();
  285. }
  286. throw ex;
  287. }
  288. return returnRows;
  289. }
  290. /// <summary>
  291. /// 修改产品档案
  292. /// </summary>
  293. /// <param name="sUserInfo">用户基本信息</param>
  294. /// <param name="goodsEntity">产品实体</param>
  295. /// <param name="imgList">产品图片集合</param>
  296. /// <param name="attList">缺陷位置ID集合</param>
  297. /// <returns>int受影响行数</returns>
  298. /// <remarks>
  299. /// 庄天威 2014.09.04 新建
  300. /// </remarks>
  301. public static int updateGoods(SUserInfo sUserInfo, GoodsEntity goodsEntity
  302. , List<GoodsImageEntity> imgList, List<GoodsAttachmentEntity> attList)
  303. {
  304. int returnRows = 0;
  305. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  306. if (goodsEntity.MudQuantity == null)
  307. {
  308. goodsEntity.MudQuantity = 0;
  309. }
  310. if (goodsEntity.GlazeQuantity == null)
  311. {
  312. goodsEntity.GlazeQuantity = 0;
  313. }
  314. if (goodsEntity.Remarks == null)
  315. {
  316. goodsEntity.Remarks = "";
  317. }
  318. if (goodsEntity.GoodsSpecification == null)
  319. {
  320. goodsEntity.GoodsSpecification = "";
  321. }
  322. if (goodsEntity.GoodsModel == null)
  323. {
  324. goodsEntity.GoodsModel = "";
  325. }
  326. try
  327. {
  328. oracleTrConn.Connect();
  329. // 物料编码重复验证 add by chenxy 2017-07-11 begin
  330. // 有不同编码,同物料编码的情况 delete by chenxy 2017-11-10
  331. //string sqlString = "SELECT g.goodscode \n" +
  332. //" FROM tp_mst_goods g\n" +
  333. //" WHERE g.materialcode = :materialcode and g.goodsid <> :goodsid";
  334. //OracleParameter[] checkParas = new OracleParameter[]{
  335. // new OracleParameter(":materialcode",goodsEntity.MaterialCode),
  336. // new OracleParameter(":goodsid",goodsEntity.GoodsID),
  337. //};
  338. //string goodscode = oracleTrConn.GetSqlResultToStr(sqlString, checkParas);
  339. //if (!string.IsNullOrWhiteSpace(goodscode))
  340. //{
  341. // return -10;
  342. //}
  343. // 物料编码重复验证 add by chenxy 2017-07-11 end
  344. StringBuilder sbSql = new StringBuilder();
  345. sbSql.Append("update TP_MST_GOODS");
  346. //sbSql.Append(" set GoodsCode=:GoodsCode,GoodsName=:GoodsName,GoodsSpecification=:GoodsSpecification,");
  347. sbSql.Append(" set GoodsName=:GoodsName,GoodsSpecification=:GoodsSpecification,");
  348. sbSql.Append(" GoodsModel=:GoodsModel,GoodsTypeID=:GoodsTypeID,GlazeTypeID=:GlazeTypeID,MudWeight=:MudWeight,");
  349. sbSql.Append(" GlazeWeight=:GlazeWeight,LusterwareWeight=:LusterwareWeight,ProductionCycle=:ProductionCycle,CeaseFlag=:CeaseFlag,Goods_Line_Type=:Goods_Line_Type,Remarks=:Remarks,");
  350. sbSql.Append(" StartingDate=:StartingDate, AutoLossCycle = :AutoLossCycle, DeliverLimitCycle=:DeliverLimitCycle, PlateLimitNum=:PlateLimitNum,");
  351. sbSql.Append(" UnitPrice=:UnitPrice,PackageNum=:PackageNum,OutletDistance=:OutletDistance,MaterialCode=:MaterialCode,MaterialRemark=:MaterialRemark,printcopies=:printcopies,");
  352. sbSql.Append(" MouldWeight=:MouldWeight, MouldCost=:MouldCost,ScrapSumFlag=:ScrapSumFlag, ReservedDays=:ReservedDays,SEATCOVERCODE=:SEATCOVERCODE,");
  353. sbSql.Append(" WaterLabelCode=:WaterLabelCode, StandardGroutingNum=:StandardGroutingNum,MouldMaterialCode=:MouldMaterialCode, MouldOutputCount=:MouldOutputCount,");
  354. sbSql.Append(" AccountID=:AccountID,ValueFlag=:ValueFlag,UpdateUserID=:UpdateUserID,logoid=:logoid");
  355. //sbSql.Append(" CreateTime=:CreateTime,CreateUserID=:CreateUserID ");
  356. sbSql.Append(" where GoodsID=:GoodsID and OPTimeStamp=:OPTimeStamp");
  357. OracleParameter[] paras = new OracleParameter[]{
  358. // new OracleParameter(":GoodsCode",goodsEntity.GoodsCode),
  359. new OracleParameter(":GoodsName",goodsEntity.GoodsName),
  360. new OracleParameter(":GoodsSpecification",goodsEntity.GoodsSpecification),
  361. new OracleParameter(":GoodsModel",goodsEntity.GoodsModel),
  362. new OracleParameter(":GoodsTypeID",goodsEntity.GoodsTypeID),
  363. new OracleParameter(":GlazeTypeID",goodsEntity.GlazeTypeID),
  364. new OracleParameter(":MudWeight",goodsEntity.MudQuantity),
  365. new OracleParameter(":GlazeWeight",goodsEntity.GlazeQuantity),
  366. new OracleParameter(":LusterwareWeight",goodsEntity.LusterwareWeight),
  367. new OracleParameter(":ProductionCycle",goodsEntity.ProductionCycle),
  368. new OracleParameter(":CeaseFlag",goodsEntity.CeaseFlag),
  369. new OracleParameter(":Goods_Line_Type",goodsEntity.GoodsLineType),
  370. new OracleParameter(":StartingDate",goodsEntity.StartingDate),
  371. new OracleParameter(":AutoLossCycle",goodsEntity.AutoLossCycle),
  372. new OracleParameter(":DeliverLimitCycle",goodsEntity.DeliverLimitCycle),
  373. new OracleParameter(":PlateLimitNum",goodsEntity.PlateLimitNum),
  374. new OracleParameter(":ReservedDays",goodsEntity.ReservedDays),
  375. new OracleParameter(":UnitPrice",goodsEntity.UnitPrice),
  376. new OracleParameter(":PackageNum",goodsEntity.PackageNum),
  377. new OracleParameter(":OutletDistance",goodsEntity.OutletDistance),
  378. new OracleParameter(":MaterialCode",goodsEntity.MaterialCode),
  379. new OracleParameter(":MouldWeight",goodsEntity.MouldWeight),
  380. new OracleParameter(":MouldCost",goodsEntity.MouldCost),
  381. new OracleParameter(":ScrapSumFlag",goodsEntity.ScrapSumFlag),
  382. new OracleParameter(":MaterialRemark",goodsEntity.MaterialRemark),
  383. new OracleParameter(":printcopies",goodsEntity.PrintCopies),
  384. new OracleParameter(":Remarks",goodsEntity.Remarks),
  385. new OracleParameter(":SEATCOVERCODE",goodsEntity.SeatCoverCode),
  386. new OracleParameter(":WaterLabelCode",goodsEntity.WaterLabelCode),
  387. new OracleParameter(":StandardGroutingNum",goodsEntity.StandardGroutingNum),
  388. new OracleParameter(":MouldMaterialCode",goodsEntity.MouldMaterialCode),
  389. new OracleParameter(":MouldOutputCount",goodsEntity.MouldOutputCount),
  390. new OracleParameter(":logoid", goodsEntity.LogoID),
  391. new OracleParameter(":AccountID",goodsEntity.AccountID),
  392. new OracleParameter(":ValueFlag",goodsEntity.ValueFlag),
  393. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  394. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  395. //new OracleParameter(":CreateTime",OracleDbType.Date,goodsEntity.CreateTime,ParameterDirection.Input),
  396. //new OracleParameter(":CreateUserID",goodsEntity.CreateUserID),
  397. new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,goodsEntity.OPTimeStamp,ParameterDirection.Input),
  398. new OracleParameter(":GoodsId",goodsEntity.GoodsID)
  399. };
  400. returnRows = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), paras);
  401. if (returnRows == 0)
  402. {
  403. oracleTrConn.Rollback();
  404. oracleTrConn.Disconnect();
  405. return -500;
  406. }
  407. //SAP物料信息
  408. string sql = "delete from TP_MST_GoodsLogoSAP where goodsid = " + goodsEntity.GoodsID;
  409. returnRows += oracleTrConn.ExecuteNonQuery(sql);
  410. sql = "insert into TP_MST_GOODSLOGOSAP\n" +
  411. " (GOODSID, LOGOID, GOODSCODE, MATERIALCODE, MATERIALREMARK, CREATEUSERID,WaterLabelCode)\n" +
  412. "values\n" +
  413. " (:GOODSID, :LOGOID, :GOODSCODE, :MATERIALCODE, :MATERIALREMARK, :CREATEUSERID,:WaterLabelCode)";
  414. foreach (DataRow item in goodsEntity.SAPInfo.Rows)
  415. {
  416. string sapcode = item["MATERIALCODE"] + "";
  417. string sapremark = item["MATERIALREMARK"] + "";
  418. if (string.IsNullOrWhiteSpace(sapcode))
  419. {
  420. continue;
  421. }
  422. if (string.IsNullOrEmpty(sapremark))
  423. {
  424. sapremark = " ";
  425. }
  426. paras = new OracleParameter[]{
  427. new OracleParameter(":GOODSID",goodsEntity.GoodsID),
  428. new OracleParameter(":LOGOID",item["LOGOID"]),
  429. new OracleParameter(":GOODSCODE",goodsEntity.GoodsCode),
  430. new OracleParameter(":MATERIALCODE",sapcode),
  431. new OracleParameter(":MATERIALREMARK",sapremark),
  432. new OracleParameter(":CREATEUSERID",sUserInfo.UserID),
  433. new OracleParameter(":WaterLabelCode",item["WaterLabelCode"]),
  434. };
  435. returnRows += oracleTrConn.ExecuteNonQuery(sql, paras);
  436. }
  437. foreach (GoodsImageEntity imgEntity in imgList)
  438. {
  439. if (imgEntity.GoodsImageID == 0)
  440. {
  441. int imgReturn = 0;
  442. sbSql.Clear();
  443. sbSql.Append("select SEQ_MST_GoodsImage_ID.nextval from dual");
  444. int imgId = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  445. sbSql.Clear();
  446. sbSql.Append("Insert into TP_MST_GoodsImage");
  447. sbSql.Append("(GoodsImageID,GoodsID,Thumbnail,Image,AccountID,ValueFlag,");
  448. sbSql.Append("CreateUserID,UpdateUserID)");
  449. sbSql.Append(" VALUES(:GoodsImageID,:GoodsID,:Thumbnail,:Image,:AccountID,:ValueFlag,");
  450. sbSql.Append(":CreateUserID,:UpdateUserID)");
  451. OracleParameter[] imgParas = new OracleParameter[] {
  452. new OracleParameter(":GoodsImageID",OracleDbType.Int32,imgId,ParameterDirection.Input),
  453. new OracleParameter(":GoodsID",OracleDbType.Int32,goodsEntity.GoodsID,ParameterDirection.Input),
  454. new OracleParameter(":Thumbnail",OracleDbType.Blob,imgEntity.Thumbnail,ParameterDirection.Input),
  455. new OracleParameter(":Image",OracleDbType.Blob,imgEntity.Image,ParameterDirection.Input),
  456. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  457. new OracleParameter(":ValueFlag",OracleDbType.Int32,imgEntity.ValueFlag,ParameterDirection.Input),
  458. //new OracleParameter(":CreateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  459. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  460. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  461. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  462. //new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,DateTime.Now,ParameterDirection.Input)
  463. };
  464. imgReturn = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), imgParas);
  465. }
  466. else
  467. {
  468. int imgReturn = 0;
  469. sbSql.Clear();
  470. sbSql.Append(" update TP_MST_GoodsImage");
  471. sbSql.Append(" set GoodsID=:GoodsID,AccountID=:AccountID,ValueFlag=:ValueFlag,");
  472. sbSql.Append(" UpdateUserID=:UpdateUserID");
  473. //sbSql.Append(" where GoodsImageID=:GoodsImageID And OPTimeStamp=to_date(:OPTimeStamp,'yyyy-mm-dd HH24:mi:ss')");
  474. sbSql.Append(" where GoodsImageID=:GoodsImageID");
  475. OracleParameter[] imgParas = new OracleParameter[] {
  476. new OracleParameter(":GoodsID",OracleDbType.Int32,
  477. goodsEntity.GoodsID,ParameterDirection.Input),
  478. new OracleParameter(":AccountID",OracleDbType.Int32,
  479. imgEntity.AccountID,ParameterDirection.Input),
  480. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  481. imgEntity.ValueFlag,ParameterDirection.Input),
  482. //new OracleParameter(":UpdateTime",OracleDbType.NVarchar2,
  483. // DateTime.Now.ToString(),ParameterDirection.Input),
  484. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  485. sUserInfo.UserID,ParameterDirection.Input),
  486. new OracleParameter(":GoodsImageID",OracleDbType.Int32,
  487. imgEntity.GoodsImageID,ParameterDirection.Input)
  488. //,new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp, imgEntity.OPTimeStamp,ParameterDirection.Input)
  489. };
  490. imgReturn = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), imgParas);
  491. }
  492. }
  493. //修改产品附件
  494. //int AttReturn = UpdateAttachment(oracleTrConn, attList, Convert.ToInt32(goodsEntity.GoodsID), sUserInfo);
  495. oracleTrConn.Commit();
  496. oracleTrConn.Disconnect();
  497. }
  498. catch (Exception ex)
  499. {
  500. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  501. {
  502. oracleTrConn.Rollback();
  503. oracleTrConn.Disconnect();
  504. }
  505. throw ex;
  506. }
  507. return returnRows;
  508. }
  509. /// <summary>
  510. /// 查询产品物料信息
  511. /// </summary>
  512. /// <param name="sUserInfo"></param>
  513. /// <param name="goodsID"></param>
  514. /// <returns></returns>
  515. public static ServiceResultEntity GetGoodsSAP(SUserInfo sUserInfo, int goodsID)
  516. {
  517. IDBConnection conn = null;
  518. try
  519. {
  520. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  521. string sqlString = "\n" +
  522. "select '产品档案' logoname, g.materialcode, g.materialremark,g.WaterLabelCode, '1' valueflag, -1 displayno\n" +
  523. " from tp_mst_goods g\n" +
  524. " where g.goodsid = :goodsid\n" +
  525. "union all\n" +
  526. "select to_char(l.logoname)\n" +
  527. " ,gls.materialcode\n" +
  528. " ,gls.materialremark\n" +
  529. " ,gls.WaterLabelCode\n" +
  530. " ,l.valueflag\n" +
  531. " ,l.displayno\n" +
  532. " from tp_mst_goodslogosap gls\n" +
  533. " inner join tp_mst_logo l\n" +
  534. " on l.logoid = gls.logoid\n" +
  535. " where gls.goodsid = :goodsid\n" +
  536. " order by valueflag desc, displayno";
  537. OracleParameter[] paras = new OracleParameter[]{
  538. new OracleParameter(":goodsid",goodsID),
  539. };
  540. ServiceResultEntity sre = new ServiceResultEntity();
  541. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  542. return sre;
  543. }
  544. catch (Exception ex)
  545. {
  546. throw ex;
  547. }
  548. finally
  549. {
  550. if (conn != null &&
  551. conn.ConnState == ConnectionState.Open)
  552. {
  553. conn.Close();
  554. }
  555. }
  556. }
  557. /// <summary>
  558. /// 查询产品物料信息(编辑用)
  559. /// </summary>
  560. /// <param name="sUserInfo"></param>
  561. /// <param name="goodsID"></param>
  562. /// <returns></returns>
  563. public static ServiceResultEntity GetGoodsSAPByEdit(SUserInfo sUserInfo, int goodsID)
  564. {
  565. IDBConnection conn = null;
  566. try
  567. {
  568. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  569. string sqlString = "select l.logoid\n" +
  570. " ,l.logoname\n" +
  571. " ,gls.materialcode\n" +
  572. " ,gls.materialremark\n" +
  573. " ,gls.WaterLabelCode\n" +
  574. " ,gls.goodsid\n" +
  575. " ,l.valueflag\n" +
  576. " from tp_mst_logo l\n" +
  577. " left join tp_mst_goodslogosap gls\n" +
  578. " on gls.goodsid = :goodsid\n" +
  579. " and l.logoid = gls.logoid\n" +
  580. " where (l.valueflag = '1' or gls.goodsid is not null)\n" +
  581. " order by gls.goodsid, l.valueflag desc, l.displayno";
  582. OracleParameter[] paras = new OracleParameter[]{
  583. new OracleParameter(":goodsid",goodsID),
  584. };
  585. ServiceResultEntity sre = new ServiceResultEntity();
  586. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  587. return sre;
  588. }
  589. catch (Exception ex)
  590. {
  591. throw ex;
  592. }
  593. finally
  594. {
  595. if (conn != null &&
  596. conn.ConnState == ConnectionState.Open)
  597. {
  598. conn.Close();
  599. }
  600. }
  601. }
  602. #endregion
  603. #region 获得生产工号集合
  604. /// <summary>
  605. /// 获得生产工号集合
  606. /// </summary>
  607. /// <param name="sUserInfo">用户基本信息</param>
  608. /// <returns>DataSet</returns>
  609. /// <remarks>
  610. /// 陈冰 2014.09.03 新建
  611. /// </remarks>
  612. public static DataSet GetWorker(SUserInfo sUserInfo)
  613. {
  614. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  615. try
  616. {
  617. con.Open();
  618. OracleParameter[] paras = new OracleParameter[]{
  619. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  620. new OracleParameter("rs_worker",OracleDbType.RefCursor,ParameterDirection.Output),
  621. };
  622. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetWorker", paras);
  623. return ds;
  624. }
  625. catch (Exception ex)
  626. {
  627. throw ex;
  628. }
  629. finally
  630. {
  631. if (con.ConnState == ConnectionState.Open)
  632. {
  633. con.Close();
  634. }
  635. }
  636. }
  637. #endregion
  638. #region 获得工种集合
  639. /// <summary>
  640. /// 获得工种集合
  641. /// </summary>
  642. /// <param name="sUserInfo">用户基本信息</param>
  643. /// <returns>DataSet</returns>
  644. /// <remarks>
  645. /// 陈冰 2014.09.03 新建
  646. /// </remarks>
  647. public static DataSet GetJobs(SUserInfo sUserInfo)
  648. {
  649. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  650. try
  651. {
  652. con.Open();
  653. OracleParameter[] paras = new OracleParameter[]{
  654. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  655. new OracleParameter("rs_jobs",OracleDbType.RefCursor,ParameterDirection.Output),
  656. };
  657. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetJobs", paras);
  658. return ds;
  659. }
  660. catch (Exception ex)
  661. {
  662. throw ex;
  663. }
  664. finally
  665. {
  666. if (con.ConnState == ConnectionState.Open)
  667. {
  668. con.Close();
  669. }
  670. }
  671. }
  672. #endregion
  673. #region 获得缺陷集合
  674. /// <summary>
  675. /// 获得缺陷集合
  676. /// </summary>
  677. /// <param name="sUserInfo">用户基本信息</param>
  678. /// <returns>DataSet</returns>
  679. /// <remarks>
  680. /// 陈冰 2014.09.03 新建
  681. /// </remarks>
  682. public static DataSet GetDefect(SUserInfo sUserInfo)
  683. {
  684. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  685. try
  686. {
  687. con.Open();
  688. OracleParameter[] paras = new OracleParameter[]{
  689. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  690. new OracleParameter("rs_defect",OracleDbType.RefCursor,ParameterDirection.Output),
  691. };
  692. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetDefect", paras);
  693. return ds;
  694. }
  695. catch (Exception ex)
  696. {
  697. throw ex;
  698. }
  699. finally
  700. {
  701. if (con.ConnState == ConnectionState.Open)
  702. {
  703. con.Close();
  704. }
  705. }
  706. }
  707. #endregion
  708. #region 产品图片
  709. /// <summary>
  710. /// 根据产品ID获取产品图片
  711. /// </summary>
  712. /// <param name="sUserInfo">用户基本信息</param>
  713. /// <param name="goodsId">产品ID</param>
  714. /// <returns>DataSet</returns>
  715. /// <remarks>
  716. /// 庄天威 2014.09.04 新建
  717. /// </remarks>
  718. public static DataSet GetImageByGoodsId(SUserInfo sUserInfo, int goodsId)
  719. {
  720. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  721. try
  722. {
  723. con.Open();
  724. OracleParameter[] paras = new OracleParameter[]{
  725. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  726. new OracleParameter("in_goodsID",OracleDbType.Int32,goodsId,ParameterDirection.Input),
  727. new OracleParameter("rs_result",OracleDbType.RefCursor,ParameterDirection.Output),
  728. };
  729. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetImageByGoodsId", paras);
  730. return ds;
  731. }
  732. catch (Exception ex)
  733. {
  734. throw ex;
  735. }
  736. finally
  737. {
  738. if (con.ConnState == ConnectionState.Open)
  739. {
  740. con.Close();
  741. }
  742. }
  743. }
  744. #endregion
  745. #region 附件
  746. /// <summary>
  747. /// 新建附件信息
  748. /// </summary>
  749. /// <param name="AttList">附件实体集合</param>
  750. /// <param name="mainId">产品ID</param>
  751. /// <param name="userInfo">用户基本信息</param>
  752. /// <returns>int影响结果行数</returns>
  753. public static int AddAttachment(List<GoodsAttachmentEntity> AttList, int mainId, SUserInfo userInfo)
  754. {
  755. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  756. try
  757. {
  758. oracleTrConn.Connect();
  759. int AttReturn = 0;
  760. int GAReturn = 0;
  761. StringBuilder sbSql = new StringBuilder();
  762. foreach (GoodsAttachmentEntity attFor in AttList)
  763. {
  764. sbSql.Clear();
  765. sbSql.Append("select SEQ_MST_Attachment_ID.nextval from dual");
  766. int id = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  767. sbSql.Clear();
  768. sbSql.Append(@"Insert into TP_MST_Attachment(AttachmentID,FileName,FilePath,AccountID,ValueFlag,
  769. CreateUserID,UpdateUserID)
  770. Values(:AttachmentID,:FileName,:FilePath,:AccountID,:ValueFlag,
  771. :CreateUserID,:UpdateUserID)");
  772. OracleParameter[] attParas = new OracleParameter[] {
  773. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  774. id,ParameterDirection.Input),
  775. new OracleParameter(":FileName",OracleDbType.NVarchar2,
  776. attFor.FileName,ParameterDirection.Input),
  777. new OracleParameter(":FilePath",OracleDbType.NVarchar2,
  778. attFor.FilePath,ParameterDirection.Input),
  779. new OracleParameter(":AccountID",OracleDbType.Int32,
  780. userInfo.AccountID,ParameterDirection.Input),
  781. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  782. 1,ParameterDirection.Input),
  783. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  784. userInfo.UserID,ParameterDirection.Input),
  785. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  786. userInfo.UserID,ParameterDirection.Input)
  787. };
  788. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  789. sbSql.Clear();
  790. sbSql.Append(@"Insert into TP_MST_GoodsAttachment(GoodsID,AttachmentID,CreateUserID,UpdateUserID)
  791. Values(:GoodsID,:AttachmentID,:CreateUserID,:UpdateUserID)");
  792. OracleParameter[] gaParas = new OracleParameter[] {
  793. new OracleParameter(":GoodsID",OracleDbType.Int32,
  794. mainId,ParameterDirection.Input),
  795. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  796. id,ParameterDirection.Input),
  797. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  798. userInfo.UserID,ParameterDirection.Input),
  799. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  800. userInfo.UserID,ParameterDirection.Input)
  801. };
  802. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), gaParas);
  803. sbSql.Clear();
  804. }
  805. oracleTrConn.Commit();
  806. oracleTrConn.Disconnect();
  807. return AttReturn;
  808. }
  809. catch (Exception ex)
  810. {
  811. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  812. {
  813. oracleTrConn.Rollback();
  814. oracleTrConn.Disconnect();
  815. }
  816. throw ex;
  817. }
  818. }
  819. /// <summary>
  820. /// 修改附件信息
  821. /// </summary>
  822. /// <param name="AttList">附件实体集合</param>
  823. /// <param name="mainId">产品ID</param>
  824. /// <param name="userInfo">用户基本信息</param>
  825. /// <returns>int受影响行数</returns>
  826. public static int UpdateAttachment(List<GoodsAttachmentEntity> AttList, int mainId, SUserInfo userInfo)
  827. {
  828. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  829. try
  830. {
  831. oracleTrConn.Connect();
  832. int AttReturn = 0;
  833. int GAReturn = 0;
  834. StringBuilder sbSql = new StringBuilder();
  835. foreach (GoodsAttachmentEntity attFor in AttList)
  836. {
  837. if (attFor.IsUpdateAdd == 0) //不是新建的
  838. {
  839. sbSql.Clear();
  840. sbSql.Append(@"Update TP_MST_Attachment set ValueFlag = :ValueFlag,UpdateUserID=:UpdateUserID
  841. Where AttachmentID = :AttachmentID");
  842. OracleParameter[] attParas = new OracleParameter[] {
  843. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  844. attFor.ValueFlag,ParameterDirection.Input),
  845. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  846. userInfo.UserID,ParameterDirection.Input),
  847. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  848. attFor.AttachmentID,ParameterDirection.Input)
  849. };
  850. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  851. sbSql.Clear();
  852. sbSql.Append(@"Update TP_MST_GoodsAttachment
  853. Set ValueFlag = :ValueFlag,UpdateUserID=:UpdateUserID
  854. Where AttachmentID = :AttachmentID");
  855. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  856. sbSql.Clear();
  857. }
  858. else //新建的
  859. {
  860. sbSql.Clear();
  861. sbSql.Append("select SEQ_MST_Attachment_ID.nextval from dual");
  862. int id = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  863. sbSql.Clear();
  864. sbSql.Append(@"Insert into TP_MST_Attachment(AttachmentID,FileName,FilePath,AccountID,ValueFlag,
  865. CreateUserID,UpdateUserID)
  866. Values(:AttachmentID,:FileName,:FilePath,:AccountID,:ValueFlag,
  867. :CreateUserID,:UpdateUserID)");
  868. OracleParameter[] attParas = new OracleParameter[] {
  869. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  870. id,ParameterDirection.Input),
  871. new OracleParameter(":FileName",OracleDbType.NVarchar2,
  872. attFor.FileName,ParameterDirection.Input),
  873. new OracleParameter(":FilePath",OracleDbType.NVarchar2,
  874. attFor.FilePath,ParameterDirection.Input),
  875. new OracleParameter(":AccountID",OracleDbType.Int32,
  876. userInfo.AccountID,ParameterDirection.Input),
  877. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  878. 1,ParameterDirection.Input),
  879. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  880. userInfo.UserID,ParameterDirection.Input),
  881. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  882. userInfo.UserID,ParameterDirection.Input)
  883. };
  884. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  885. sbSql.Clear();
  886. sbSql.Append(@"Insert into TP_MST_GoodsAttachment(GoodsID,AttachmentID,CreateUserID,UpdateUserID)
  887. Values(:GoodsID,:AttachmentID,:CreateUserID,:UpdateUserID)");
  888. OracleParameter[] gaParas = new OracleParameter[] {
  889. new OracleParameter(":GoodsID",OracleDbType.Int32,
  890. mainId,ParameterDirection.Input),
  891. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  892. id,ParameterDirection.Input),
  893. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  894. userInfo.UserID,ParameterDirection.Input),
  895. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  896. userInfo.UserID,ParameterDirection.Input)
  897. };
  898. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), gaParas);
  899. sbSql.Clear();
  900. }
  901. }
  902. oracleTrConn.Commit();
  903. oracleTrConn.Disconnect();
  904. return AttReturn;
  905. }
  906. catch (Exception ex)
  907. {
  908. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  909. {
  910. oracleTrConn.Rollback();
  911. oracleTrConn.Disconnect();
  912. }
  913. throw ex;
  914. }
  915. }
  916. /// <summary>
  917. /// 根据产品ID获取附件
  918. /// </summary>
  919. /// <param name="goodsId">产品ID</param>
  920. /// <returns>DataSet</returns>
  921. public static DataSet GetAttachmentByGoodsId(int goodsId)
  922. {
  923. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  924. try
  925. {
  926. con.Open();
  927. String strSql = @"Select goodsAtt.GoodsID,att.* from TP_MST_GoodsAttachment goodsAtt
  928. Inner join TP_MST_Attachment att
  929. On goodsAtt.AttachmentID = att.AttachmentID
  930. Where goodsAtt.ValueFlag = 1 and goodsAtt.GoodsID = " + goodsId;
  931. DataSet ds = con.GetSqlResultToDs(strSql, null);
  932. return ds;
  933. }
  934. catch (Exception ex)
  935. {
  936. throw ex;
  937. }
  938. finally
  939. {
  940. if (con.ConnState == ConnectionState.Open)
  941. {
  942. con.Close();
  943. }
  944. }
  945. }
  946. #endregion
  947. #region 缺陷位置
  948. /// <summary>
  949. /// 获取缺陷位置
  950. /// </summary>
  951. /// <param name="dpEntity">缺陷位置实体</param>
  952. /// <param name="userInfo">用户基本信息</param>
  953. /// <returns>DataSet</returns>
  954. public static DataSet GetDefectPosition(DefectPositionEntity dpEntity, SUserInfo userInfo)
  955. {
  956. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  957. try
  958. {
  959. con.Open();
  960. OracleParameter[] paras = new OracleParameter[]{
  961. new OracleParameter("in_DefectPositionID",OracleDbType.Int32,
  962. dpEntity.DefectPositionID,ParameterDirection.Input),
  963. new OracleParameter("in_DefectPositionCode",OracleDbType.NVarchar2,
  964. dpEntity.DefectPositionCode,ParameterDirection.Input),
  965. new OracleParameter("in_DefectPositionName",OracleDbType.NVarchar2,
  966. dpEntity.DefectPositionName,ParameterDirection.Input),
  967. new OracleParameter("in_AccountID",OracleDbType.Int32,
  968. userInfo.AccountID,ParameterDirection.Input),
  969. new OracleParameter("out_rs_defect",OracleDbType.RefCursor,ParameterDirection.Output),
  970. };
  971. DataSet dsDefectPosition = con.ExecStoredProcedure("PRO_MST_GetDefectPosition", paras);
  972. return dsDefectPosition;
  973. }
  974. catch (Exception ex)
  975. {
  976. throw ex;
  977. }
  978. finally
  979. {
  980. if (con.ConnState == ConnectionState.Open)
  981. {
  982. con.Close();
  983. }
  984. }
  985. }
  986. /// <summary>
  987. /// 根据产品获得产品缺陷位置
  988. /// </summary>
  989. /// <param name="GoodsId">产品ID</param>
  990. /// <returns>DataSet</returns>
  991. public static DataSet getGoodsDefectPositionByGoodsId(int GoodsId)
  992. {
  993. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  994. try
  995. {
  996. con.Open();
  997. string sql = @"select gdp.*,dp.DefectPositionCode,dp.DefectPositionName,dp.Remarks
  998. from TP_MST_GoodsDefectPosition gdp
  999. inner join TP_MST_DefectPosition dp
  1000. on gdp.DefectPositionID=dp.DefectPositionID
  1001. where gdp.GoodsID=" + GoodsId;
  1002. DataSet dsDefectPosition = con.GetSqlResultToDs(sql, null);
  1003. return dsDefectPosition;
  1004. }
  1005. catch (Exception ex)
  1006. {
  1007. throw ex;
  1008. }
  1009. finally
  1010. {
  1011. if (con.ConnState == ConnectionState.Open)
  1012. {
  1013. con.Close();
  1014. }
  1015. }
  1016. }
  1017. /// <summary>
  1018. /// 保存产品缺陷位置关联(依附在添加产品中)
  1019. /// </summary>
  1020. /// <param name="dpList">缺陷位置集</param>
  1021. /// <param name="GoodsId">产品ID</param>
  1022. /// <param name="userInfo">用户基本信息</param>
  1023. /// <returns>int</returns>
  1024. public static int SaveGoodsDefectPosition(IDBTransaction oracleTrConn, List<int> dpList, int GoodsId, SUserInfo userInfo)
  1025. {
  1026. try
  1027. {
  1028. int ReturnCount = 0;
  1029. string sql = "Delete from TP_MST_GoodsDefectPosition where GoodsId=" + GoodsId;
  1030. foreach (int dpFor in dpList)
  1031. {
  1032. string sqlAdd = @"Insert into TP_MST_GoodsDefectPosition(GoodsID,DefectPositionID,
  1033. CreateTime,CreateUserID) Values(:GoodsID,:DefectPositionID,sysdate,:CreateUserID)";
  1034. OracleParameter[] paras = new OracleParameter[]{
  1035. new OracleParameter(":GoodsID",OracleDbType.Int32,
  1036. GoodsId,ParameterDirection.Input),
  1037. new OracleParameter(":DefectPositionID",OracleDbType.Int32,
  1038. dpFor,ParameterDirection.Input),
  1039. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  1040. userInfo.UserID,ParameterDirection.Input),
  1041. };
  1042. ReturnCount += oracleTrConn.ExecuteNonQuery(sqlAdd, paras);
  1043. }
  1044. return ReturnCount;
  1045. }
  1046. catch (Exception ex)
  1047. {
  1048. throw ex;
  1049. }
  1050. }
  1051. #endregion
  1052. #region 成型线类型
  1053. /// <summary>
  1054. /// 获取成型线类型
  1055. /// </summary>
  1056. /// <param name="userInfo">用户基本信息</param>
  1057. /// <returns>数据集</returns>
  1058. /// <remarks>
  1059. /// 庄天威 2014.09.04 新建
  1060. /// </remarks>
  1061. public static DataSet GetGMouldType(SUserInfo userInfo)
  1062. {
  1063. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1064. try
  1065. {
  1066. con.Open();
  1067. OracleParameter[] paras = new OracleParameter[]{
  1068. new OracleParameter("in_accountID",OracleDbType.Int32,
  1069. userInfo.AccountID,ParameterDirection.Input),
  1070. new OracleParameter("in_valueFlag",OracleDbType.Int32,
  1071. 1,ParameterDirection.Input),
  1072. new OracleParameter("out_result",OracleDbType.RefCursor,ParameterDirection.Output),
  1073. };
  1074. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetMouldType", paras);
  1075. return ds;
  1076. }
  1077. catch (Exception ex)
  1078. {
  1079. throw ex;
  1080. }
  1081. finally
  1082. {
  1083. if (con.ConnState == ConnectionState.Open)
  1084. {
  1085. con.Close();
  1086. }
  1087. }
  1088. }
  1089. #endregion
  1090. #region 产品分级数据源
  1091. /// <summary>
  1092. /// 产品分级数据源
  1093. /// </summary>
  1094. /// <param name="type">1适用半成品2检验 2适用成品检验 3入窑前检验</param>
  1095. /// <param name="userInfo">用户基本信息</param>
  1096. /// <returns>DataSet</returns>
  1097. public static DataSet GetGoodsLevel(int type, SUserInfo userInfo)
  1098. {
  1099. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1100. try
  1101. {
  1102. con.Open();
  1103. string sqlString = "";
  1104. if (type == 1 || type == 3)
  1105. {
  1106. sqlString = "select GoodsLevelID as DefectFlagID,GoodsLevelName as DefectFlagName,GoodsLevelTypeID from TP_MST_GoodsLevel where IsSemiFinishedEx=1 and AccountID=:AccountID and ValueFlag=1 order by SFEDisplayNo";
  1107. }
  1108. else if (type == 2)
  1109. {
  1110. sqlString = "select GoodsLevelID as DefectFlagID,GoodsLevelName as DefectFlagName,GoodsLevelTypeID from TP_MST_GoodsLevel where IsFinishedEx=1 and AccountID=:AccountID and ValueFlag=1 order by FEDisplayNo";
  1111. }
  1112. OracleParameter[] paras = new OracleParameter[]{
  1113. new OracleParameter(":AccountID",userInfo.AccountID),
  1114. };
  1115. DataSet dsGoodsLevel = con.GetSqlResultToDs(sqlString, paras);
  1116. return dsGoodsLevel;
  1117. }
  1118. catch (Exception ex)
  1119. {
  1120. throw ex;
  1121. }
  1122. finally
  1123. {
  1124. if (con.ConnState == ConnectionState.Open)
  1125. {
  1126. con.Close();
  1127. }
  1128. }
  1129. }
  1130. #endregion
  1131. #region 审核状态
  1132. /// <summary>
  1133. /// 获取全部审核状态
  1134. /// </summary>
  1135. /// <returns>DataSet审核状态数据源</returns>
  1136. public static DataSet GetAuditStatus()
  1137. {
  1138. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1139. try
  1140. {
  1141. con.Open();
  1142. String strSql = "Select * from TP_SYS_AuditStatus Order by DisplayNo";
  1143. DataSet ds = con.GetSqlResultToDs(strSql, null);
  1144. return ds;
  1145. }
  1146. catch (Exception ex)
  1147. {
  1148. throw ex;
  1149. }
  1150. finally
  1151. {
  1152. if (con.ConnState == ConnectionState.Open)
  1153. {
  1154. con.Close();
  1155. }
  1156. }
  1157. }
  1158. #endregion
  1159. /// <summary>
  1160. /// 工序集合
  1161. /// </summary>
  1162. /// <param name="ProductionLineEntity">工序实体</param>
  1163. /// <param name="sUserInfo">用户<基本信息/param>
  1164. /// <returns>DataSet</returns>
  1165. /// <remarks>
  1166. /// 王鑫 2014.11.29 新建
  1167. /// </remarks>
  1168. public static DataSet GetProdureList(SearchProductionLineEntity productionLineEntity, SUserInfo sUserInfo)
  1169. {
  1170. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1171. try
  1172. {
  1173. con.Open();
  1174. OracleParameter[] paras = new OracleParameter[]{
  1175. new OracleParameter("in_procedureCode",OracleDbType.Varchar2,productionLineEntity.ProductionLineCode,ParameterDirection.Input),
  1176. new OracleParameter("in_procedureName",OracleDbType.Varchar2,productionLineEntity.ProductionLineName,ParameterDirection.Input),
  1177. new OracleParameter("in_procedureIDS",OracleDbType.Varchar2,productionLineEntity.ProcuteLineIDS,ParameterDirection.Input),
  1178. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  1179. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  1180. };
  1181. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_PC_GetProcedureList", paras);
  1182. return dsSearchReport;
  1183. }
  1184. catch (Exception ex)
  1185. {
  1186. throw ex;
  1187. }
  1188. finally
  1189. {
  1190. if (con.ConnState == ConnectionState.Open)
  1191. {
  1192. con.Close();
  1193. }
  1194. }
  1195. }
  1196. /// <summary>
  1197. /// 获取全部工种计件方式
  1198. /// </summary>
  1199. /// <returns>DataSet工种计件方式集合</returns>
  1200. public static DataSet GetJobsPriceType()
  1201. {
  1202. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1203. try
  1204. {
  1205. con.Open();
  1206. String strSql = "Select * from TP_SYS_JobsPriceType Order by DisplayNo";
  1207. DataSet dsSearchReport = con.GetSqlResultToDs(strSql, null);
  1208. return dsSearchReport;
  1209. }
  1210. catch (Exception ex)
  1211. {
  1212. throw ex;
  1213. }
  1214. finally
  1215. {
  1216. if (con.ConnState == ConnectionState.Open)
  1217. {
  1218. con.Close();
  1219. }
  1220. }
  1221. }
  1222. }
  1223. }