SystemModuleLogicPartial.cs 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016
  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)");
  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)");
  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(":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,GOODSMODEL)\n" +
  220. "values\n" +
  221. " (:GOODSID, :LOGOID, :GOODSCODE, :MATERIALCODE, :MATERIALREMARK, :CREATEUSERID, :WaterLabelCode,:GOODSMODEL)";
  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. new OracleParameter(":GOODSMODEL",item["goodsModel"]),
  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(" 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(":Goods_Line_CODE",goodsEntity.GoodsLineCode),
  373. new OracleParameter(":StartingDate",goodsEntity.StartingDate),
  374. new OracleParameter(":AutoLossCycle",goodsEntity.AutoLossCycle),
  375. new OracleParameter(":DeliverLimitCycle",goodsEntity.DeliverLimitCycle),
  376. new OracleParameter(":PlateLimitNum",goodsEntity.PlateLimitNum),
  377. new OracleParameter(":ReservedDays",goodsEntity.ReservedDays),
  378. new OracleParameter(":UnitPrice",goodsEntity.UnitPrice),
  379. new OracleParameter(":PackageNum",goodsEntity.PackageNum),
  380. new OracleParameter(":OutletDistance",goodsEntity.OutletDistance),
  381. new OracleParameter(":MaterialCode",goodsEntity.MaterialCode),
  382. new OracleParameter(":MouldWeight",goodsEntity.MouldWeight),
  383. new OracleParameter(":MouldCost",goodsEntity.MouldCost),
  384. new OracleParameter(":ScrapSumFlag",goodsEntity.ScrapSumFlag),
  385. new OracleParameter(":MaterialRemark",goodsEntity.MaterialRemark),
  386. new OracleParameter(":printcopies",goodsEntity.PrintCopies),
  387. new OracleParameter(":Remarks",goodsEntity.Remarks),
  388. new OracleParameter(":SEATCOVERCODE",goodsEntity.SeatCoverCode),
  389. new OracleParameter(":WaterLabelCode",goodsEntity.WaterLabelCode),
  390. new OracleParameter(":StandardGroutingNum",goodsEntity.StandardGroutingNum),
  391. new OracleParameter(":MouldMaterialCode",goodsEntity.MouldMaterialCode),
  392. new OracleParameter(":MouldOutputCount",goodsEntity.MouldOutputCount),
  393. new OracleParameter(":logoid", goodsEntity.LogoID),
  394. new OracleParameter(":AccountID",goodsEntity.AccountID),
  395. new OracleParameter(":ValueFlag",goodsEntity.ValueFlag),
  396. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  397. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  398. //new OracleParameter(":CreateTime",OracleDbType.Date,goodsEntity.CreateTime,ParameterDirection.Input),
  399. //new OracleParameter(":CreateUserID",goodsEntity.CreateUserID),
  400. new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,goodsEntity.OPTimeStamp,ParameterDirection.Input),
  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,GOODSMODEL)\n" +
  415. "values\n" +
  416. " (:GOODSID, :LOGOID, :GOODSCODE, :MATERIALCODE, :MATERIALREMARK, :CREATEUSERID,:WaterLabelCode,:GOODSMODEL)";
  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. new OracleParameter(":GOODSMODEL",item["goodsModel"]),
  438. };
  439. returnRows += oracleTrConn.ExecuteNonQuery(sql, paras);
  440. }
  441. foreach (GoodsImageEntity imgEntity in imgList)
  442. {
  443. if (imgEntity.GoodsImageID == 0)
  444. {
  445. int imgReturn = 0;
  446. sbSql.Clear();
  447. sbSql.Append("select SEQ_MST_GoodsImage_ID.nextval from dual");
  448. int imgId = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  449. sbSql.Clear();
  450. sbSql.Append("Insert into TP_MST_GoodsImage");
  451. sbSql.Append("(GoodsImageID,GoodsID,Thumbnail,Image,AccountID,ValueFlag,");
  452. sbSql.Append("CreateUserID,UpdateUserID)");
  453. sbSql.Append(" VALUES(:GoodsImageID,:GoodsID,:Thumbnail,:Image,:AccountID,:ValueFlag,");
  454. sbSql.Append(":CreateUserID,:UpdateUserID)");
  455. OracleParameter[] imgParas = new OracleParameter[] {
  456. new OracleParameter(":GoodsImageID",OracleDbType.Int32,imgId,ParameterDirection.Input),
  457. new OracleParameter(":GoodsID",OracleDbType.Int32,goodsEntity.GoodsID,ParameterDirection.Input),
  458. new OracleParameter(":Thumbnail",OracleDbType.Blob,imgEntity.Thumbnail,ParameterDirection.Input),
  459. new OracleParameter(":Image",OracleDbType.Blob,imgEntity.Image,ParameterDirection.Input),
  460. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  461. new OracleParameter(":ValueFlag",OracleDbType.Int32,imgEntity.ValueFlag,ParameterDirection.Input),
  462. //new OracleParameter(":CreateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  463. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  464. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  465. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  466. //new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,DateTime.Now,ParameterDirection.Input)
  467. };
  468. imgReturn = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), imgParas);
  469. }
  470. else
  471. {
  472. int imgReturn = 0;
  473. sbSql.Clear();
  474. sbSql.Append(" update TP_MST_GoodsImage");
  475. sbSql.Append(" set GoodsID=:GoodsID,AccountID=:AccountID,ValueFlag=:ValueFlag,");
  476. sbSql.Append(" UpdateUserID=:UpdateUserID");
  477. //sbSql.Append(" where GoodsImageID=:GoodsImageID And OPTimeStamp=to_date(:OPTimeStamp,'yyyy-mm-dd HH24:mi:ss')");
  478. sbSql.Append(" where GoodsImageID=:GoodsImageID");
  479. OracleParameter[] imgParas = new OracleParameter[] {
  480. new OracleParameter(":GoodsID",OracleDbType.Int32,
  481. goodsEntity.GoodsID,ParameterDirection.Input),
  482. new OracleParameter(":AccountID",OracleDbType.Int32,
  483. imgEntity.AccountID,ParameterDirection.Input),
  484. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  485. imgEntity.ValueFlag,ParameterDirection.Input),
  486. //new OracleParameter(":UpdateTime",OracleDbType.NVarchar2,
  487. // DateTime.Now.ToString(),ParameterDirection.Input),
  488. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  489. sUserInfo.UserID,ParameterDirection.Input),
  490. new OracleParameter(":GoodsImageID",OracleDbType.Int32,
  491. imgEntity.GoodsImageID,ParameterDirection.Input)
  492. //,new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp, imgEntity.OPTimeStamp,ParameterDirection.Input)
  493. };
  494. imgReturn = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), imgParas);
  495. }
  496. }
  497. //修改产品附件
  498. //int AttReturn = UpdateAttachment(oracleTrConn, attList, Convert.ToInt32(goodsEntity.GoodsID), sUserInfo);
  499. oracleTrConn.Commit();
  500. oracleTrConn.Disconnect();
  501. }
  502. catch (Exception ex)
  503. {
  504. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  505. {
  506. oracleTrConn.Rollback();
  507. oracleTrConn.Disconnect();
  508. }
  509. throw ex;
  510. }
  511. return returnRows;
  512. }
  513. /// <summary>
  514. /// 查询产品物料信息
  515. /// </summary>
  516. /// <param name="sUserInfo"></param>
  517. /// <param name="goodsID"></param>
  518. /// <returns></returns>
  519. public static ServiceResultEntity GetGoodsSAP(SUserInfo sUserInfo, int goodsID)
  520. {
  521. IDBConnection conn = null;
  522. try
  523. {
  524. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  525. string sqlString = "\n" +
  526. "select '产品档案' logoname, g.materialcode, g.materialremark,g.WaterLabelCode,g.goodsModel, '1' valueflag, -1 displayno\n" +
  527. " from tp_mst_goods g\n" +
  528. " where g.goodsid = :goodsid\n" +
  529. "union all\n" +
  530. "select to_char(l.logoname)\n" +
  531. " ,gls.materialcode\n" +
  532. " ,gls.materialremark\n" +
  533. " ,gls.WaterLabelCode\n" +
  534. " ,gls.goodsModel\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 GetGoodsLogo(SUserInfo sUserInfo, int goodsID)
  569. {
  570. IDBConnection conn = null;
  571. try
  572. {
  573. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  574. string sqlString = @" SELECT distinct t.LOGONAME,
  575. t.LOGOID FROM (
  576. SELECT
  577. TML.LOGONAME,
  578. TML.LOGOID
  579. FROM TP_MST_LOGO TML
  580. WHERE
  581. TML.LOGOID = 1
  582. union all
  583. SELECT
  584. TML.LOGONAME,
  585. TMGS.LOGOID
  586. FROM
  587. TP_MST_GOODSLOGOSAP TMGS
  588. LEFT JOIN TP_MST_LOGO TML ON TML.LOGOID = TMGS.LOGOID
  589. WHERE
  590. TMGS.goodsid = :goodsid
  591. )t ";
  592. OracleParameter[] paras = new OracleParameter[]{
  593. new OracleParameter(":goodsid",goodsID),
  594. };
  595. ServiceResultEntity sre = new ServiceResultEntity();
  596. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  597. return sre;
  598. }
  599. catch (Exception ex)
  600. {
  601. throw ex;
  602. }
  603. finally
  604. {
  605. if (conn != null &&
  606. conn.ConnState == ConnectionState.Open)
  607. {
  608. conn.Close();
  609. }
  610. }
  611. }
  612. /// <summary>
  613. /// 查询产品信息
  614. /// </summary>
  615. /// <param name="sUserInfo"></param>
  616. /// <param name="goodsID"></param>
  617. /// <returns></returns>
  618. public static ServiceResultEntity GetGoodsCode(SUserInfo sUserInfo)
  619. {
  620. IDBConnection conn = null;
  621. try
  622. {
  623. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  624. string sqlString = @"SELECT GOODSID,GOODSCODE FROM TP_MST_GOODS WHERE VALUEFLAG = 1";
  625. OracleParameter[] paras = new OracleParameter[]{
  626. };
  627. ServiceResultEntity sre = new ServiceResultEntity();
  628. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  629. return sre;
  630. }
  631. catch (Exception ex)
  632. {
  633. throw ex;
  634. }
  635. finally
  636. {
  637. if (conn != null &&
  638. conn.ConnState == ConnectionState.Open)
  639. {
  640. conn.Close();
  641. }
  642. }
  643. }
  644. /// <summary>
  645. /// 查询辅件种类
  646. /// </summary>
  647. /// <param name="sUserInfo"></param>
  648. /// <param name="goodsID"></param>
  649. /// <returns></returns>
  650. public static ServiceResultEntity GetAccessoriesType(SUserInfo sUserInfo)
  651. {
  652. IDBConnection conn = null;
  653. try
  654. {
  655. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  656. string sqlString = @"SELECT DICTIONARYID,DICTIONARYVALUE FROM TP_MST_DATADICTIONARY WHERE DICTIONARYTYPE = 'TPC010'";
  657. OracleParameter[] paras = new OracleParameter[]{
  658. };
  659. ServiceResultEntity sre = new ServiceResultEntity();
  660. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  661. return sre;
  662. }
  663. catch (Exception ex)
  664. {
  665. throw ex;
  666. }
  667. finally
  668. {
  669. if (conn != null &&
  670. conn.ConnState == ConnectionState.Open)
  671. {
  672. conn.Close();
  673. }
  674. }
  675. }
  676. /// <summary>
  677. /// 查询辅件编辑信息
  678. /// </summary>
  679. /// <param name="sUserInfo"></param>
  680. /// <param name="goodsID"></param>
  681. /// <returns></returns>
  682. public static ServiceResultEntity GetEditGoods(SUserInfo sUserInfo,ClientRequestEntity cre)
  683. {
  684. IDBConnection conn = null;
  685. try
  686. {
  687. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  688. string sqlString = @"
  689. SELECT
  690. TMA.GOODSID,
  691. TMA.LOGOID,
  692. TMA.ACCESSORIESNAME,
  693. TMA.ACCESSORIESCODE,
  694. TMA.ACCESSORIESTYPEID
  695. FROM
  696. TP_MST_ACCESSORIES TMA
  697. WHERE
  698. TMA.VALUEFLAG = 1
  699. AND TMA.goodsid = :goodsid
  700. AND TMA.logoid = :logoid";
  701. string goodsid = cre.Data.Tables[0].Rows[0]["GoodsID"].ToString();
  702. string logoid = cre.Data.Tables[0].Rows[0]["logoid"].ToString();
  703. OracleParameter[] paras = new OracleParameter[]{
  704. new OracleParameter(":goodsid",goodsid),
  705. new OracleParameter(":logoid",logoid),
  706. };
  707. ServiceResultEntity sre = new ServiceResultEntity();
  708. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  709. return sre;
  710. }
  711. catch (Exception ex)
  712. {
  713. throw ex;
  714. }
  715. finally
  716. {
  717. if (conn != null &&
  718. conn.ConnState == ConnectionState.Open)
  719. {
  720. conn.Close();
  721. }
  722. }
  723. }
  724. /// <summary>
  725. /// 产品对应商标辅件编辑
  726. /// </summary>
  727. /// <param name="sUserInfo"></param>
  728. /// <param name="goodsID"></param>
  729. /// <returns></returns>
  730. public static ServiceResultEntity EditGoodsLogo(SUserInfo sUserInfo, ClientRequestEntity cre)
  731. {
  732. ServiceResultEntity sre = new ServiceResultEntity();
  733. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  734. try
  735. {
  736. string sqlString = string.Empty;
  737. string sqlString2 = string.Empty;
  738. OracleParameter[] paras = null;
  739. OracleParameter[] paras2 = null;
  740. //辅件
  741. DataTable dt1 = cre.Data.Tables[0];
  742. //产品id、商标id
  743. DataTable dt = cre.Data.Tables[1];
  744. int goodsid = Convert.ToInt32(dt.Rows[0]["GoodsID"]);
  745. int logoid = Convert.ToInt32(dt.Rows[0]["logoid"]);
  746. oracleTrConn.Connect();
  747. //删除对应辅件
  748. sqlString = @"DELETE FROM TP_MST_ACCESSORIES WHERE GOODSID = :GOODSID AND LOGOID = :LOGOID";
  749. paras = new OracleParameter[]
  750. {
  751. new OracleParameter(":GOODSID", goodsid),
  752. new OracleParameter(":LOGOID", logoid)
  753. };
  754. int count = dt1.Rows.Count;
  755. sre.OtherStatus += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  756. if (dt1.Rows.Count > 0)
  757. {
  758. // 保存
  759. sqlString = @"
  760. INSERT INTO TP_MST_ACCESSORIES (GOODSID,LOGOID,VALUEFLAG,CREATEUSERID,UPDATEUSERID,ACCESSORIESNAME,ACCESSORIESTYPEID,ACCESSORIESCODE)
  761. VALUES(:GOODSID,:LOGOID,1,:UserID,:UserID,:ACCESSORIESNAME,:ACCESSORIESTYPEID,:ACCESSORIESCODE)
  762. ";
  763. for (int i = 0; i < count; i++)
  764. {
  765. //查询对应的辅件id
  766. sqlString2 = "SELECT DICTIONARYID FROM TP_MST_DATADICTIONARY WHERE DICTIONARYVALUE = :DICTIONARYVALUE";
  767. paras2 = new OracleParameter[]
  768. {
  769. new OracleParameter(":DICTIONARYVALUE", dt1.Rows[i]["DICTIONARYVALUE"]),
  770. };
  771. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString2, paras2);
  772. paras = new OracleParameter[]
  773. {
  774. new OracleParameter(":GOODSID", goodsid),
  775. new OracleParameter(":LOGOID", logoid),
  776. new OracleParameter(":ACCESSORIESNAME", dt1.Rows[i]["ACCESSORIESNAME"]),
  777. new OracleParameter(":ACCESSORIESTYPEID",ds.Tables[0].Rows[0]["DICTIONARYID"]),
  778. new OracleParameter(":ACCESSORIESCODE", dt1.Rows[i]["ACCESSORIESCODE"]),
  779. new OracleParameter(":UserID", sUserInfo.UserID),
  780. };
  781. sre.OtherStatus += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  782. }
  783. }
  784. oracleTrConn.Commit();
  785. oracleTrConn.Disconnect();
  786. }
  787. catch (Exception ex)
  788. {
  789. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  790. {
  791. oracleTrConn.Rollback();
  792. oracleTrConn.Disconnect();
  793. }
  794. throw new Exception(ex.ToString(), ex);
  795. }
  796. finally
  797. {
  798. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  799. {
  800. oracleTrConn.Disconnect();
  801. }
  802. }
  803. return sre;
  804. }
  805. /// <summary>
  806. /// 查询附件
  807. /// </summary>
  808. /// <param name="sUserInfo"></param>
  809. /// <param name="goodsID"></param>
  810. /// <returns></returns>
  811. public static ServiceResultEntity GetAccessories(SUserInfo sUserInfo, ClientRequestEntity cre)
  812. {
  813. IDBConnection conn = null;
  814. try
  815. {
  816. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  817. string sqlString = @"SELECT
  818. TMA.ACCESSORIESCODE,
  819. --TMA.ACCESSORIESTYPEID,
  820. TMA.ACCESSORIESNAME,
  821. TMD.DICTIONARYVALUE
  822. FROM
  823. TP_MST_ACCESSORIES TMA
  824. LEFT JOIN TP_MST_DATADICTIONARY TMD ON TMA.ACCESSORIESTYPEID = TMD.DICTIONARYID
  825. WHERE GOODSID = :goodsid AND LOGOID = :logoid";
  826. string goodsid = cre.Data.Tables[0].Rows[0]["GoodsID"].ToString();
  827. string logoid = cre.Data.Tables[0].Rows[0]["logoid"].ToString();
  828. OracleParameter[] paras = new OracleParameter[]{
  829. new OracleParameter(":goodsid",goodsid),
  830. new OracleParameter(":logoid",logoid),
  831. };
  832. ServiceResultEntity sre = new ServiceResultEntity();
  833. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  834. return sre;
  835. }
  836. catch (Exception ex)
  837. {
  838. throw ex;
  839. }
  840. finally
  841. {
  842. if (conn != null &&
  843. conn.ConnState == ConnectionState.Open)
  844. {
  845. conn.Close();
  846. }
  847. }
  848. }
  849. /// <summary>
  850. /// 保存产品商标辅件
  851. /// </summary>
  852. /// <param name="sUserInfo"></param>
  853. /// <param name="goodsID"></param>
  854. /// <returns></returns>
  855. public static ServiceResultEntity AddGoodsLogo(SUserInfo sUserInfo, ClientRequestEntity cre)
  856. {
  857. string sqlString = string.Empty;
  858. string sqlString2 = string.Empty;
  859. OracleParameter[] paras = null;
  860. OracleParameter[] paras2 = null;
  861. //辅件
  862. DataTable dt1 = cre.Data.Tables[1];
  863. //产品id、商标id
  864. DataTable dt = cre.Data.Tables[0];
  865. int goodsid = Convert.ToInt32(dt.Rows[0]["GoodsID"]);
  866. int logoid = Convert.ToInt32(dt.Rows[0]["logoid"]);
  867. //新增条数
  868. int count = dt1.Rows.Count;
  869. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  870. ServiceResultEntity sre = new ServiceResultEntity();
  871. try
  872. {
  873. oracleTrConn.Connect();
  874. // 保存
  875. sqlString = @"
  876. INSERT INTO TP_MST_ACCESSORIES (GOODSID,LOGOID,VALUEFLAG,CREATEUSERID,UPDATEUSERID,ACCESSORIESNAME,ACCESSORIESTYPEID,ACCESSORIESCODE)
  877. VALUES(:GOODSID,:LOGOID,1,:UserID,:UserID,:ACCESSORIESNAME,:ACCESSORIESTYPEID,:ACCESSORIESCODE)
  878. ";
  879. for (int i = 0; i < count; i++)
  880. {
  881. //查询对应的辅件id
  882. sqlString2 = "SELECT DICTIONARYID FROM TP_MST_DATADICTIONARY WHERE DICTIONARYVALUE = :DICTIONARYVALUE";
  883. paras2 = new OracleParameter[]
  884. {
  885. new OracleParameter(":DICTIONARYVALUE", dt1.Rows[i]["DICTIONARYVALUE"]),
  886. };
  887. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString2, paras2);
  888. paras = new OracleParameter[]
  889. {
  890. new OracleParameter(":GOODSID", goodsid),
  891. new OracleParameter(":LOGOID", logoid),
  892. new OracleParameter(":ACCESSORIESNAME", dt1.Rows[i]["ACCESSORIESNAME"]),
  893. new OracleParameter(":ACCESSORIESTYPEID",ds.Tables[0].Rows[0]["DICTIONARYID"]),
  894. new OracleParameter(":ACCESSORIESCODE", dt1.Rows[i]["ACCESSORIESCODE"]),
  895. new OracleParameter(":UserID", sUserInfo.UserID),
  896. };
  897. sre.OtherStatus += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  898. }
  899. oracleTrConn.Commit();
  900. oracleTrConn.Disconnect();
  901. }
  902. catch (Exception ex)
  903. {
  904. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  905. {
  906. oracleTrConn.Rollback();
  907. oracleTrConn.Disconnect();
  908. }
  909. throw ex;
  910. }
  911. return sre;
  912. }
  913. /// <summary>
  914. /// 查询产品物料信息(编辑用)
  915. /// </summary>
  916. /// <param name="sUserInfo"></param>
  917. /// <param name="goodsID"></param>
  918. /// <returns></returns>
  919. public static ServiceResultEntity GetGoodsSAPByEdit(SUserInfo sUserInfo, int goodsID)
  920. {
  921. IDBConnection conn = null;
  922. try
  923. {
  924. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  925. string sqlString = "select l.logoid\n" +
  926. " ,l.logoname\n" +
  927. " ,gls.materialcode\n" +
  928. " ,gls.materialremark\n" +
  929. " ,gls.WaterLabelCode\n" +
  930. " ,gls.goodsModel\n" +
  931. " ,gls.goodsid\n" +
  932. " ,l.valueflag\n" +
  933. " from tp_mst_logo l\n" +
  934. " left join tp_mst_goodslogosap gls\n" +
  935. " on gls.goodsid = :goodsid\n" +
  936. " and l.logoid = gls.logoid\n" +
  937. " where (l.valueflag = '1' or gls.goodsid is not null)\n" +
  938. " order by gls.goodsid, l.valueflag desc, l.displayno";
  939. OracleParameter[] paras = new OracleParameter[]{
  940. new OracleParameter(":goodsid",goodsID),
  941. };
  942. ServiceResultEntity sre = new ServiceResultEntity();
  943. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  944. return sre;
  945. }
  946. catch (Exception ex)
  947. {
  948. throw ex;
  949. }
  950. finally
  951. {
  952. if (conn != null &&
  953. conn.ConnState == ConnectionState.Open)
  954. {
  955. conn.Close();
  956. }
  957. }
  958. }
  959. #endregion
  960. #region 获得生产工号集合
  961. /// <summary>
  962. /// 获得生产工号集合
  963. /// </summary>
  964. /// <param name="sUserInfo">用户基本信息</param>
  965. /// <returns>DataSet</returns>
  966. /// <remarks>
  967. /// 陈冰 2014.09.03 新建
  968. /// </remarks>
  969. public static DataSet GetWorker(SUserInfo sUserInfo)
  970. {
  971. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  972. try
  973. {
  974. con.Open();
  975. OracleParameter[] paras = new OracleParameter[]{
  976. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  977. new OracleParameter("rs_worker",OracleDbType.RefCursor,ParameterDirection.Output),
  978. };
  979. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetWorker", paras);
  980. return ds;
  981. }
  982. catch (Exception ex)
  983. {
  984. throw ex;
  985. }
  986. finally
  987. {
  988. if (con.ConnState == ConnectionState.Open)
  989. {
  990. con.Close();
  991. }
  992. }
  993. }
  994. #endregion
  995. #region 获得工种集合
  996. /// <summary>
  997. /// 获得工种集合
  998. /// </summary>
  999. /// <param name="sUserInfo">用户基本信息</param>
  1000. /// <returns>DataSet</returns>
  1001. /// <remarks>
  1002. /// 陈冰 2014.09.03 新建
  1003. /// </remarks>
  1004. public static DataSet GetJobs(SUserInfo sUserInfo)
  1005. {
  1006. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1007. try
  1008. {
  1009. con.Open();
  1010. OracleParameter[] paras = new OracleParameter[]{
  1011. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  1012. new OracleParameter("rs_jobs",OracleDbType.RefCursor,ParameterDirection.Output),
  1013. };
  1014. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetJobs", paras);
  1015. return ds;
  1016. }
  1017. catch (Exception ex)
  1018. {
  1019. throw ex;
  1020. }
  1021. finally
  1022. {
  1023. if (con.ConnState == ConnectionState.Open)
  1024. {
  1025. con.Close();
  1026. }
  1027. }
  1028. }
  1029. #endregion
  1030. #region 获得缺陷集合
  1031. /// <summary>
  1032. /// 获得缺陷集合
  1033. /// </summary>
  1034. /// <param name="sUserInfo">用户基本信息</param>
  1035. /// <returns>DataSet</returns>
  1036. /// <remarks>
  1037. /// 陈冰 2014.09.03 新建
  1038. /// </remarks>
  1039. public static DataSet GetDefect(SUserInfo sUserInfo)
  1040. {
  1041. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1042. try
  1043. {
  1044. con.Open();
  1045. OracleParameter[] paras = new OracleParameter[]{
  1046. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  1047. new OracleParameter("rs_defect",OracleDbType.RefCursor,ParameterDirection.Output),
  1048. };
  1049. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetDefect", paras);
  1050. return ds;
  1051. }
  1052. catch (Exception ex)
  1053. {
  1054. throw ex;
  1055. }
  1056. finally
  1057. {
  1058. if (con.ConnState == ConnectionState.Open)
  1059. {
  1060. con.Close();
  1061. }
  1062. }
  1063. }
  1064. #endregion
  1065. #region 产品图片
  1066. /// <summary>
  1067. /// 根据产品ID获取产品图片
  1068. /// </summary>
  1069. /// <param name="sUserInfo">用户基本信息</param>
  1070. /// <param name="goodsId">产品ID</param>
  1071. /// <returns>DataSet</returns>
  1072. /// <remarks>
  1073. /// 庄天威 2014.09.04 新建
  1074. /// </remarks>
  1075. public static DataSet GetImageByGoodsId(SUserInfo sUserInfo, int goodsId)
  1076. {
  1077. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1078. try
  1079. {
  1080. con.Open();
  1081. OracleParameter[] paras = new OracleParameter[]{
  1082. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  1083. new OracleParameter("in_goodsID",OracleDbType.Int32,goodsId,ParameterDirection.Input),
  1084. new OracleParameter("rs_result",OracleDbType.RefCursor,ParameterDirection.Output),
  1085. };
  1086. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetImageByGoodsId", paras);
  1087. return ds;
  1088. }
  1089. catch (Exception ex)
  1090. {
  1091. throw ex;
  1092. }
  1093. finally
  1094. {
  1095. if (con.ConnState == ConnectionState.Open)
  1096. {
  1097. con.Close();
  1098. }
  1099. }
  1100. }
  1101. #endregion
  1102. #region 附件
  1103. /// <summary>
  1104. /// 新建附件信息
  1105. /// </summary>
  1106. /// <param name="AttList">附件实体集合</param>
  1107. /// <param name="mainId">产品ID</param>
  1108. /// <param name="userInfo">用户基本信息</param>
  1109. /// <returns>int影响结果行数</returns>
  1110. public static int AddAttachment(List<GoodsAttachmentEntity> AttList, int mainId, SUserInfo userInfo)
  1111. {
  1112. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  1113. try
  1114. {
  1115. oracleTrConn.Connect();
  1116. int AttReturn = 0;
  1117. int GAReturn = 0;
  1118. StringBuilder sbSql = new StringBuilder();
  1119. foreach (GoodsAttachmentEntity attFor in AttList)
  1120. {
  1121. sbSql.Clear();
  1122. sbSql.Append("select SEQ_MST_Attachment_ID.nextval from dual");
  1123. int id = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  1124. sbSql.Clear();
  1125. sbSql.Append(@"Insert into TP_MST_Attachment(AttachmentID,FileName,FilePath,AccountID,ValueFlag,
  1126. CreateUserID,UpdateUserID)
  1127. Values(:AttachmentID,:FileName,:FilePath,:AccountID,:ValueFlag,
  1128. :CreateUserID,:UpdateUserID)");
  1129. OracleParameter[] attParas = new OracleParameter[] {
  1130. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  1131. id,ParameterDirection.Input),
  1132. new OracleParameter(":FileName",OracleDbType.NVarchar2,
  1133. attFor.FileName,ParameterDirection.Input),
  1134. new OracleParameter(":FilePath",OracleDbType.NVarchar2,
  1135. attFor.FilePath,ParameterDirection.Input),
  1136. new OracleParameter(":AccountID",OracleDbType.Int32,
  1137. userInfo.AccountID,ParameterDirection.Input),
  1138. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  1139. 1,ParameterDirection.Input),
  1140. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  1141. userInfo.UserID,ParameterDirection.Input),
  1142. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  1143. userInfo.UserID,ParameterDirection.Input)
  1144. };
  1145. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  1146. sbSql.Clear();
  1147. sbSql.Append(@"Insert into TP_MST_GoodsAttachment(GoodsID,AttachmentID,CreateUserID,UpdateUserID)
  1148. Values(:GoodsID,:AttachmentID,:CreateUserID,:UpdateUserID)");
  1149. OracleParameter[] gaParas = new OracleParameter[] {
  1150. new OracleParameter(":GoodsID",OracleDbType.Int32,
  1151. mainId,ParameterDirection.Input),
  1152. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  1153. id,ParameterDirection.Input),
  1154. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  1155. userInfo.UserID,ParameterDirection.Input),
  1156. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  1157. userInfo.UserID,ParameterDirection.Input)
  1158. };
  1159. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), gaParas);
  1160. sbSql.Clear();
  1161. }
  1162. oracleTrConn.Commit();
  1163. oracleTrConn.Disconnect();
  1164. return AttReturn;
  1165. }
  1166. catch (Exception ex)
  1167. {
  1168. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  1169. {
  1170. oracleTrConn.Rollback();
  1171. oracleTrConn.Disconnect();
  1172. }
  1173. throw ex;
  1174. }
  1175. }
  1176. /// <summary>
  1177. /// 修改附件信息
  1178. /// </summary>
  1179. /// <param name="AttList">附件实体集合</param>
  1180. /// <param name="mainId">产品ID</param>
  1181. /// <param name="userInfo">用户基本信息</param>
  1182. /// <returns>int受影响行数</returns>
  1183. public static int UpdateAttachment(List<GoodsAttachmentEntity> AttList, int mainId, SUserInfo userInfo)
  1184. {
  1185. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  1186. try
  1187. {
  1188. oracleTrConn.Connect();
  1189. int AttReturn = 0;
  1190. int GAReturn = 0;
  1191. StringBuilder sbSql = new StringBuilder();
  1192. foreach (GoodsAttachmentEntity attFor in AttList)
  1193. {
  1194. if (attFor.IsUpdateAdd == 0) //不是新建的
  1195. {
  1196. sbSql.Clear();
  1197. sbSql.Append(@"Update TP_MST_Attachment set ValueFlag = :ValueFlag,UpdateUserID=:UpdateUserID
  1198. Where AttachmentID = :AttachmentID");
  1199. OracleParameter[] attParas = new OracleParameter[] {
  1200. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  1201. attFor.ValueFlag,ParameterDirection.Input),
  1202. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  1203. userInfo.UserID,ParameterDirection.Input),
  1204. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  1205. attFor.AttachmentID,ParameterDirection.Input)
  1206. };
  1207. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  1208. sbSql.Clear();
  1209. sbSql.Append(@"Update TP_MST_GoodsAttachment
  1210. Set ValueFlag = :ValueFlag,UpdateUserID=:UpdateUserID
  1211. Where AttachmentID = :AttachmentID");
  1212. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  1213. sbSql.Clear();
  1214. }
  1215. else //新建的
  1216. {
  1217. sbSql.Clear();
  1218. sbSql.Append("select SEQ_MST_Attachment_ID.nextval from dual");
  1219. int id = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  1220. sbSql.Clear();
  1221. sbSql.Append(@"Insert into TP_MST_Attachment(AttachmentID,FileName,FilePath,AccountID,ValueFlag,
  1222. CreateUserID,UpdateUserID)
  1223. Values(:AttachmentID,:FileName,:FilePath,:AccountID,:ValueFlag,
  1224. :CreateUserID,:UpdateUserID)");
  1225. OracleParameter[] attParas = new OracleParameter[] {
  1226. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  1227. id,ParameterDirection.Input),
  1228. new OracleParameter(":FileName",OracleDbType.NVarchar2,
  1229. attFor.FileName,ParameterDirection.Input),
  1230. new OracleParameter(":FilePath",OracleDbType.NVarchar2,
  1231. attFor.FilePath,ParameterDirection.Input),
  1232. new OracleParameter(":AccountID",OracleDbType.Int32,
  1233. userInfo.AccountID,ParameterDirection.Input),
  1234. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  1235. 1,ParameterDirection.Input),
  1236. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  1237. userInfo.UserID,ParameterDirection.Input),
  1238. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  1239. userInfo.UserID,ParameterDirection.Input)
  1240. };
  1241. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  1242. sbSql.Clear();
  1243. sbSql.Append(@"Insert into TP_MST_GoodsAttachment(GoodsID,AttachmentID,CreateUserID,UpdateUserID)
  1244. Values(:GoodsID,:AttachmentID,:CreateUserID,:UpdateUserID)");
  1245. OracleParameter[] gaParas = new OracleParameter[] {
  1246. new OracleParameter(":GoodsID",OracleDbType.Int32,
  1247. mainId,ParameterDirection.Input),
  1248. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  1249. id,ParameterDirection.Input),
  1250. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  1251. userInfo.UserID,ParameterDirection.Input),
  1252. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  1253. userInfo.UserID,ParameterDirection.Input)
  1254. };
  1255. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), gaParas);
  1256. sbSql.Clear();
  1257. }
  1258. }
  1259. oracleTrConn.Commit();
  1260. oracleTrConn.Disconnect();
  1261. return AttReturn;
  1262. }
  1263. catch (Exception ex)
  1264. {
  1265. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  1266. {
  1267. oracleTrConn.Rollback();
  1268. oracleTrConn.Disconnect();
  1269. }
  1270. throw ex;
  1271. }
  1272. }
  1273. /// <summary>
  1274. /// 根据产品ID获取附件
  1275. /// </summary>
  1276. /// <param name="goodsId">产品ID</param>
  1277. /// <returns>DataSet</returns>
  1278. public static DataSet GetAttachmentByGoodsId(int goodsId)
  1279. {
  1280. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1281. try
  1282. {
  1283. con.Open();
  1284. String strSql = @"Select goodsAtt.GoodsID,att.* from TP_MST_GoodsAttachment goodsAtt
  1285. Inner join TP_MST_Attachment att
  1286. On goodsAtt.AttachmentID = att.AttachmentID
  1287. Where goodsAtt.ValueFlag = 1 and goodsAtt.GoodsID = " + goodsId;
  1288. DataSet ds = con.GetSqlResultToDs(strSql, null);
  1289. return ds;
  1290. }
  1291. catch (Exception ex)
  1292. {
  1293. throw ex;
  1294. }
  1295. finally
  1296. {
  1297. if (con.ConnState == ConnectionState.Open)
  1298. {
  1299. con.Close();
  1300. }
  1301. }
  1302. }
  1303. #endregion
  1304. #region 缺陷位置
  1305. /// <summary>
  1306. /// 获取缺陷位置
  1307. /// </summary>
  1308. /// <param name="dpEntity">缺陷位置实体</param>
  1309. /// <param name="userInfo">用户基本信息</param>
  1310. /// <returns>DataSet</returns>
  1311. public static DataSet GetDefectPosition(DefectPositionEntity dpEntity, SUserInfo userInfo)
  1312. {
  1313. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1314. try
  1315. {
  1316. con.Open();
  1317. OracleParameter[] paras = new OracleParameter[]{
  1318. new OracleParameter("in_DefectPositionID",OracleDbType.Int32,
  1319. dpEntity.DefectPositionID,ParameterDirection.Input),
  1320. new OracleParameter("in_DefectPositionCode",OracleDbType.NVarchar2,
  1321. dpEntity.DefectPositionCode,ParameterDirection.Input),
  1322. new OracleParameter("in_DefectPositionName",OracleDbType.NVarchar2,
  1323. dpEntity.DefectPositionName,ParameterDirection.Input),
  1324. new OracleParameter("in_AccountID",OracleDbType.Int32,
  1325. userInfo.AccountID,ParameterDirection.Input),
  1326. new OracleParameter("out_rs_defect",OracleDbType.RefCursor,ParameterDirection.Output),
  1327. };
  1328. DataSet dsDefectPosition = con.ExecStoredProcedure("PRO_MST_GetDefectPosition", paras);
  1329. return dsDefectPosition;
  1330. }
  1331. catch (Exception ex)
  1332. {
  1333. throw ex;
  1334. }
  1335. finally
  1336. {
  1337. if (con.ConnState == ConnectionState.Open)
  1338. {
  1339. con.Close();
  1340. }
  1341. }
  1342. }
  1343. /// <summary>
  1344. /// 根据产品获得产品缺陷位置
  1345. /// </summary>
  1346. /// <param name="GoodsId">产品ID</param>
  1347. /// <returns>DataSet</returns>
  1348. public static DataSet getGoodsDefectPositionByGoodsId(int GoodsId)
  1349. {
  1350. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1351. try
  1352. {
  1353. con.Open();
  1354. string sql = @"select gdp.*,dp.DefectPositionCode,dp.DefectPositionName,dp.Remarks
  1355. from TP_MST_GoodsDefectPosition gdp
  1356. inner join TP_MST_DefectPosition dp
  1357. on gdp.DefectPositionID=dp.DefectPositionID
  1358. where gdp.GoodsID=" + GoodsId;
  1359. DataSet dsDefectPosition = con.GetSqlResultToDs(sql, null);
  1360. return dsDefectPosition;
  1361. }
  1362. catch (Exception ex)
  1363. {
  1364. throw ex;
  1365. }
  1366. finally
  1367. {
  1368. if (con.ConnState == ConnectionState.Open)
  1369. {
  1370. con.Close();
  1371. }
  1372. }
  1373. }
  1374. /// <summary>
  1375. /// 保存产品缺陷位置关联(依附在添加产品中)
  1376. /// </summary>
  1377. /// <param name="dpList">缺陷位置集</param>
  1378. /// <param name="GoodsId">产品ID</param>
  1379. /// <param name="userInfo">用户基本信息</param>
  1380. /// <returns>int</returns>
  1381. public static int SaveGoodsDefectPosition(IDBTransaction oracleTrConn, List<int> dpList, int GoodsId, SUserInfo userInfo)
  1382. {
  1383. try
  1384. {
  1385. int ReturnCount = 0;
  1386. string sql = "Delete from TP_MST_GoodsDefectPosition where GoodsId=" + GoodsId;
  1387. foreach (int dpFor in dpList)
  1388. {
  1389. string sqlAdd = @"Insert into TP_MST_GoodsDefectPosition(GoodsID,DefectPositionID,
  1390. CreateTime,CreateUserID) Values(:GoodsID,:DefectPositionID,sysdate,:CreateUserID)";
  1391. OracleParameter[] paras = new OracleParameter[]{
  1392. new OracleParameter(":GoodsID",OracleDbType.Int32,
  1393. GoodsId,ParameterDirection.Input),
  1394. new OracleParameter(":DefectPositionID",OracleDbType.Int32,
  1395. dpFor,ParameterDirection.Input),
  1396. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  1397. userInfo.UserID,ParameterDirection.Input),
  1398. };
  1399. ReturnCount += oracleTrConn.ExecuteNonQuery(sqlAdd, paras);
  1400. }
  1401. return ReturnCount;
  1402. }
  1403. catch (Exception ex)
  1404. {
  1405. throw ex;
  1406. }
  1407. }
  1408. #endregion
  1409. #region 成型线类型
  1410. /// <summary>
  1411. /// 获取成型线类型
  1412. /// </summary>
  1413. /// <param name="userInfo">用户基本信息</param>
  1414. /// <returns>数据集</returns>
  1415. /// <remarks>
  1416. /// 庄天威 2014.09.04 新建
  1417. /// </remarks>
  1418. public static DataSet GetGMouldType(SUserInfo userInfo)
  1419. {
  1420. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1421. try
  1422. {
  1423. con.Open();
  1424. OracleParameter[] paras = new OracleParameter[]{
  1425. new OracleParameter("in_accountID",OracleDbType.Int32,
  1426. userInfo.AccountID,ParameterDirection.Input),
  1427. new OracleParameter("in_valueFlag",OracleDbType.Int32,
  1428. 1,ParameterDirection.Input),
  1429. new OracleParameter("out_result",OracleDbType.RefCursor,ParameterDirection.Output),
  1430. };
  1431. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetMouldType", paras);
  1432. return ds;
  1433. }
  1434. catch (Exception ex)
  1435. {
  1436. throw ex;
  1437. }
  1438. finally
  1439. {
  1440. if (con.ConnState == ConnectionState.Open)
  1441. {
  1442. con.Close();
  1443. }
  1444. }
  1445. }
  1446. #endregion
  1447. #region 产品分级数据源
  1448. /// <summary>
  1449. /// 产品分级数据源
  1450. /// </summary>
  1451. /// <param name="type">1适用半成品2检验 2适用成品检验 3入窑前检验</param>
  1452. /// <param name="userInfo">用户基本信息</param>
  1453. /// <returns>DataSet</returns>
  1454. public static DataSet GetGoodsLevel(int type, SUserInfo userInfo)
  1455. {
  1456. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1457. try
  1458. {
  1459. con.Open();
  1460. string sqlString = "";
  1461. if (type == 1 || type == 3)
  1462. {
  1463. 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";
  1464. }
  1465. else if (type == 2)
  1466. {
  1467. 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";
  1468. }
  1469. OracleParameter[] paras = new OracleParameter[]{
  1470. new OracleParameter(":AccountID",userInfo.AccountID),
  1471. };
  1472. DataSet dsGoodsLevel = con.GetSqlResultToDs(sqlString, paras);
  1473. return dsGoodsLevel;
  1474. }
  1475. catch (Exception ex)
  1476. {
  1477. throw ex;
  1478. }
  1479. finally
  1480. {
  1481. if (con.ConnState == ConnectionState.Open)
  1482. {
  1483. con.Close();
  1484. }
  1485. }
  1486. }
  1487. #endregion
  1488. #region 审核状态
  1489. /// <summary>
  1490. /// 获取全部审核状态
  1491. /// </summary>
  1492. /// <returns>DataSet审核状态数据源</returns>
  1493. public static DataSet GetAuditStatus()
  1494. {
  1495. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1496. try
  1497. {
  1498. con.Open();
  1499. String strSql = "Select * from TP_SYS_AuditStatus Order by DisplayNo";
  1500. DataSet ds = con.GetSqlResultToDs(strSql, null);
  1501. return ds;
  1502. }
  1503. catch (Exception ex)
  1504. {
  1505. throw ex;
  1506. }
  1507. finally
  1508. {
  1509. if (con.ConnState == ConnectionState.Open)
  1510. {
  1511. con.Close();
  1512. }
  1513. }
  1514. }
  1515. #endregion
  1516. /// <summary>
  1517. /// 工序集合
  1518. /// </summary>
  1519. /// <param name="ProductionLineEntity">工序实体</param>
  1520. /// <param name="sUserInfo">用户<基本信息/param>
  1521. /// <returns>DataSet</returns>
  1522. /// <remarks>
  1523. /// 王鑫 2014.11.29 新建
  1524. /// </remarks>
  1525. public static DataSet GetProdureList(SearchProductionLineEntity productionLineEntity, SUserInfo sUserInfo)
  1526. {
  1527. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1528. try
  1529. {
  1530. con.Open();
  1531. OracleParameter[] paras = new OracleParameter[]{
  1532. new OracleParameter("in_procedureCode",OracleDbType.Varchar2,productionLineEntity.ProductionLineCode,ParameterDirection.Input),
  1533. new OracleParameter("in_procedureName",OracleDbType.Varchar2,productionLineEntity.ProductionLineName,ParameterDirection.Input),
  1534. new OracleParameter("in_procedureIDS",OracleDbType.Varchar2,productionLineEntity.ProcuteLineIDS,ParameterDirection.Input),
  1535. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  1536. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  1537. };
  1538. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_PC_GetProcedureList", paras);
  1539. return dsSearchReport;
  1540. }
  1541. catch (Exception ex)
  1542. {
  1543. throw ex;
  1544. }
  1545. finally
  1546. {
  1547. if (con.ConnState == ConnectionState.Open)
  1548. {
  1549. con.Close();
  1550. }
  1551. }
  1552. }
  1553. /// <summary>
  1554. /// 获取全部工种计件方式
  1555. /// </summary>
  1556. /// <returns>DataSet工种计件方式集合</returns>
  1557. public static DataSet GetJobsPriceType()
  1558. {
  1559. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1560. try
  1561. {
  1562. con.Open();
  1563. String strSql = "Select * from TP_SYS_JobsPriceType Order by DisplayNo";
  1564. DataSet dsSearchReport = con.GetSqlResultToDs(strSql, null);
  1565. return dsSearchReport;
  1566. }
  1567. catch (Exception ex)
  1568. {
  1569. throw ex;
  1570. }
  1571. finally
  1572. {
  1573. if (con.ConnState == ConnectionState.Open)
  1574. {
  1575. con.Close();
  1576. }
  1577. }
  1578. }
  1579. #region 工位
  1580. #region 工位配置
  1581. /// <summary>
  1582. /// 获取工位
  1583. /// </summary>
  1584. /// <param name="cre"></param>
  1585. /// <param name="sUserInfo"></param>
  1586. /// <returns></returns>
  1587. public static ServiceResultEntity GetWorkStation(ClientRequestEntity cre, SUserInfo sUserInfo)
  1588. {
  1589. ServiceResultEntity sre = new ServiceResultEntity();
  1590. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1591. try
  1592. {
  1593. string sqlString = string.Empty;
  1594. List<OracleParameter> paras = new List<OracleParameter>();
  1595. con.Open();
  1596. sqlString = "SELECT ws.workstationid\n" +
  1597. " ,ws.workstationname\n" +
  1598. " ,p.procedurename\n" +
  1599. " ,ws.remarks\n" +
  1600. " FROM tp_mst_workstation ws\n" +
  1601. " LEFT JOIN tp_pc_procedure p\n" +
  1602. " ON p.procedureid = ws.procedureid\n" +
  1603. " WHERE ws.valueflag = '1'\n" +
  1604. " AND ws.accountid = :accountid";
  1605. paras.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  1606. if (!string.IsNullOrEmpty(cre.Properties["workstationname"] + ""))
  1607. {
  1608. sqlString += " AND ws.workstationname LIKE :workstationname ";
  1609. paras.Add(new OracleParameter(":workstationname", "%" + cre.Properties["workstationname"] + "%"));
  1610. }
  1611. if (!string.IsNullOrEmpty(cre.Properties["remarks"] + ""))
  1612. {
  1613. sqlString += " AND ws.remarks LIKE :remarks ";
  1614. paras.Add(new OracleParameter(":remarks", "%" + cre.Properties["remarks"] + "%"));
  1615. }
  1616. sqlString += " ORDER BY ws.displayno";
  1617. sre.Data = con.GetSqlResultToDs(sqlString, paras.ToArray());
  1618. return sre;
  1619. }
  1620. catch (Exception ex)
  1621. {
  1622. throw ex;
  1623. }
  1624. finally
  1625. {
  1626. if (con.ConnState == ConnectionState.Open)
  1627. {
  1628. con.Close();
  1629. }
  1630. }
  1631. }
  1632. /// <summary>
  1633. /// 获取工位工号
  1634. /// </summary>
  1635. /// <param name="sUserInfo"></param>
  1636. /// <returns></returns>
  1637. public static ServiceResultEntity GetWorkStationUser(int workStationID)
  1638. {
  1639. ServiceResultEntity sre = new ServiceResultEntity();
  1640. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1641. try
  1642. {
  1643. string sqlString =
  1644. "SELECT u.userid\n" +
  1645. " ,u.usercode\n" +
  1646. " ,u.username\n" +
  1647. " ,o.organizationid\n" +
  1648. " ,o.organizationname\n" +
  1649. " ,o.organizationfullname\n" +
  1650. " ,o.telephone\n" +
  1651. " ,u.remarks\n" +
  1652. " ,0 as addflag\n" +
  1653. " FROM tp_mst_user u\n" +
  1654. " LEFT JOIN tp_mst_organization o\n" +
  1655. " ON o.organizationid = u.organizationid\n" +
  1656. " WHERE EXISTS (SELECT 1\n" +
  1657. " FROM tp_mst_workstationuser wsu\n" +
  1658. " WHERE wsu.userid = u.userid\n" +
  1659. " AND wsu.workstationid = :workstationid)\n" +
  1660. " ORDER BY u.usercode";
  1661. OracleParameter[] paras = new OracleParameter[]
  1662. {
  1663. new OracleParameter(":workstationid", workStationID)
  1664. };
  1665. con.Open();
  1666. sre.Data = con.GetSqlResultToDs(sqlString, paras);
  1667. return sre;
  1668. }
  1669. catch (Exception ex)
  1670. {
  1671. throw ex;
  1672. }
  1673. finally
  1674. {
  1675. if (con.ConnState == ConnectionState.Open)
  1676. {
  1677. con.Close();
  1678. }
  1679. }
  1680. }
  1681. /// <summary>
  1682. /// 保存工位工号
  1683. /// </summary>
  1684. /// <param name="SProductEntity"></param>
  1685. /// <param name="userInfo"></param>
  1686. /// <returns></returns>
  1687. public static ServiceResultEntity SaveWorkStationUser(ClientRequestEntity cre, SUserInfo sUserInfo)
  1688. {
  1689. ServiceResultEntity sre = new ServiceResultEntity();
  1690. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  1691. try
  1692. {
  1693. string sqlString = string.Empty;
  1694. OracleParameter[] paras = null;
  1695. int workstationid = Convert.ToInt32(cre.Properties["workststionid"]);
  1696. oracleTrConn.Connect();
  1697. // 校验当前工号是否配置该工位
  1698. sqlString = "SELECT 1\n" +
  1699. " FROM tp_mst_workstation w\n" +
  1700. " WHERE w.workstationid = :workstationid";
  1701. paras = new OracleParameter[]
  1702. {
  1703. new OracleParameter(":workstationid", workstationid)
  1704. };
  1705. object isExists = oracleTrConn.GetSqlResultToObj(sqlString, paras);
  1706. if (isExists == null)
  1707. {
  1708. sre.OtherStatus = -1;
  1709. sre.Message = "当前工位不存在";
  1710. return sre;
  1711. }
  1712. // 删除当前工位工号
  1713. sqlString = "DELETE FROM tp_mst_workstationuser wu WHERE wu.workstationid = :workstationid";
  1714. paras = new OracleParameter[]
  1715. {
  1716. new OracleParameter(":workstationid", workstationid)
  1717. };
  1718. sre.OtherStatus += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  1719. // 保存工位工号
  1720. sqlString = "INSERT INTO tp_mst_workstationuser\n" +
  1721. " (workstationid\n" +
  1722. " ,userid\n" +
  1723. " ,usercode\n" +
  1724. " ,accountid\n" +
  1725. " ,createuserid\n" +
  1726. " ,updateuserid\n" +
  1727. " ,organizationid)\n" +
  1728. " SELECT :workstationid\n" +
  1729. " ,u.userid\n" +
  1730. " ,u.usercode\n" +
  1731. " ,:accountid\n" +
  1732. " ,:createuserid\n" +
  1733. " ,:createuserid\n" +
  1734. " ,u.organizationid\n" +
  1735. " FROM tp_mst_user u\n" +
  1736. " WHERE u.userid = :userid";
  1737. foreach (DataRow row in cre.Data.Tables[0].Rows)
  1738. {
  1739. paras = new OracleParameter[]
  1740. {
  1741. new OracleParameter(":workstationid", workstationid),
  1742. new OracleParameter(":userid", row["userid"]),
  1743. new OracleParameter(":accountid", sUserInfo.AccountID),
  1744. new OracleParameter(":createuserid", sUserInfo.UserID)
  1745. };
  1746. sre.OtherStatus += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  1747. }
  1748. oracleTrConn.Commit();
  1749. oracleTrConn.Disconnect();
  1750. }
  1751. catch (Exception ex)
  1752. {
  1753. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  1754. {
  1755. oracleTrConn.Rollback();
  1756. oracleTrConn.Disconnect();
  1757. }
  1758. throw new Exception(ex.ToString(), ex);
  1759. }
  1760. finally
  1761. {
  1762. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  1763. {
  1764. oracleTrConn.Disconnect();
  1765. }
  1766. }
  1767. return sre;
  1768. }
  1769. #endregion
  1770. #region 工位打卡
  1771. /// <summary>
  1772. /// 获取工号工位
  1773. /// </summary>
  1774. /// <param name="sUserInfo"></param>
  1775. /// <returns></returns>
  1776. public static ServiceResultEntity GetUserWorkStation(SUserInfo sUserInfo)
  1777. {
  1778. ServiceResultEntity sre = new ServiceResultEntity();
  1779. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1780. try
  1781. {
  1782. string sqlString =
  1783. "SELECT w.workstationid\n" +
  1784. " ,w.workstationname\n" +
  1785. " FROM tp_mst_workstationuser wu\n" +
  1786. " INNER JOIN tp_mst_workstation w\n" +
  1787. " ON w.workstationid = wu.workstationid\n" +
  1788. " WHERE w.valueflag = '1'\n" +
  1789. " AND wu.usercode = :usercode\n" +
  1790. " ORDER BY w.displayno";
  1791. OracleParameter[] paras = new OracleParameter[]
  1792. {
  1793. new OracleParameter(":usercode", sUserInfo.UserCode)
  1794. };
  1795. con.Open();
  1796. sre.Data = con.GetSqlResultToDs(sqlString, paras);
  1797. if (sre.Data.Tables[0].Rows.Count == 0)
  1798. {
  1799. sre.Message = "当前工号未配置工位";
  1800. }
  1801. return sre;
  1802. }
  1803. catch (Exception ex)
  1804. {
  1805. throw ex;
  1806. }
  1807. finally
  1808. {
  1809. if (con.ConnState == ConnectionState.Open)
  1810. {
  1811. con.Close();
  1812. }
  1813. }
  1814. }
  1815. /// <summary>
  1816. /// 工号工位打卡
  1817. /// </summary>
  1818. /// <param name="SProductEntity"></param>
  1819. /// <param name="userInfo"></param>
  1820. /// <returns></returns>
  1821. public static ServiceResultEntity SaveUserWorkStation(int workStationID, SUserInfo userInfo)
  1822. {
  1823. ServiceResultEntity sre = new ServiceResultEntity();
  1824. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  1825. try
  1826. {
  1827. string sqlString = string.Empty;
  1828. OracleParameter[] paras = null;
  1829. oracleTrConn.Connect();
  1830. // 校验当前工号是否配置该工位
  1831. sqlString = "SELECT 1\n" +
  1832. " FROM tp_mst_workstationuser wu\n" +
  1833. " WHERE wu.userid = :userid\n" +
  1834. " AND wu.workstationid = :workstationid";
  1835. paras = new OracleParameter[]
  1836. {
  1837. new OracleParameter(":userid", userInfo.UserID),
  1838. new OracleParameter(":workstationid", workStationID)
  1839. };
  1840. object isExists = oracleTrConn.GetSqlResultToObj(sqlString, paras);
  1841. if (isExists == null)
  1842. {
  1843. sre.OtherStatus = -1;
  1844. sre.Message = "当前工号未配置该工位";
  1845. return sre;
  1846. }
  1847. // 删除当前工号在任何一个工位,以确保当前工号在工位中唯一
  1848. sqlString = "UPDATE tp_mst_workstation\n" +
  1849. " SET usercode = NULL\n" +
  1850. " WHERE usercode = :usercode";
  1851. paras = new OracleParameter[]
  1852. {
  1853. new OracleParameter(":usercode", userInfo.UserCode)
  1854. };
  1855. sre.OtherStatus += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  1856. // 更新工位当前工号
  1857. sqlString = "UPDATE tp_mst_workstation\n" +
  1858. " SET usercode = :usercode\n" +
  1859. " ,updateuserid = :userid\n" +
  1860. " WHERE workstationid = :workstationid";
  1861. paras = new OracleParameter[]
  1862. {
  1863. new OracleParameter(":usercode", userInfo.UserCode),
  1864. new OracleParameter(":userid", userInfo.UserID),
  1865. new OracleParameter(":workstationid", workStationID)
  1866. };
  1867. sre.OtherStatus += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  1868. oracleTrConn.Commit();
  1869. oracleTrConn.Disconnect();
  1870. }
  1871. catch (Exception ex)
  1872. {
  1873. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  1874. {
  1875. oracleTrConn.Rollback();
  1876. oracleTrConn.Disconnect();
  1877. }
  1878. throw new Exception(ex.ToString(), ex);
  1879. }
  1880. finally
  1881. {
  1882. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  1883. {
  1884. oracleTrConn.Disconnect();
  1885. }
  1886. }
  1887. return sre;
  1888. }
  1889. #endregion
  1890. #endregion
  1891. }
  1892. }