SystemModuleLogicPartial.cs 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:SystemModuleLogic.cs
  5. * 2.功能描述:产品档案数据查询处理
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/09/12 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Text;
  14. using Dongke.IBOSS.PRD.Basics.DataAccess;
  15. using Dongke.IBOSS.PRD.Service.DataModels;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Oracle.ManagedDataAccess.Client;
  18. namespace Dongke.IBOSS.PRD.Service.SystemModuleLogic
  19. {
  20. /// <summary>
  21. /// 产品档案数据查询处理
  22. /// </summary>
  23. public partial class SystemModuleLogic
  24. {
  25. #region 产品档案
  26. /// <summary>
  27. /// 查询产品信息
  28. /// </summary>
  29. /// <param name="sUserInfo">用户基本信息</param>
  30. /// <param name="goodsEntity">产品信息</param>
  31. /// <returns>DataSet</returns>
  32. /// <remarks>
  33. /// 陈冰 2014.09.01 新建
  34. /// </remarks>
  35. public static DataSet SerachGoods(SUserInfo sUserInfo, GoodsEntity goodsEntity)
  36. {
  37. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  38. try
  39. {
  40. con.Open();
  41. if (!string.IsNullOrWhiteSpace(goodsEntity.GoodsCodeOnly))
  42. {
  43. string sql = "select goodsid from tp_mst_goods g where g.goodscode = :goodscode";
  44. OracleParameter[] paras1 = new OracleParameter[]{
  45. new OracleParameter(":goodscode",OracleDbType.Varchar2,
  46. goodsEntity.GoodsCodeOnly,ParameterDirection.Input),
  47. };
  48. return con.GetSqlResultToDs(sql, paras1);
  49. }
  50. OracleParameter[] paras = new OracleParameter[]{
  51. new OracleParameter("account",OracleDbType.Int32,
  52. sUserInfo.AccountID,ParameterDirection.Input),
  53. new OracleParameter("goodsID",OracleDbType.Int32,
  54. goodsEntity.GoodsID,ParameterDirection.Input),
  55. new OracleParameter("goodsCode",OracleDbType.NVarchar2,
  56. goodsEntity.GoodsCode,ParameterDirection.Input),
  57. new OracleParameter("goodsName",OracleDbType.NVarchar2,
  58. goodsEntity.GoodsName,ParameterDirection.Input),
  59. new OracleParameter("goodsSpecification",OracleDbType.NVarchar2,
  60. goodsEntity.GoodsSpecification,ParameterDirection.Input),
  61. new OracleParameter("goodsModel",OracleDbType.NVarchar2,
  62. goodsEntity.GoodsModel,ParameterDirection.Input),
  63. new OracleParameter("goodsTypeCode",OracleDbType.NVarchar2,
  64. goodsEntity.GoodsTypeCode,ParameterDirection.Input),
  65. new OracleParameter("glazeTypeID",OracleDbType.Int32,
  66. goodsEntity.GlazeTypeID,ParameterDirection.Input),
  67. new OracleParameter("ceaseFlag",OracleDbType.NVarchar2,
  68. goodsEntity.CeaseFlag,ParameterDirection.Input),
  69. new OracleParameter("remarks",OracleDbType.NVarchar2,
  70. goodsEntity.Remarks,ParameterDirection.Input),
  71. new OracleParameter("valueFlag",OracleDbType.NVarchar2,
  72. goodsEntity.ValueFlag,ParameterDirection.Input),
  73. new OracleParameter("rs_result",OracleDbType.RefCursor,ParameterDirection.Output),
  74. new OracleParameter("rs_result_img",OracleDbType.RefCursor,ParameterDirection.Output),
  75. };
  76. foreach (OracleParameter item in paras)
  77. {
  78. if (item.Value + "" == "")
  79. {
  80. item.Value = DBNull.Value;
  81. }
  82. }
  83. DataSet ds = con.ExecStoredProcedure("PRO_MST_SerachGoods", paras);
  84. return ds;
  85. }
  86. catch (Exception ex)
  87. {
  88. throw ex;
  89. }
  90. finally
  91. {
  92. if (con.ConnState == ConnectionState.Open)
  93. {
  94. con.Close();
  95. }
  96. }
  97. }
  98. /// <summary>
  99. /// 新建产品档案
  100. /// </summary>
  101. /// <param name="sUserInfo">用户基本信息</param>
  102. /// <param name="goodsEntity">产品实体</param>
  103. /// <param name="imgList">产品图片集合</param>
  104. /// <param name="attList">缺陷位置ID集合</param>
  105. /// <returns>int受影响行数</returns>
  106. /// <remarks>
  107. /// 庄天威 2014.09.04 新建
  108. /// </remarks>
  109. public static int AddGoods(SUserInfo sUserInfo, GoodsEntity goodsEntity
  110. , List<GoodsImageEntity> imgList, List<GoodsAttachmentEntity> attList)
  111. {
  112. int returnRows;
  113. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  114. if (goodsEntity.MudQuantity == null)
  115. {
  116. goodsEntity.MudQuantity = 0;
  117. }
  118. if (goodsEntity.GlazeQuantity == null)
  119. {
  120. goodsEntity.GlazeQuantity = 0;
  121. }
  122. if (goodsEntity.Remarks == null)
  123. {
  124. goodsEntity.Remarks = "";
  125. }
  126. if (goodsEntity.GoodsSpecification == null)
  127. {
  128. goodsEntity.GoodsSpecification = "";
  129. }
  130. if (goodsEntity.GoodsModel == null)
  131. {
  132. goodsEntity.GoodsModel = "";
  133. }
  134. try
  135. {
  136. oracleTrConn.Connect();
  137. // 物料编码重复验证 add by chenxy 2017-07-11 begin
  138. // 有不同编码,同物料编码的情况 delete by chenxy 2017-11-10
  139. //string sqlString = "SELECT g.goodscode \n" +
  140. //" FROM tp_mst_goods g\n" +
  141. //" WHERE g.materialcode = :materialcode";
  142. //OracleParameter[] checkParas = new OracleParameter[]{
  143. // new OracleParameter(":materialcode",goodsEntity.MaterialCode),
  144. //};
  145. //string goodscode = oracleTrConn.GetSqlResultToStr(sqlString, checkParas);
  146. //if (!string.IsNullOrWhiteSpace(goodscode))
  147. //{
  148. // return -10;
  149. //}
  150. // 物料编码重复验证 add by chenxy 2017-07-11 end
  151. StringBuilder sbSql = new StringBuilder();
  152. sbSql.Append("select SEQ_MST_Goods_GoodsID.nextval from dual");
  153. int id = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  154. sbSql.Clear();
  155. sbSql.Append(" INSERT INTO TP_MST_GOODS");
  156. sbSql.Append("(GoodsID,GoodsCode,GoodsName,GoodsSpecification,GoodsModel,GoodsTypeID,");
  157. sbSql.Append("GlazeTypeID,MudWeight,GlazeWeight,LusterwareWeight,ProductionCycle,CeaseFlag,Goods_Line_Type,");
  158. sbSql.Append("StartingDate,AutoLossCycle,DeliverLimitCycle,PlateLimitNum,UnitPrice,ReservedDays,");
  159. sbSql.Append("PackageNum,OutletDistance,MaterialCode,MaterialRemark,printcopies,");
  160. sbSql.Append("MouldWeight,MouldCost,ScrapSumFlag,SEATCOVERCODE,");
  161. sbSql.Append("WaterLabelCode,StandardGroutingNum,MouldMaterialCode,MouldOutputCount,logoid,");
  162. sbSql.Append("Remarks,AccountID,ValueFlag,CreateUserID,UpdateUserID)");
  163. sbSql.Append("VALUES( :GoodsId, :GoodsCode, :GoodsName, :GoodsSpecification, :GoodsModel, :GoodsTypeID,");
  164. sbSql.Append(" :GlazeTypeID, :MudWeight, :GlazeWeight,:LusterwareWeight, :ProductionCycle, :CeaseFlag,:Goods_Line_Type,");
  165. sbSql.Append(" :StartingDate, :AutoLossCycle, :DeliverLimitCycle,:PlateLimitNum,:UnitPrice,:ReservedDays,");
  166. sbSql.Append(" :PackageNum, :OutletDistance, :MaterialCode,:MaterialRemark,:printcopies,");
  167. sbSql.Append(" :MouldWeight, :MouldCost,:ScrapSumFlag,:SEATCOVERCODE,");
  168. sbSql.Append(" :WaterLabelCode, :StandardGroutingNum, :MouldMaterialCode, :MouldOutputCount,:logoid,");
  169. sbSql.Append(" :Remarks, :AccountID, :ValueFlag, :CreateUserID, :UpdateUserID)");
  170. OracleParameter[] paras = new OracleParameter[]{
  171. new OracleParameter(":GoodsId",id),
  172. new OracleParameter(":GoodsCode",goodsEntity.GoodsCode),
  173. new OracleParameter(":GoodsName",goodsEntity.GoodsName),
  174. new OracleParameter(":GoodsSpecification",goodsEntity.GoodsSpecification),
  175. new OracleParameter(":GoodsModel",goodsEntity.GoodsModel),
  176. new OracleParameter(":GoodsTypeID",goodsEntity.GoodsTypeID),
  177. new OracleParameter(":GlazeTypeID",goodsEntity.GlazeTypeID),
  178. new OracleParameter(":MudWeight",goodsEntity.MudQuantity),
  179. new OracleParameter(":GlazeWeight",goodsEntity.GlazeQuantity),
  180. new OracleParameter(":LusterwareWeight",goodsEntity.LusterwareWeight),
  181. new OracleParameter(":ProductionCycle",goodsEntity.ProductionCycle),
  182. new OracleParameter(":CeaseFlag",goodsEntity.CeaseFlag),
  183. new OracleParameter(":Goods_Line_Type",goodsEntity.GoodsLineType),
  184. new OracleParameter(":StartingDate",goodsEntity.StartingDate),
  185. new OracleParameter(":AutoLossCycle",goodsEntity.AutoLossCycle),
  186. new OracleParameter(":DeliverLimitCycle",goodsEntity.DeliverLimitCycle),
  187. new OracleParameter(":PlateLimitNum",goodsEntity.PlateLimitNum),
  188. new OracleParameter(":ReservedDays",goodsEntity.ReservedDays),
  189. new OracleParameter(":UnitPrice",goodsEntity.UnitPrice),
  190. new OracleParameter(":PackageNum",goodsEntity.PackageNum),
  191. new OracleParameter(":OutletDistance",goodsEntity.OutletDistance),
  192. new OracleParameter(":MaterialCode",goodsEntity.MaterialCode),
  193. new OracleParameter(":MouldWeight",goodsEntity.MouldWeight),
  194. new OracleParameter(":MouldCost",goodsEntity.MouldCost),
  195. new OracleParameter(":ScrapSumFlag",goodsEntity.ScrapSumFlag),
  196. new OracleParameter(":MaterialRemark",goodsEntity.MaterialRemark),
  197. new OracleParameter(":printcopies",goodsEntity.PrintCopies),
  198. new OracleParameter(":SEATCOVERCODE", goodsEntity.SeatCoverCode),
  199. new OracleParameter(":WaterLabelCode", goodsEntity.WaterLabelCode),
  200. new OracleParameter(":StandardGroutingNum", goodsEntity.StandardGroutingNum),
  201. new OracleParameter(":MouldMaterialCode", goodsEntity.MouldMaterialCode),
  202. new OracleParameter(":MouldOutputCount", goodsEntity.MouldOutputCount),
  203. new OracleParameter(":logoid", goodsEntity.LogoID),
  204. new OracleParameter(":Remarks",goodsEntity.Remarks),
  205. new OracleParameter(":AccountID",sUserInfo.AccountID),
  206. new OracleParameter(":ValueFlag",goodsEntity.ValueFlag),
  207. //new OracleParameter(":CreateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  208. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  209. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  210. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  211. //new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,DateTime.Now,ParameterDirection.Input)
  212. };
  213. returnRows = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), paras);
  214. //SAP物料信息
  215. string sql = "delete from TP_MST_GoodsLogoSAP where goodsid = " + id;
  216. returnRows += oracleTrConn.ExecuteNonQuery(sql);
  217. sql = "insert into TP_MST_GOODSLOGOSAP\n" +
  218. " (GOODSID, LOGOID, GOODSCODE, MATERIALCODE, MATERIALREMARK, CREATEUSERID, WaterLabelCode)\n" +
  219. "values\n" +
  220. " (:GOODSID, :LOGOID, :GOODSCODE, :MATERIALCODE, :MATERIALREMARK, :CREATEUSERID, :WaterLabelCode)";
  221. foreach (DataRow item in goodsEntity.SAPInfo.Rows)
  222. {
  223. string sapcode = item["MATERIALCODE"] + "";
  224. string sapremark = item["MATERIALREMARK"] + "";
  225. if (string.IsNullOrWhiteSpace(sapcode))
  226. {
  227. continue;
  228. }
  229. if (string.IsNullOrEmpty(sapremark))
  230. {
  231. sapremark = " ";
  232. }
  233. paras = new OracleParameter[]{
  234. new OracleParameter(":GOODSID",id),
  235. new OracleParameter(":LOGOID",item["LOGOID"]),
  236. new OracleParameter(":GOODSCODE",goodsEntity.GoodsCode),
  237. new OracleParameter(":MATERIALCODE",sapcode),
  238. new OracleParameter(":MATERIALREMARK",sapremark),
  239. new OracleParameter(":CREATEUSERID",sUserInfo.UserID),
  240. new OracleParameter(":WaterLabelCode",item["WaterLabelCode"]),
  241. };
  242. returnRows += oracleTrConn.ExecuteNonQuery(sql, paras);
  243. }
  244. //此处添加图片信息
  245. foreach (GoodsImageEntity img in imgList)
  246. {
  247. int imgReturn = 0;
  248. sbSql.Clear();
  249. sbSql.Append("select SEQ_MST_GoodsImage_ID.nextval from dual");
  250. int imgId = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  251. sbSql.Clear();
  252. sbSql.Append("Insert into TP_MST_GoodsImage");
  253. sbSql.Append("(GoodsImageID,GoodsID,Thumbnail,Image,AccountID,ValueFlag,");
  254. sbSql.Append("CreateUserID,UpdateUserID)");
  255. sbSql.Append(" VALUES(:GoodsImageID,:GoodsID,:Thumbnail,:Image,:AccountID,:ValueFlag,");
  256. sbSql.Append(":CreateUserID,:UpdateUserID)");
  257. OracleParameter[] imgParas = new OracleParameter[] {
  258. new OracleParameter(":GoodsImageID",OracleDbType.Int32,imgId,ParameterDirection.Input),
  259. new OracleParameter(":GoodsID",OracleDbType.Int32,id,ParameterDirection.Input),
  260. new OracleParameter(":Thumbnail",OracleDbType.Blob,img.Thumbnail,ParameterDirection.Input),
  261. new OracleParameter(":Image",OracleDbType.Blob,img.Image,ParameterDirection.Input),
  262. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  263. new OracleParameter(":ValueFlag",OracleDbType.Int32,img.ValueFlag,ParameterDirection.Input),
  264. //new OracleParameter(":CreateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  265. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  266. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  267. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  268. //new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,DateTime.Now,ParameterDirection.Input)
  269. };
  270. imgReturn = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), imgParas);
  271. }
  272. //此处添加产品附件
  273. //int AttReturn = AddAttachment(oracleTrConn, attList, id, sUserInfo);
  274. //此处添加缺陷位置关联
  275. //int dpCount = SaveGoodsDefectPosition(oracleTrConn, dpList, id, sUserInfo);
  276. oracleTrConn.Commit();
  277. oracleTrConn.Disconnect();
  278. }
  279. catch (Exception ex)
  280. {
  281. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  282. {
  283. oracleTrConn.Rollback();
  284. oracleTrConn.Disconnect();
  285. }
  286. throw ex;
  287. }
  288. return returnRows;
  289. }
  290. /// <summary>
  291. /// 修改产品档案
  292. /// </summary>
  293. /// <param name="sUserInfo">用户基本信息</param>
  294. /// <param name="goodsEntity">产品实体</param>
  295. /// <param name="imgList">产品图片集合</param>
  296. /// <param name="attList">缺陷位置ID集合</param>
  297. /// <returns>int受影响行数</returns>
  298. /// <remarks>
  299. /// 庄天威 2014.09.04 新建
  300. /// </remarks>
  301. public static int updateGoods(SUserInfo sUserInfo, GoodsEntity goodsEntity
  302. , List<GoodsImageEntity> imgList, List<GoodsAttachmentEntity> attList)
  303. {
  304. int returnRows = 0;
  305. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  306. if (goodsEntity.MudQuantity == null)
  307. {
  308. goodsEntity.MudQuantity = 0;
  309. }
  310. if (goodsEntity.GlazeQuantity == null)
  311. {
  312. goodsEntity.GlazeQuantity = 0;
  313. }
  314. if (goodsEntity.Remarks == null)
  315. {
  316. goodsEntity.Remarks = "";
  317. }
  318. if (goodsEntity.GoodsSpecification == null)
  319. {
  320. goodsEntity.GoodsSpecification = "";
  321. }
  322. if (goodsEntity.GoodsModel == null)
  323. {
  324. goodsEntity.GoodsModel = "";
  325. }
  326. try
  327. {
  328. oracleTrConn.Connect();
  329. // 物料编码重复验证 add by chenxy 2017-07-11 begin
  330. // 有不同编码,同物料编码的情况 delete by chenxy 2017-11-10
  331. //string sqlString = "SELECT g.goodscode \n" +
  332. //" FROM tp_mst_goods g\n" +
  333. //" WHERE g.materialcode = :materialcode and g.goodsid <> :goodsid";
  334. //OracleParameter[] checkParas = new OracleParameter[]{
  335. // new OracleParameter(":materialcode",goodsEntity.MaterialCode),
  336. // new OracleParameter(":goodsid",goodsEntity.GoodsID),
  337. //};
  338. //string goodscode = oracleTrConn.GetSqlResultToStr(sqlString, checkParas);
  339. //if (!string.IsNullOrWhiteSpace(goodscode))
  340. //{
  341. // return -10;
  342. //}
  343. // 物料编码重复验证 add by chenxy 2017-07-11 end
  344. StringBuilder sbSql = new StringBuilder();
  345. sbSql.Append("update TP_MST_GOODS");
  346. //sbSql.Append(" set GoodsCode=:GoodsCode,GoodsName=:GoodsName,GoodsSpecification=:GoodsSpecification,");
  347. sbSql.Append(" set GoodsName=:GoodsName,GoodsSpecification=:GoodsSpecification,");
  348. sbSql.Append(" GoodsModel=:GoodsModel,GoodsTypeID=:GoodsTypeID,GlazeTypeID=:GlazeTypeID,MudWeight=:MudWeight,");
  349. sbSql.Append(" GlazeWeight=:GlazeWeight,LusterwareWeight=:LusterwareWeight,ProductionCycle=:ProductionCycle,CeaseFlag=:CeaseFlag,Goods_Line_Type=:Goods_Line_Type,Remarks=:Remarks,");
  350. sbSql.Append(" StartingDate=:StartingDate, AutoLossCycle = :AutoLossCycle, DeliverLimitCycle=:DeliverLimitCycle, PlateLimitNum=:PlateLimitNum,");
  351. sbSql.Append(" UnitPrice=:UnitPrice,PackageNum=:PackageNum,OutletDistance=:OutletDistance,MaterialCode=:MaterialCode,MaterialRemark=:MaterialRemark,printcopies=:printcopies,");
  352. sbSql.Append(" MouldWeight=:MouldWeight, MouldCost=:MouldCost,ScrapSumFlag=:ScrapSumFlag, ReservedDays=:ReservedDays,SEATCOVERCODE=:SEATCOVERCODE,");
  353. sbSql.Append(" WaterLabelCode=:WaterLabelCode, StandardGroutingNum=:StandardGroutingNum,MouldMaterialCode=:MouldMaterialCode, MouldOutputCount=:MouldOutputCount,");
  354. sbSql.Append(" AccountID=:AccountID,ValueFlag=:ValueFlag,UpdateUserID=:UpdateUserID,logoid=:logoid");
  355. //sbSql.Append(" CreateTime=:CreateTime,CreateUserID=:CreateUserID ");
  356. sbSql.Append(" where GoodsID=:GoodsID and OPTimeStamp=:OPTimeStamp");
  357. OracleParameter[] paras = new OracleParameter[]{
  358. // new OracleParameter(":GoodsCode",goodsEntity.GoodsCode),
  359. new OracleParameter(":GoodsName",goodsEntity.GoodsName),
  360. new OracleParameter(":GoodsSpecification",goodsEntity.GoodsSpecification),
  361. new OracleParameter(":GoodsModel",goodsEntity.GoodsModel),
  362. new OracleParameter(":GoodsTypeID",goodsEntity.GoodsTypeID),
  363. new OracleParameter(":GlazeTypeID",goodsEntity.GlazeTypeID),
  364. new OracleParameter(":MudWeight",goodsEntity.MudQuantity),
  365. new OracleParameter(":GlazeWeight",goodsEntity.GlazeQuantity),
  366. new OracleParameter(":LusterwareWeight",goodsEntity.LusterwareWeight),
  367. new OracleParameter(":ProductionCycle",goodsEntity.ProductionCycle),
  368. new OracleParameter(":CeaseFlag",goodsEntity.CeaseFlag),
  369. new OracleParameter(":Goods_Line_Type",goodsEntity.GoodsLineType),
  370. new OracleParameter(":StartingDate",goodsEntity.StartingDate),
  371. new OracleParameter(":AutoLossCycle",goodsEntity.AutoLossCycle),
  372. new OracleParameter(":DeliverLimitCycle",goodsEntity.DeliverLimitCycle),
  373. new OracleParameter(":PlateLimitNum",goodsEntity.PlateLimitNum),
  374. new OracleParameter(":ReservedDays",goodsEntity.ReservedDays),
  375. new OracleParameter(":UnitPrice",goodsEntity.UnitPrice),
  376. new OracleParameter(":PackageNum",goodsEntity.PackageNum),
  377. new OracleParameter(":OutletDistance",goodsEntity.OutletDistance),
  378. new OracleParameter(":MaterialCode",goodsEntity.MaterialCode),
  379. new OracleParameter(":MouldWeight",goodsEntity.MouldWeight),
  380. new OracleParameter(":MouldCost",goodsEntity.MouldCost),
  381. new OracleParameter(":ScrapSumFlag",goodsEntity.ScrapSumFlag),
  382. new OracleParameter(":MaterialRemark",goodsEntity.MaterialRemark),
  383. new OracleParameter(":printcopies",goodsEntity.PrintCopies),
  384. new OracleParameter(":Remarks",goodsEntity.Remarks),
  385. new OracleParameter(":SEATCOVERCODE",goodsEntity.SeatCoverCode),
  386. new OracleParameter(":WaterLabelCode",goodsEntity.WaterLabelCode),
  387. new OracleParameter(":StandardGroutingNum",goodsEntity.StandardGroutingNum),
  388. new OracleParameter(":MouldMaterialCode",goodsEntity.MouldMaterialCode),
  389. new OracleParameter(":MouldOutputCount",goodsEntity.MouldOutputCount),
  390. new OracleParameter(":logoid", goodsEntity.LogoID),
  391. new OracleParameter(":AccountID",goodsEntity.AccountID),
  392. new OracleParameter(":ValueFlag",goodsEntity.ValueFlag),
  393. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  394. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  395. //new OracleParameter(":CreateTime",OracleDbType.Date,goodsEntity.CreateTime,ParameterDirection.Input),
  396. //new OracleParameter(":CreateUserID",goodsEntity.CreateUserID),
  397. new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,goodsEntity.OPTimeStamp,ParameterDirection.Input),
  398. new OracleParameter(":GoodsId",goodsEntity.GoodsID)
  399. };
  400. returnRows = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), paras);
  401. if (returnRows == 0)
  402. {
  403. oracleTrConn.Rollback();
  404. oracleTrConn.Disconnect();
  405. return -500;
  406. }
  407. //SAP物料信息
  408. string sql = "delete from TP_MST_GoodsLogoSAP where goodsid = " + goodsEntity.GoodsID;
  409. returnRows += oracleTrConn.ExecuteNonQuery(sql);
  410. sql = "insert into TP_MST_GOODSLOGOSAP\n" +
  411. " (GOODSID, LOGOID, GOODSCODE, MATERIALCODE, MATERIALREMARK, CREATEUSERID,WaterLabelCode)\n" +
  412. "values\n" +
  413. " (:GOODSID, :LOGOID, :GOODSCODE, :MATERIALCODE, :MATERIALREMARK, :CREATEUSERID,:WaterLabelCode)";
  414. foreach (DataRow item in goodsEntity.SAPInfo.Rows)
  415. {
  416. string sapcode = item["MATERIALCODE"] + "";
  417. string sapremark = item["MATERIALREMARK"] + "";
  418. if (string.IsNullOrWhiteSpace(sapcode))
  419. {
  420. continue;
  421. }
  422. if (string.IsNullOrEmpty(sapremark))
  423. {
  424. sapremark = " ";
  425. }
  426. paras = new OracleParameter[]{
  427. new OracleParameter(":GOODSID",goodsEntity.GoodsID),
  428. new OracleParameter(":LOGOID",item["LOGOID"]),
  429. new OracleParameter(":GOODSCODE",goodsEntity.GoodsCode),
  430. new OracleParameter(":MATERIALCODE",sapcode),
  431. new OracleParameter(":MATERIALREMARK",sapremark),
  432. new OracleParameter(":CREATEUSERID",sUserInfo.UserID),
  433. new OracleParameter(":WaterLabelCode",item["WaterLabelCode"]),
  434. };
  435. returnRows += oracleTrConn.ExecuteNonQuery(sql, paras);
  436. }
  437. foreach (GoodsImageEntity imgEntity in imgList)
  438. {
  439. if (imgEntity.GoodsImageID == 0)
  440. {
  441. int imgReturn = 0;
  442. sbSql.Clear();
  443. sbSql.Append("select SEQ_MST_GoodsImage_ID.nextval from dual");
  444. int imgId = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  445. sbSql.Clear();
  446. sbSql.Append("Insert into TP_MST_GoodsImage");
  447. sbSql.Append("(GoodsImageID,GoodsID,Thumbnail,Image,AccountID,ValueFlag,");
  448. sbSql.Append("CreateUserID,UpdateUserID)");
  449. sbSql.Append(" VALUES(:GoodsImageID,:GoodsID,:Thumbnail,:Image,:AccountID,:ValueFlag,");
  450. sbSql.Append(":CreateUserID,:UpdateUserID)");
  451. OracleParameter[] imgParas = new OracleParameter[] {
  452. new OracleParameter(":GoodsImageID",OracleDbType.Int32,imgId,ParameterDirection.Input),
  453. new OracleParameter(":GoodsID",OracleDbType.Int32,goodsEntity.GoodsID,ParameterDirection.Input),
  454. new OracleParameter(":Thumbnail",OracleDbType.Blob,imgEntity.Thumbnail,ParameterDirection.Input),
  455. new OracleParameter(":Image",OracleDbType.Blob,imgEntity.Image,ParameterDirection.Input),
  456. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  457. new OracleParameter(":ValueFlag",OracleDbType.Int32,imgEntity.ValueFlag,ParameterDirection.Input),
  458. //new OracleParameter(":CreateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  459. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  460. //new OracleParameter(":UpdateTime",OracleDbType.Date,DateTime.Now,ParameterDirection.Input),
  461. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  462. //new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp,DateTime.Now,ParameterDirection.Input)
  463. };
  464. imgReturn = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), imgParas);
  465. }
  466. else
  467. {
  468. int imgReturn = 0;
  469. sbSql.Clear();
  470. sbSql.Append(" update TP_MST_GoodsImage");
  471. sbSql.Append(" set GoodsID=:GoodsID,AccountID=:AccountID,ValueFlag=:ValueFlag,");
  472. sbSql.Append(" UpdateUserID=:UpdateUserID");
  473. //sbSql.Append(" where GoodsImageID=:GoodsImageID And OPTimeStamp=to_date(:OPTimeStamp,'yyyy-mm-dd HH24:mi:ss')");
  474. sbSql.Append(" where GoodsImageID=:GoodsImageID");
  475. OracleParameter[] imgParas = new OracleParameter[] {
  476. new OracleParameter(":GoodsID",OracleDbType.Int32,
  477. goodsEntity.GoodsID,ParameterDirection.Input),
  478. new OracleParameter(":AccountID",OracleDbType.Int32,
  479. imgEntity.AccountID,ParameterDirection.Input),
  480. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  481. imgEntity.ValueFlag,ParameterDirection.Input),
  482. //new OracleParameter(":UpdateTime",OracleDbType.NVarchar2,
  483. // DateTime.Now.ToString(),ParameterDirection.Input),
  484. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  485. sUserInfo.UserID,ParameterDirection.Input),
  486. new OracleParameter(":GoodsImageID",OracleDbType.Int32,
  487. imgEntity.GoodsImageID,ParameterDirection.Input)
  488. //,new OracleParameter(":OPTimeStamp",OracleDbType.TimeStamp, imgEntity.OPTimeStamp,ParameterDirection.Input)
  489. };
  490. imgReturn = oracleTrConn.ExecuteNonQuery(sbSql.ToString(), imgParas);
  491. }
  492. }
  493. //修改产品附件
  494. //int AttReturn = UpdateAttachment(oracleTrConn, attList, Convert.ToInt32(goodsEntity.GoodsID), sUserInfo);
  495. oracleTrConn.Commit();
  496. oracleTrConn.Disconnect();
  497. }
  498. catch (Exception ex)
  499. {
  500. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  501. {
  502. oracleTrConn.Rollback();
  503. oracleTrConn.Disconnect();
  504. }
  505. throw ex;
  506. }
  507. return returnRows;
  508. }
  509. /// <summary>
  510. /// 查询产品物料信息
  511. /// </summary>
  512. /// <param name="sUserInfo"></param>
  513. /// <param name="goodsID"></param>
  514. /// <returns></returns>
  515. public static ServiceResultEntity GetGoodsSAP(SUserInfo sUserInfo, int goodsID)
  516. {
  517. IDBConnection conn = null;
  518. try
  519. {
  520. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  521. string sqlString = "\n" +
  522. "select '产品档案' logoname, g.materialcode, g.materialremark,g.WaterLabelCode, '1' valueflag, -1 displayno\n" +
  523. " from tp_mst_goods g\n" +
  524. " where g.goodsid = :goodsid\n" +
  525. "union all\n" +
  526. "select to_char(l.logoname)\n" +
  527. " ,gls.materialcode\n" +
  528. " ,gls.materialremark\n" +
  529. " ,gls.WaterLabelCode\n" +
  530. " ,l.valueflag\n" +
  531. " ,l.displayno\n" +
  532. " from tp_mst_goodslogosap gls\n" +
  533. " inner join tp_mst_logo l\n" +
  534. " on l.logoid = gls.logoid\n" +
  535. " where gls.goodsid = :goodsid\n" +
  536. " order by valueflag desc, displayno";
  537. OracleParameter[] paras = new OracleParameter[]{
  538. new OracleParameter(":goodsid",goodsID),
  539. };
  540. ServiceResultEntity sre = new ServiceResultEntity();
  541. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  542. return sre;
  543. }
  544. catch (Exception ex)
  545. {
  546. throw ex;
  547. }
  548. finally
  549. {
  550. if (conn != null &&
  551. conn.ConnState == ConnectionState.Open)
  552. {
  553. conn.Close();
  554. }
  555. }
  556. }
  557. /// <summary>
  558. /// 查询产品物料信息(编辑用)
  559. /// </summary>
  560. /// <param name="sUserInfo"></param>
  561. /// <param name="goodsID"></param>
  562. /// <returns></returns>
  563. public static ServiceResultEntity GetGoodsSAPByEdit(SUserInfo sUserInfo, int goodsID)
  564. {
  565. IDBConnection conn = null;
  566. try
  567. {
  568. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  569. string sqlString = "select l.logoid\n" +
  570. " ,l.logoname\n" +
  571. " ,gls.materialcode\n" +
  572. " ,gls.materialremark\n" +
  573. " ,gls.WaterLabelCode\n" +
  574. " ,gls.goodsid\n" +
  575. " ,l.valueflag\n" +
  576. " from tp_mst_logo l\n" +
  577. " left join tp_mst_goodslogosap gls\n" +
  578. " on gls.goodsid = :goodsid\n" +
  579. " and l.logoid = gls.logoid\n" +
  580. " where (l.valueflag = '1' or gls.goodsid is not null)\n" +
  581. " order by gls.goodsid, l.valueflag desc, l.displayno";
  582. OracleParameter[] paras = new OracleParameter[]{
  583. new OracleParameter(":goodsid",goodsID),
  584. };
  585. ServiceResultEntity sre = new ServiceResultEntity();
  586. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  587. return sre;
  588. }
  589. catch (Exception ex)
  590. {
  591. throw ex;
  592. }
  593. finally
  594. {
  595. if (conn != null &&
  596. conn.ConnState == ConnectionState.Open)
  597. {
  598. conn.Close();
  599. }
  600. }
  601. }
  602. #endregion
  603. #region 获得生产工号集合
  604. /// <summary>
  605. /// 获得生产工号集合
  606. /// </summary>
  607. /// <param name="sUserInfo">用户基本信息</param>
  608. /// <returns>DataSet</returns>
  609. /// <remarks>
  610. /// 陈冰 2014.09.03 新建
  611. /// </remarks>
  612. public static DataSet GetWorker(SUserInfo sUserInfo)
  613. {
  614. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  615. try
  616. {
  617. con.Open();
  618. OracleParameter[] paras = new OracleParameter[]{
  619. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  620. new OracleParameter("rs_worker",OracleDbType.RefCursor,ParameterDirection.Output),
  621. };
  622. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetWorker", paras);
  623. return ds;
  624. }
  625. catch (Exception ex)
  626. {
  627. throw ex;
  628. }
  629. finally
  630. {
  631. if (con.ConnState == ConnectionState.Open)
  632. {
  633. con.Close();
  634. }
  635. }
  636. }
  637. #endregion
  638. #region 获得工种集合
  639. /// <summary>
  640. /// 获得工种集合
  641. /// </summary>
  642. /// <param name="sUserInfo">用户基本信息</param>
  643. /// <returns>DataSet</returns>
  644. /// <remarks>
  645. /// 陈冰 2014.09.03 新建
  646. /// </remarks>
  647. public static DataSet GetJobs(SUserInfo sUserInfo)
  648. {
  649. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  650. try
  651. {
  652. con.Open();
  653. OracleParameter[] paras = new OracleParameter[]{
  654. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  655. new OracleParameter("rs_jobs",OracleDbType.RefCursor,ParameterDirection.Output),
  656. };
  657. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetJobs", paras);
  658. return ds;
  659. }
  660. catch (Exception ex)
  661. {
  662. throw ex;
  663. }
  664. finally
  665. {
  666. if (con.ConnState == ConnectionState.Open)
  667. {
  668. con.Close();
  669. }
  670. }
  671. }
  672. #endregion
  673. #region 获得缺陷集合
  674. /// <summary>
  675. /// 获得缺陷集合
  676. /// </summary>
  677. /// <param name="sUserInfo">用户基本信息</param>
  678. /// <returns>DataSet</returns>
  679. /// <remarks>
  680. /// 陈冰 2014.09.03 新建
  681. /// </remarks>
  682. public static DataSet GetDefect(SUserInfo sUserInfo)
  683. {
  684. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  685. try
  686. {
  687. con.Open();
  688. OracleParameter[] paras = new OracleParameter[]{
  689. new OracleParameter("accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  690. new OracleParameter("rs_defect",OracleDbType.RefCursor,ParameterDirection.Output),
  691. };
  692. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetDefect", paras);
  693. return ds;
  694. }
  695. catch (Exception ex)
  696. {
  697. throw ex;
  698. }
  699. finally
  700. {
  701. if (con.ConnState == ConnectionState.Open)
  702. {
  703. con.Close();
  704. }
  705. }
  706. }
  707. #endregion
  708. #region 产品图片
  709. /// <summary>
  710. /// 根据产品ID获取产品图片
  711. /// </summary>
  712. /// <param name="sUserInfo">用户基本信息</param>
  713. /// <param name="goodsId">产品ID</param>
  714. /// <returns>DataSet</returns>
  715. /// <remarks>
  716. /// 庄天威 2014.09.04 新建
  717. /// </remarks>
  718. public static DataSet GetImageByGoodsId(SUserInfo sUserInfo, int goodsId)
  719. {
  720. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  721. try
  722. {
  723. con.Open();
  724. OracleParameter[] paras = new OracleParameter[]{
  725. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  726. new OracleParameter("in_goodsID",OracleDbType.Int32,goodsId,ParameterDirection.Input),
  727. new OracleParameter("rs_result",OracleDbType.RefCursor,ParameterDirection.Output),
  728. };
  729. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetImageByGoodsId", paras);
  730. return ds;
  731. }
  732. catch (Exception ex)
  733. {
  734. throw ex;
  735. }
  736. finally
  737. {
  738. if (con.ConnState == ConnectionState.Open)
  739. {
  740. con.Close();
  741. }
  742. }
  743. }
  744. #endregion
  745. #region 附件
  746. /// <summary>
  747. /// 新建附件信息
  748. /// </summary>
  749. /// <param name="AttList">附件实体集合</param>
  750. /// <param name="mainId">产品ID</param>
  751. /// <param name="userInfo">用户基本信息</param>
  752. /// <returns>int影响结果行数</returns>
  753. public static int AddAttachment(List<GoodsAttachmentEntity> AttList, int mainId, SUserInfo userInfo)
  754. {
  755. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  756. try
  757. {
  758. oracleTrConn.Connect();
  759. int AttReturn = 0;
  760. int GAReturn = 0;
  761. StringBuilder sbSql = new StringBuilder();
  762. foreach (GoodsAttachmentEntity attFor in AttList)
  763. {
  764. sbSql.Clear();
  765. sbSql.Append("select SEQ_MST_Attachment_ID.nextval from dual");
  766. int id = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  767. sbSql.Clear();
  768. sbSql.Append(@"Insert into TP_MST_Attachment(AttachmentID,FileName,FilePath,AccountID,ValueFlag,
  769. CreateUserID,UpdateUserID)
  770. Values(:AttachmentID,:FileName,:FilePath,:AccountID,:ValueFlag,
  771. :CreateUserID,:UpdateUserID)");
  772. OracleParameter[] attParas = new OracleParameter[] {
  773. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  774. id,ParameterDirection.Input),
  775. new OracleParameter(":FileName",OracleDbType.NVarchar2,
  776. attFor.FileName,ParameterDirection.Input),
  777. new OracleParameter(":FilePath",OracleDbType.NVarchar2,
  778. attFor.FilePath,ParameterDirection.Input),
  779. new OracleParameter(":AccountID",OracleDbType.Int32,
  780. userInfo.AccountID,ParameterDirection.Input),
  781. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  782. 1,ParameterDirection.Input),
  783. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  784. userInfo.UserID,ParameterDirection.Input),
  785. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  786. userInfo.UserID,ParameterDirection.Input)
  787. };
  788. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  789. sbSql.Clear();
  790. sbSql.Append(@"Insert into TP_MST_GoodsAttachment(GoodsID,AttachmentID,CreateUserID,UpdateUserID)
  791. Values(:GoodsID,:AttachmentID,:CreateUserID,:UpdateUserID)");
  792. OracleParameter[] gaParas = new OracleParameter[] {
  793. new OracleParameter(":GoodsID",OracleDbType.Int32,
  794. mainId,ParameterDirection.Input),
  795. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  796. id,ParameterDirection.Input),
  797. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  798. userInfo.UserID,ParameterDirection.Input),
  799. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  800. userInfo.UserID,ParameterDirection.Input)
  801. };
  802. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), gaParas);
  803. sbSql.Clear();
  804. }
  805. oracleTrConn.Commit();
  806. oracleTrConn.Disconnect();
  807. return AttReturn;
  808. }
  809. catch (Exception ex)
  810. {
  811. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  812. {
  813. oracleTrConn.Rollback();
  814. oracleTrConn.Disconnect();
  815. }
  816. throw ex;
  817. }
  818. }
  819. /// <summary>
  820. /// 修改附件信息
  821. /// </summary>
  822. /// <param name="AttList">附件实体集合</param>
  823. /// <param name="mainId">产品ID</param>
  824. /// <param name="userInfo">用户基本信息</param>
  825. /// <returns>int受影响行数</returns>
  826. public static int UpdateAttachment(List<GoodsAttachmentEntity> AttList, int mainId, SUserInfo userInfo)
  827. {
  828. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  829. try
  830. {
  831. oracleTrConn.Connect();
  832. int AttReturn = 0;
  833. int GAReturn = 0;
  834. StringBuilder sbSql = new StringBuilder();
  835. foreach (GoodsAttachmentEntity attFor in AttList)
  836. {
  837. if (attFor.IsUpdateAdd == 0) //不是新建的
  838. {
  839. sbSql.Clear();
  840. sbSql.Append(@"Update TP_MST_Attachment set ValueFlag = :ValueFlag,UpdateUserID=:UpdateUserID
  841. Where AttachmentID = :AttachmentID");
  842. OracleParameter[] attParas = new OracleParameter[] {
  843. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  844. attFor.ValueFlag,ParameterDirection.Input),
  845. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  846. userInfo.UserID,ParameterDirection.Input),
  847. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  848. attFor.AttachmentID,ParameterDirection.Input)
  849. };
  850. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  851. sbSql.Clear();
  852. sbSql.Append(@"Update TP_MST_GoodsAttachment
  853. Set ValueFlag = :ValueFlag,UpdateUserID=:UpdateUserID
  854. Where AttachmentID = :AttachmentID");
  855. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  856. sbSql.Clear();
  857. }
  858. else //新建的
  859. {
  860. sbSql.Clear();
  861. sbSql.Append("select SEQ_MST_Attachment_ID.nextval from dual");
  862. int id = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sbSql.ToString()));
  863. sbSql.Clear();
  864. sbSql.Append(@"Insert into TP_MST_Attachment(AttachmentID,FileName,FilePath,AccountID,ValueFlag,
  865. CreateUserID,UpdateUserID)
  866. Values(:AttachmentID,:FileName,:FilePath,:AccountID,:ValueFlag,
  867. :CreateUserID,:UpdateUserID)");
  868. OracleParameter[] attParas = new OracleParameter[] {
  869. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  870. id,ParameterDirection.Input),
  871. new OracleParameter(":FileName",OracleDbType.NVarchar2,
  872. attFor.FileName,ParameterDirection.Input),
  873. new OracleParameter(":FilePath",OracleDbType.NVarchar2,
  874. attFor.FilePath,ParameterDirection.Input),
  875. new OracleParameter(":AccountID",OracleDbType.Int32,
  876. userInfo.AccountID,ParameterDirection.Input),
  877. new OracleParameter(":ValueFlag",OracleDbType.Int32,
  878. 1,ParameterDirection.Input),
  879. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  880. userInfo.UserID,ParameterDirection.Input),
  881. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  882. userInfo.UserID,ParameterDirection.Input)
  883. };
  884. AttReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), attParas);
  885. sbSql.Clear();
  886. sbSql.Append(@"Insert into TP_MST_GoodsAttachment(GoodsID,AttachmentID,CreateUserID,UpdateUserID)
  887. Values(:GoodsID,:AttachmentID,:CreateUserID,:UpdateUserID)");
  888. OracleParameter[] gaParas = new OracleParameter[] {
  889. new OracleParameter(":GoodsID",OracleDbType.Int32,
  890. mainId,ParameterDirection.Input),
  891. new OracleParameter(":AttachmentID",OracleDbType.Int32,
  892. id,ParameterDirection.Input),
  893. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  894. userInfo.UserID,ParameterDirection.Input),
  895. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  896. userInfo.UserID,ParameterDirection.Input)
  897. };
  898. GAReturn += oracleTrConn.ExecuteNonQuery(sbSql.ToString(), gaParas);
  899. sbSql.Clear();
  900. }
  901. }
  902. oracleTrConn.Commit();
  903. oracleTrConn.Disconnect();
  904. return AttReturn;
  905. }
  906. catch (Exception ex)
  907. {
  908. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  909. {
  910. oracleTrConn.Rollback();
  911. oracleTrConn.Disconnect();
  912. }
  913. throw ex;
  914. }
  915. }
  916. /// <summary>
  917. /// 根据产品ID获取附件
  918. /// </summary>
  919. /// <param name="goodsId">产品ID</param>
  920. /// <returns>DataSet</returns>
  921. public static DataSet GetAttachmentByGoodsId(int goodsId)
  922. {
  923. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  924. try
  925. {
  926. con.Open();
  927. String strSql = @"Select goodsAtt.GoodsID,att.* from TP_MST_GoodsAttachment goodsAtt
  928. Inner join TP_MST_Attachment att
  929. On goodsAtt.AttachmentID = att.AttachmentID
  930. Where goodsAtt.ValueFlag = 1 and goodsAtt.GoodsID = " + goodsId;
  931. DataSet ds = con.GetSqlResultToDs(strSql, null);
  932. return ds;
  933. }
  934. catch (Exception ex)
  935. {
  936. throw ex;
  937. }
  938. finally
  939. {
  940. if (con.ConnState == ConnectionState.Open)
  941. {
  942. con.Close();
  943. }
  944. }
  945. }
  946. #endregion
  947. #region 缺陷位置
  948. /// <summary>
  949. /// 获取缺陷位置
  950. /// </summary>
  951. /// <param name="dpEntity">缺陷位置实体</param>
  952. /// <param name="userInfo">用户基本信息</param>
  953. /// <returns>DataSet</returns>
  954. public static DataSet GetDefectPosition(DefectPositionEntity dpEntity, SUserInfo userInfo)
  955. {
  956. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  957. try
  958. {
  959. con.Open();
  960. OracleParameter[] paras = new OracleParameter[]{
  961. new OracleParameter("in_DefectPositionID",OracleDbType.Int32,
  962. dpEntity.DefectPositionID,ParameterDirection.Input),
  963. new OracleParameter("in_DefectPositionCode",OracleDbType.NVarchar2,
  964. dpEntity.DefectPositionCode,ParameterDirection.Input),
  965. new OracleParameter("in_DefectPositionName",OracleDbType.NVarchar2,
  966. dpEntity.DefectPositionName,ParameterDirection.Input),
  967. new OracleParameter("in_AccountID",OracleDbType.Int32,
  968. userInfo.AccountID,ParameterDirection.Input),
  969. new OracleParameter("out_rs_defect",OracleDbType.RefCursor,ParameterDirection.Output),
  970. };
  971. DataSet dsDefectPosition = con.ExecStoredProcedure("PRO_MST_GetDefectPosition", paras);
  972. return dsDefectPosition;
  973. }
  974. catch (Exception ex)
  975. {
  976. throw ex;
  977. }
  978. finally
  979. {
  980. if (con.ConnState == ConnectionState.Open)
  981. {
  982. con.Close();
  983. }
  984. }
  985. }
  986. /// <summary>
  987. /// 根据产品获得产品缺陷位置
  988. /// </summary>
  989. /// <param name="GoodsId">产品ID</param>
  990. /// <returns>DataSet</returns>
  991. public static DataSet getGoodsDefectPositionByGoodsId(int GoodsId)
  992. {
  993. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  994. try
  995. {
  996. con.Open();
  997. string sql = @"select gdp.*,dp.DefectPositionCode,dp.DefectPositionName,dp.Remarks
  998. from TP_MST_GoodsDefectPosition gdp
  999. inner join TP_MST_DefectPosition dp
  1000. on gdp.DefectPositionID=dp.DefectPositionID
  1001. where gdp.GoodsID=" + GoodsId;
  1002. DataSet dsDefectPosition = con.GetSqlResultToDs(sql, null);
  1003. return dsDefectPosition;
  1004. }
  1005. catch (Exception ex)
  1006. {
  1007. throw ex;
  1008. }
  1009. finally
  1010. {
  1011. if (con.ConnState == ConnectionState.Open)
  1012. {
  1013. con.Close();
  1014. }
  1015. }
  1016. }
  1017. /// <summary>
  1018. /// 保存产品缺陷位置关联(依附在添加产品中)
  1019. /// </summary>
  1020. /// <param name="dpList">缺陷位置集</param>
  1021. /// <param name="GoodsId">产品ID</param>
  1022. /// <param name="userInfo">用户基本信息</param>
  1023. /// <returns>int</returns>
  1024. public static int SaveGoodsDefectPosition(IDBTransaction oracleTrConn, List<int> dpList, int GoodsId, SUserInfo userInfo)
  1025. {
  1026. try
  1027. {
  1028. int ReturnCount = 0;
  1029. string sql = "Delete from TP_MST_GoodsDefectPosition where GoodsId=" + GoodsId;
  1030. foreach (int dpFor in dpList)
  1031. {
  1032. string sqlAdd = @"Insert into TP_MST_GoodsDefectPosition(GoodsID,DefectPositionID,
  1033. CreateTime,CreateUserID) Values(:GoodsID,:DefectPositionID,sysdate,:CreateUserID)";
  1034. OracleParameter[] paras = new OracleParameter[]{
  1035. new OracleParameter(":GoodsID",OracleDbType.Int32,
  1036. GoodsId,ParameterDirection.Input),
  1037. new OracleParameter(":DefectPositionID",OracleDbType.Int32,
  1038. dpFor,ParameterDirection.Input),
  1039. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  1040. userInfo.UserID,ParameterDirection.Input),
  1041. };
  1042. ReturnCount += oracleTrConn.ExecuteNonQuery(sqlAdd, paras);
  1043. }
  1044. return ReturnCount;
  1045. }
  1046. catch (Exception ex)
  1047. {
  1048. throw ex;
  1049. }
  1050. }
  1051. #endregion
  1052. #region 成型线类型
  1053. /// <summary>
  1054. /// 获取成型线类型
  1055. /// </summary>
  1056. /// <param name="userInfo">用户基本信息</param>
  1057. /// <returns>数据集</returns>
  1058. /// <remarks>
  1059. /// 庄天威 2014.09.04 新建
  1060. /// </remarks>
  1061. public static DataSet GetGMouldType(SUserInfo userInfo)
  1062. {
  1063. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1064. try
  1065. {
  1066. con.Open();
  1067. OracleParameter[] paras = new OracleParameter[]{
  1068. new OracleParameter("in_accountID",OracleDbType.Int32,
  1069. userInfo.AccountID,ParameterDirection.Input),
  1070. new OracleParameter("in_valueFlag",OracleDbType.Int32,
  1071. 1,ParameterDirection.Input),
  1072. new OracleParameter("out_result",OracleDbType.RefCursor,ParameterDirection.Output),
  1073. };
  1074. DataSet ds = con.ExecStoredProcedure("PRO_MST_GetMouldType", paras);
  1075. return ds;
  1076. }
  1077. catch (Exception ex)
  1078. {
  1079. throw ex;
  1080. }
  1081. finally
  1082. {
  1083. if (con.ConnState == ConnectionState.Open)
  1084. {
  1085. con.Close();
  1086. }
  1087. }
  1088. }
  1089. #endregion
  1090. #region 产品分级数据源
  1091. /// <summary>
  1092. /// 产品分级数据源
  1093. /// </summary>
  1094. /// <param name="type">1适用半成品2检验 2适用成品检验 3入窑前检验</param>
  1095. /// <param name="userInfo">用户基本信息</param>
  1096. /// <returns>DataSet</returns>
  1097. public static DataSet GetGoodsLevel(int type, SUserInfo userInfo)
  1098. {
  1099. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1100. try
  1101. {
  1102. con.Open();
  1103. string sqlString = "";
  1104. if (type == 1 || type == 3)
  1105. {
  1106. sqlString = "select GoodsLevelID as DefectFlagID,GoodsLevelName as DefectFlagName,GoodsLevelTypeID from TP_MST_GoodsLevel where IsSemiFinishedEx=1 and AccountID=:AccountID and ValueFlag=1 order by SFEDisplayNo";
  1107. }
  1108. else if (type == 2)
  1109. {
  1110. sqlString = "select GoodsLevelID as DefectFlagID,GoodsLevelName as DefectFlagName,GoodsLevelTypeID from TP_MST_GoodsLevel where IsFinishedEx=1 and AccountID=:AccountID and ValueFlag=1 order by FEDisplayNo";
  1111. }
  1112. OracleParameter[] paras = new OracleParameter[]{
  1113. new OracleParameter(":AccountID",userInfo.AccountID),
  1114. };
  1115. DataSet dsGoodsLevel = con.GetSqlResultToDs(sqlString, paras);
  1116. return dsGoodsLevel;
  1117. }
  1118. catch (Exception ex)
  1119. {
  1120. throw ex;
  1121. }
  1122. finally
  1123. {
  1124. if (con.ConnState == ConnectionState.Open)
  1125. {
  1126. con.Close();
  1127. }
  1128. }
  1129. }
  1130. #endregion
  1131. #region 审核状态
  1132. /// <summary>
  1133. /// 获取全部审核状态
  1134. /// </summary>
  1135. /// <returns>DataSet审核状态数据源</returns>
  1136. public static DataSet GetAuditStatus()
  1137. {
  1138. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1139. try
  1140. {
  1141. con.Open();
  1142. String strSql = "Select * from TP_SYS_AuditStatus Order by DisplayNo";
  1143. DataSet ds = con.GetSqlResultToDs(strSql, null);
  1144. return ds;
  1145. }
  1146. catch (Exception ex)
  1147. {
  1148. throw ex;
  1149. }
  1150. finally
  1151. {
  1152. if (con.ConnState == ConnectionState.Open)
  1153. {
  1154. con.Close();
  1155. }
  1156. }
  1157. }
  1158. #endregion
  1159. /// <summary>
  1160. /// 工序集合
  1161. /// </summary>
  1162. /// <param name="ProductionLineEntity">工序实体</param>
  1163. /// <param name="sUserInfo">用户<基本信息/param>
  1164. /// <returns>DataSet</returns>
  1165. /// <remarks>
  1166. /// 王鑫 2014.11.29 新建
  1167. /// </remarks>
  1168. public static DataSet GetProdureList(SearchProductionLineEntity productionLineEntity, SUserInfo sUserInfo)
  1169. {
  1170. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1171. try
  1172. {
  1173. con.Open();
  1174. OracleParameter[] paras = new OracleParameter[]{
  1175. new OracleParameter("in_procedureCode",OracleDbType.Varchar2,productionLineEntity.ProductionLineCode,ParameterDirection.Input),
  1176. new OracleParameter("in_procedureName",OracleDbType.Varchar2,productionLineEntity.ProductionLineName,ParameterDirection.Input),
  1177. new OracleParameter("in_procedureIDS",OracleDbType.Varchar2,productionLineEntity.ProcuteLineIDS,ParameterDirection.Input),
  1178. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  1179. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  1180. };
  1181. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_PC_GetProcedureList", paras);
  1182. return dsSearchReport;
  1183. }
  1184. catch (Exception ex)
  1185. {
  1186. throw ex;
  1187. }
  1188. finally
  1189. {
  1190. if (con.ConnState == ConnectionState.Open)
  1191. {
  1192. con.Close();
  1193. }
  1194. }
  1195. }
  1196. /// <summary>
  1197. /// 获取全部工种计件方式
  1198. /// </summary>
  1199. /// <returns>DataSet工种计件方式集合</returns>
  1200. public static DataSet GetJobsPriceType()
  1201. {
  1202. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1203. try
  1204. {
  1205. con.Open();
  1206. String strSql = "Select * from TP_SYS_JobsPriceType Order by DisplayNo";
  1207. DataSet dsSearchReport = con.GetSqlResultToDs(strSql, null);
  1208. return dsSearchReport;
  1209. }
  1210. catch (Exception ex)
  1211. {
  1212. throw ex;
  1213. }
  1214. finally
  1215. {
  1216. if (con.ConnState == ConnectionState.Open)
  1217. {
  1218. con.Close();
  1219. }
  1220. }
  1221. }
  1222. /// <summary>
  1223. /// 查询金蝶代码数据
  1224. /// </summary>
  1225. /// <param name="sUserInfo"></param>
  1226. /// <param name="goodsID"></param>
  1227. /// <returns></returns>
  1228. public static ServiceResultEntity GetKingdeeCode(SUserInfo sUserInfo, ClientRequestEntity cre)
  1229. {
  1230. IDBConnection conn = null;
  1231. try
  1232. {
  1233. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1234. OracleParameter[] paras = new OracleParameter[] { };
  1235. string sqlString = @"
  1236. SELECT
  1237. TP_MST_GOODSKINGDEECODE.GUID,
  1238. TP_MST_GOODSKINGDEECODE.GOODSCODE,
  1239. gd.goodsname,
  1240. TP_MST_GOODSKINGDEECODE.GLAZETYPE,
  1241. TP_MST_GOODSKINGDEECODE.LOGONAME,
  1242. TP_MST_GOODSKINGDEECODE.KINGDEECODE,
  1243. TP_MST_GOODSKINGDEECODE.CREATETIME,
  1244. TP_MST_USER.USERNAME AS CREATEUSER,
  1245. TP_MST_GOODSKINGDEECODE.UPDATETIME AS UPDATETIME,
  1246. USERS.USERNAME AS UPDATEUSER
  1247. FROM
  1248. TP_MST_GOODSKINGDEECODE
  1249. LEFT JOIN TP_MST_GOODS gd on gd.GOODSCODE=TP_MST_GOODSKINGDEECODE.GOODSCODE
  1250. LEFT JOIN TP_MST_USER ON TP_MST_GOODSKINGDEECODE.CREATEUSERID=TP_MST_USER.USERID
  1251. LEFT JOIN TP_MST_USER USERS ON TP_MST_GOODSKINGDEECODE.UPDATEUSERID=USERS.USERID
  1252. WHERE 1=1 AND TP_MST_GOODSKINGDEECODE.valueflag=1 ";
  1253. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"].ToString()))
  1254. {
  1255. sqlString += " AND TP_MST_GOODSKINGDEECODE.GOODSCODE like :GOODSCODE";
  1256. }
  1257. if (!string.IsNullOrEmpty(cre.Properties["GlazeType"].ToString()))
  1258. {
  1259. sqlString += " AND TP_MST_GOODSKINGDEECODE.GLAZETYPE = :GLAZETYPE";
  1260. }
  1261. if (!string.IsNullOrEmpty(cre.Properties["LogoName"].ToString()))
  1262. {
  1263. sqlString += " AND TP_MST_GOODSKINGDEECODE.LOGONAME = :LOGONAME";
  1264. }
  1265. if (!string.IsNullOrEmpty(cre.Properties["KingdeeCode"].ToString()))
  1266. {
  1267. sqlString += " AND TP_MST_GOODSKINGDEECODE.KINGDEECODE like :KINGDEECODE";
  1268. }
  1269. if (!string.IsNullOrEmpty(cre.Properties["GoodsName"].ToString()))
  1270. {
  1271. sqlString += " AND gd.goodsname like :GoodsName";
  1272. }
  1273. paras = new OracleParameter[]{
  1274. new OracleParameter(":GOODSCODE",'%'+cre.Properties["GoodsCode"].ToString()+'%'),
  1275. new OracleParameter(":GoodsName",'%'+cre.Properties["GoodsName"].ToString()+'%'),
  1276. new OracleParameter(":GLAZETYPE",cre.Properties["GlazeType"].ToString()),
  1277. new OracleParameter(":LOGONAME",cre.Properties["LogoName"].ToString()),
  1278. new OracleParameter(":KINGDEECODE",'%'+cre.Properties["KingdeeCode"].ToString()+'%'),
  1279. };
  1280. ServiceResultEntity sre = new ServiceResultEntity();
  1281. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  1282. return sre;
  1283. }
  1284. catch (Exception ex)
  1285. {
  1286. throw ex;
  1287. }
  1288. finally
  1289. {
  1290. if (conn != null &&
  1291. conn.ConnState == ConnectionState.Open)
  1292. {
  1293. conn.Close();
  1294. }
  1295. }
  1296. }
  1297. /// <summary>
  1298. /// 查询商标名称
  1299. /// </summary>
  1300. /// <param name="sUserInfo"></param>
  1301. /// <param name="goodsID"></param>
  1302. /// <returns></returns>
  1303. public static ServiceResultEntity GetLogoName(SUserInfo sUserInfo, ClientRequestEntity cre)
  1304. {
  1305. IDBConnection conn = null;
  1306. try
  1307. {
  1308. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1309. string sqlString = @"
  1310. SELECT
  1311. LogoID,
  1312. LogoName AS LogoNameCode
  1313. FROM
  1314. tp_mst_logo
  1315. WHERE
  1316. AccountID = 1
  1317. AND valueflag = '1'
  1318. ORDER BY
  1319. DECODE(LogoName, '无标', 1) , LogoName";
  1320. ServiceResultEntity sre = new ServiceResultEntity();
  1321. sre.Data = conn.GetSqlResultToDs(sqlString, null);
  1322. return sre;
  1323. }
  1324. catch (Exception ex)
  1325. {
  1326. throw ex;
  1327. }
  1328. finally
  1329. {
  1330. if (conn != null &&
  1331. conn.ConnState == ConnectionState.Open)
  1332. {
  1333. conn.Close();
  1334. }
  1335. }
  1336. }
  1337. ///<summary>
  1338. ///保存金蝶代码信息
  1339. /// </summary>
  1340. public static ServiceResultEntity AddKingdeeCode(SUserInfo sUserInfo, ClientRequestEntity cre)
  1341. {
  1342. IDBTransaction conn = null;
  1343. try
  1344. {
  1345. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  1346. ServiceResultEntity sre = new ServiceResultEntity();
  1347. DataTable dt = new DataTable();
  1348. string sqlString = string.Empty;
  1349. OracleParameter[] paras = new OracleParameter[] { };
  1350. //如果版面信息是新建的情况下,是否存在相同版面编码
  1351. if (cre.Properties["FromStatus"].ToString() == "Add")
  1352. {
  1353. sqlString = @"SELECT 1 FROM TP_MST_GOODSKINGDEECODE
  1354. WHERE
  1355. KINGDEECODE = :KINGDEECODE AND GOODSCODE =:GOODSCODE
  1356. AND GLAZETYPE =:GLAZETYPE AND LOGONAME =:LOGONAME
  1357. AND valueflag=1";
  1358. paras = new OracleParameter[] { new OracleParameter(":KINGDEECODE", cre.Properties["KINGDEECODE"].ToString()),
  1359. new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"].ToString()),
  1360. new OracleParameter(":GLAZETYPE", cre.Properties["GLAZETYPE"].ToString()) ,
  1361. new OracleParameter(":LOGONAME", cre.Properties["LOGONAME"].ToString()) ,
  1362. };
  1363. dt = new DataTable();
  1364. dt = conn.GetSqlResultToDt(sqlString, paras);
  1365. if (dt != null && dt.Rows.Count > 0)
  1366. {
  1367. //存在相同金蝶代码
  1368. sre.OtherStatus = -1001;
  1369. return sre;
  1370. }
  1371. }
  1372. #region 新增
  1373. if (cre.Properties["FromStatus"].ToString() == "Add")
  1374. {
  1375. //保存客户信息
  1376. sqlString = @"INSERT INTO TP_MST_GOODSKINGDEECODE(
  1377. GOODSCODE,
  1378. GLAZETYPE,
  1379. LOGONAME,
  1380. KINGDEECODE,
  1381. CREATEUSERID,
  1382. UPDATEUSERID,
  1383. VALUEFLAG
  1384. ) VALUES(
  1385. :GOODSCODE,
  1386. :GLAZETYPE,
  1387. :LOGONAME,
  1388. :KINGDEECODE,
  1389. :CREATEUSERID,:UPDATEUSERID,
  1390. '1' )";
  1391. paras = new OracleParameter[] {
  1392. new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"].ToString()),
  1393. new OracleParameter(":GLAZETYPE", cre.Properties["GLAZETYPE"].ToString()) ,
  1394. new OracleParameter(":LOGONAME", cre.Properties["LOGONAME"].ToString()) ,
  1395. new OracleParameter(":KINGDEECODE", cre.Properties["KINGDEECODE"].ToString()) ,
  1396. new OracleParameter(":CREATEUSERID", sUserInfo.UserID) ,
  1397. new OracleParameter(":UPDATEUSERID", sUserInfo.UserID) ,
  1398. };
  1399. }
  1400. #endregion
  1401. #region 编辑
  1402. if (cre.Properties["FromStatus"].ToString() == "Edit")
  1403. {
  1404. sqlString = @"SELECT 1 FROM TP_MST_GOODSKINGDEECODE
  1405. WHERE
  1406. KINGDEECODE = :KINGDEECODE AND GOODSCODE =:GOODSCODE
  1407. AND GLAZETYPE =:GLAZETYPE AND LOGONAME =:LOGONAME
  1408. AND valueflag=1";
  1409. paras = new OracleParameter[] {
  1410. new OracleParameter(":KINGDEECODE", cre.Properties["KINGDEECODE"].ToString()),
  1411. new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"].ToString()),
  1412. new OracleParameter(":GLAZETYPE", cre.Properties["GLAZETYPE"].ToString()) ,
  1413. new OracleParameter(":LOGONAME", cre.Properties["LOGONAME"].ToString()) ,
  1414. };
  1415. dt = new DataTable();
  1416. dt = conn.GetSqlResultToDt(sqlString, paras);
  1417. if (dt != null && dt.Rows.Count > 0)
  1418. {
  1419. //存在相同版面编码
  1420. sre.OtherStatus = -1001;
  1421. return sre;
  1422. }
  1423. sqlString = @" UPDATE TP_MST_GOODSKINGDEECODE
  1424. SET
  1425. GOODSCODE=:GOODSCODE,
  1426. GLAZETYPE = :GLAZETYPE,
  1427. LOGONAME =:LOGONAME,
  1428. KINGDEECODE = :KINGDEECODE,
  1429. UPDATEUSERID =:UPDATEUSERID,
  1430. UPDATETIME = SYSDATE
  1431. WHERE
  1432. GUID =:GUID ";
  1433. paras = new OracleParameter[] {
  1434. new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"].ToString()) ,
  1435. new OracleParameter(":GLAZETYPE", cre.Properties["GLAZETYPE"].ToString()) ,
  1436. new OracleParameter(":LOGONAME", cre.Properties["LOGONAME"].ToString()) ,
  1437. new OracleParameter(":KINGDEECODEONE", cre.Properties["KINGDEECODEONE"].ToString()) ,
  1438. new OracleParameter(":KINGDEECODE", cre.Properties["KINGDEECODE"].ToString()) ,
  1439. new OracleParameter(":UPDATEUSERID", sUserInfo.UserID) ,
  1440. new OracleParameter(":GUID", cre.Properties["GUID"].ToString()) ,
  1441. };
  1442. }
  1443. #endregion
  1444. #region 删除
  1445. if (cre.Properties["FromStatus"].ToString() == "Delete")
  1446. {
  1447. sqlString = @"UPDATE TP_MST_GOODSKINGDEECODE
  1448. SET
  1449. VALUEFLAG=0
  1450. WHERE
  1451. GUID = :GUID";
  1452. paras = new OracleParameter[] {
  1453. new OracleParameter(":GUID", cre.Properties["GUID"].ToString()) ,
  1454. };
  1455. }
  1456. #endregion
  1457. int result = conn.ExecuteNonQuery(sqlString, paras);
  1458. if (result <= 0)
  1459. {
  1460. //未改变任何数据
  1461. sre.OtherStatus = -1003;
  1462. return sre;
  1463. }
  1464. else
  1465. {
  1466. //提交数据
  1467. sre.OtherStatus = 1;
  1468. conn.Commit();
  1469. }
  1470. return sre;
  1471. }
  1472. catch (Exception ex)
  1473. {
  1474. throw ex;
  1475. }
  1476. finally
  1477. {
  1478. if (conn != null &&
  1479. conn.ConnState == ConnectionState.Open)
  1480. {
  1481. conn.Disconnect();
  1482. }
  1483. }
  1484. }
  1485. /// <summary>
  1486. /// 查询模具对应产品
  1487. /// </summary>
  1488. /// <param name="sUserInfo"></param>
  1489. /// <param name="goodsID"></param>
  1490. /// <returns></returns>
  1491. public static ServiceResultEntity GetMouldGoodsCode(SUserInfo sUserInfo, ClientRequestEntity cre)
  1492. {
  1493. IDBConnection conn = null;
  1494. try
  1495. {
  1496. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1497. OracleParameter[] paras = new OracleParameter[] { };
  1498. string sqlString = @"
  1499. SELECT MOULD.GUID,
  1500. MOULD.GOODSCODE,
  1501. GD.GOODSNAME,
  1502. MOULD.MOULDGOODSCODE,
  1503. MOULD.MOULDNAME
  1504. FROM TP_MST_MOULDGOODSCODE MOULD
  1505. LEFT JOIN TP_MST_GOODS GD ON MOULD.GOODSCODE=GD.GOODSCODE AND GD.VALUEFLAG=1
  1506. WHERE MOULD.VALUEFLAG=1 ";
  1507. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"].ToString()))
  1508. {
  1509. sqlString += "AND MOULD.GOODSCODE like :GOODSCODE";
  1510. }
  1511. if (!string.IsNullOrEmpty(cre.Properties["MOULDGOODSCODE"].ToString()))
  1512. {
  1513. sqlString += " AND MOULD.MOULDGOODSCODE like :MOULDGOODSCODE";
  1514. }
  1515. if (!string.IsNullOrEmpty(cre.Properties["MOULDNAME"].ToString()))
  1516. {
  1517. sqlString += " AND MOULD.MOULDNAME like :MOULDNAME";
  1518. }
  1519. paras = new OracleParameter[]{
  1520. new OracleParameter(":GOODSCODE",'%'+cre.Properties["GoodsCode"].ToString()+'%'),
  1521. new OracleParameter(":MOULDNAME",'%'+cre.Properties["MOULDNAME"].ToString()+'%'),
  1522. new OracleParameter(":MOULDGOODSCODE",'%'+cre.Properties["MOULDGOODSCODE"].ToString()+'%'),
  1523. };
  1524. ServiceResultEntity sre = new ServiceResultEntity();
  1525. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  1526. return sre;
  1527. }
  1528. catch (Exception ex)
  1529. {
  1530. throw ex;
  1531. }
  1532. finally
  1533. {
  1534. if (conn != null &&
  1535. conn.ConnState == ConnectionState.Open)
  1536. {
  1537. conn.Close();
  1538. }
  1539. }
  1540. }
  1541. ///<summary>
  1542. ///保存金蝶代码信息
  1543. /// </summary>
  1544. public static ServiceResultEntity AddMouldCode(SUserInfo sUserInfo, ClientRequestEntity cre)
  1545. {
  1546. IDBTransaction conn = null;
  1547. try
  1548. {
  1549. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  1550. ServiceResultEntity sre = new ServiceResultEntity();
  1551. DataTable dt = new DataTable();
  1552. string sqlString = string.Empty;
  1553. OracleParameter[] paras = new OracleParameter[] { };
  1554. //如果版面信息是新建的情况下,是否存在相同版面编码
  1555. if (cre.Properties["FromStatus"].ToString() == "Add")
  1556. {
  1557. sqlString = @" SELECT 1 FROM TP_MST_MOULDGOODSCODE
  1558. WHERE VALUEFLAG=1
  1559. AND GOODSCODE= :GOODSCODE
  1560. AND MOULDGOODSCODE= :MOULDGOODSCODE
  1561. AND MOULDNAME= :MOULDNAME";
  1562. paras = new OracleParameter[]{
  1563. new OracleParameter(":GOODSCODE",cre.Properties["GOODSCODE"].ToString()),
  1564. new OracleParameter(":MOULDNAME",cre.Properties["MOULDNAME"].ToString()),
  1565. new OracleParameter(":MOULDGOODSCODE",cre.Properties["MOULDGOODSCODE"].ToString()),
  1566. };
  1567. dt = new DataTable();
  1568. dt = conn.GetSqlResultToDt(sqlString, paras);
  1569. if (dt != null && dt.Rows.Count > 0)
  1570. {
  1571. //存在相同金蝶代码
  1572. sre.OtherStatus = -1001;
  1573. return sre;
  1574. }
  1575. }
  1576. #region 新增
  1577. if (cre.Properties["FromStatus"].ToString() == "Add")
  1578. {
  1579. //保存客户信息
  1580. sqlString = @"INSERT INTO TP_MST_MOULDGOODSCODE(
  1581. GOODSCODE,
  1582. MOULDGOODSCODE,
  1583. MOULDNAME,
  1584. VALUEFLAG
  1585. ) VALUES(
  1586. :GOODSCODE,
  1587. :MOULDGOODSCODE,
  1588. :MOULDNAME,
  1589. '1' )";
  1590. paras = new OracleParameter[]{
  1591. new OracleParameter(":GOODSCODE",cre.Properties["GOODSCODE"].ToString()),
  1592. new OracleParameter(":MOULDNAME",cre.Properties["MOULDNAME"].ToString()),
  1593. new OracleParameter(":MOULDGOODSCODE",cre.Properties["MOULDGOODSCODE"].ToString()),
  1594. };
  1595. }
  1596. #endregion
  1597. #region 编辑
  1598. if (cre.Properties["FromStatus"].ToString() == "Edit")
  1599. {
  1600. sqlString = @" SELECT 1 FROM TP_MST_MOULDGOODSCODE
  1601. WHERE VALUEFLAG=1
  1602. AND GOODSCODE=:GOODSCODE
  1603. AND MOULDGOODSCODE=:MOULDGOODSCODE
  1604. AND MOULDNAME=:MOULDNAME";
  1605. paras = new OracleParameter[]{
  1606. new OracleParameter(":GOODSCODE",cre.Properties["GOODSCODE"].ToString()),
  1607. new OracleParameter(":MOULDNAME",cre.Properties["MOULDNAME"].ToString()),
  1608. new OracleParameter(":MOULDGOODSCODE",cre.Properties["MOULDGOODSCODE"].ToString()),
  1609. };
  1610. dt = new DataTable();
  1611. dt = conn.GetSqlResultToDt(sqlString, paras);
  1612. if (dt != null && dt.Rows.Count > 0)
  1613. {
  1614. //存在相同版面编码
  1615. sre.OtherStatus = -1001;
  1616. return sre;
  1617. }
  1618. sqlString = @"UPDATE TP_MST_MOULDGOODSCODE
  1619. SET
  1620. GOODSCODE=:GOODSCODE,
  1621. MOULDGOODSCODE =:MOULDGOODSCODE,
  1622. MOULDNAME =:MOULDNAME
  1623. WHERE
  1624. GUID=:GUID";
  1625. paras = new OracleParameter[]{
  1626. new OracleParameter(":GOODSCODE",cre.Properties["GOODSCODE"].ToString()),
  1627. new OracleParameter(":MOULDNAME",cre.Properties["MOULDNAME"].ToString()),
  1628. new OracleParameter(":MOULDGOODSCODE",cre.Properties["MOULDGOODSCODE"].ToString()),
  1629. new OracleParameter(":GUID",cre.Properties["GUID"].ToString()),
  1630. };
  1631. }
  1632. #endregion
  1633. #region 删除
  1634. if (cre.Properties["FromStatus"].ToString() == "Delete")
  1635. {
  1636. sqlString = @"UPDATE TP_MST_MOULDGOODSCODE
  1637. SET
  1638. VALUEFLAG=0
  1639. WHERE GUID=:GUID
  1640. ";
  1641. paras = new OracleParameter[]{
  1642. new OracleParameter(":GUID",cre.Properties["GUID"].ToString()),
  1643. };
  1644. }
  1645. #endregion
  1646. int result = conn.ExecuteNonQuery(sqlString, paras);
  1647. if (result <= 0)
  1648. {
  1649. //未改变任何数据
  1650. sre.OtherStatus = -1003;
  1651. return sre;
  1652. }
  1653. else
  1654. {
  1655. //提交数据
  1656. sre.OtherStatus = 1;
  1657. conn.Commit();
  1658. }
  1659. return sre;
  1660. }
  1661. catch (Exception ex)
  1662. {
  1663. throw ex;
  1664. }
  1665. finally
  1666. {
  1667. if (conn != null &&
  1668. conn.ConnState == ConnectionState.Open)
  1669. {
  1670. conn.Disconnect();
  1671. }
  1672. }
  1673. }
  1674. ///<summary>
  1675. ///查询登录记录
  1676. /// </summary>
  1677. public static ServiceResultEntity GetUserLoginLogdata(SUserInfo sUserInfo, ClientRequestEntity cre)
  1678. {
  1679. IDBConnection conn = null;
  1680. try
  1681. {
  1682. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1683. OracleParameter[] paras = new OracleParameter[] { };
  1684. string sqlString = @"SELECT * from (SELECT
  1685. 0 AS Sel,
  1686. U.UserID,
  1687. U.UserCode,
  1688. U.limitMAC,
  1689. U.UserName,
  1690. POST.PostName,
  1691. U.CanPCLogin,
  1692. U.CanSmartLogin,
  1693. U.IsWorker,
  1694. U.IsGroutingWorker,
  1695. U.IsPublicBody,
  1696. U.CanLoginPRD,
  1697. U.CanLoginMBC,
  1698. U.ValueFlag,
  1699. O.OrganizationName,
  1700. O.OrganizationFullName,
  1701. U.Remarks,
  1702. TP_MST_USERLOGINLOG.MAC,
  1703. COMPUTERNAME,
  1704. ORGANIZATIONCODE,
  1705. CASE MAC
  1706. WHEN 'xx:xx:xx:xx:xx:xx' THEN
  1707. 'WEB质量登记'
  1708. ELSE
  1709. CASE
  1710. ACTIONTYPE
  1711. WHEN '0' THEN
  1712. 'PC登录'
  1713. WHEN '1' THEN
  1714. 'PC登出'
  1715. WHEN '2' THEN
  1716. '移动设备登录'
  1717. WHEN '3' THEN
  1718. '移动设备登出'
  1719. WHEN '4' THEN
  1720. 'PC登录MBC' ELSE 'PC登出MBC'
  1721. END
  1722. END as ACTIONTYPE,
  1723. IP ,
  1724. IMEI,
  1725. ACTIONTIME
  1726. FROM
  1727. TP_MST_USERLOGINLOG
  1728. LEFT JOIN TP_MST_User U ON u.USERID = TP_MST_USERLOGINLOG.USERID
  1729. LEFT JOIN TP_MST_Organization O ON U.Organizationid = O.Organizationid
  1730. LEFT JOIN TP_MST_POST POST ON POST.POSTID = U.POST
  1731. WHERE
  1732. U.AccountID = 1) where 1=1 AND ACTIONTIME>=to_date(:opentime,'yyyy-mm-dd hh24:mi:ss')AND ACTIONTIME<=to_date(:closetime,'yyyy-mm-dd hh24:mi:ss')";
  1733. if (!string.IsNullOrEmpty(cre.Properties["UserCode"].ToString()))
  1734. {
  1735. sqlString += "AND UserCode like :UserCode";
  1736. }
  1737. if (!string.IsNullOrEmpty(cre.Properties["UserName"].ToString()))
  1738. {
  1739. sqlString += " AND UserName like :UserName";
  1740. }
  1741. if (!string.IsNullOrEmpty(cre.Properties["Organization"].ToString()))
  1742. {
  1743. sqlString += " AND ORGANIZATIONCODE = :Organization";
  1744. }
  1745. if (!string.IsNullOrEmpty(cre.Properties["ActionType"].ToString()))
  1746. {
  1747. if (cre.Properties["ActionType"].ToString()== "6")
  1748. {
  1749. sqlString += " AND MAC = 'xx:xx:xx:xx:xx:xx'";
  1750. }
  1751. else { sqlString += " AND ActionType like :ActionType"; }
  1752. }
  1753. sqlString += @" ORDER BY
  1754. ACTIONTIME DESC";
  1755. paras = new OracleParameter[]{
  1756. new OracleParameter(":UserCode",'%'+cre.Properties["UserCode"].ToString()+'%'),
  1757. new OracleParameter(":UserName",'%'+cre.Properties["UserName"].ToString()+'%'),
  1758. new OracleParameter(":Organization",cre.Properties["Organization"].ToString()),
  1759. new OracleParameter(":ActionType",'%'+cre.Properties["ActionType"].ToString()+'%'),
  1760. new OracleParameter(":opentime",cre.Properties["opentime"].ToString()),
  1761. new OracleParameter(":closetime",cre.Properties["closetime"].ToString()),
  1762. };
  1763. ServiceResultEntity sre = new ServiceResultEntity();
  1764. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  1765. return sre;
  1766. }
  1767. catch (Exception ex)
  1768. {
  1769. throw ex;
  1770. }
  1771. finally
  1772. {
  1773. if (conn != null &&
  1774. conn.ConnState == ConnectionState.Open)
  1775. {
  1776. conn.Close();
  1777. }
  1778. }
  1779. }
  1780. }
  1781. }