SystemModuleLogicPartial.cs 51 KB

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