SystemModuleLogicPartial.cs 51 KB

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