SystemModuleLogicPartial.cs 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522
  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. string sqlString = @"
  1235. SELECT
  1236. TP_MST_GOODSKINGDEECODE.GOODSCODE,
  1237. gd.goodsname,
  1238. TP_MST_GOODSKINGDEECODE.GLAZETYPE,
  1239. TP_MST_GOODSKINGDEECODE.LOGONAME,
  1240. TP_MST_GOODSKINGDEECODE.KINGDEECODE
  1241. FROM
  1242. TP_MST_GOODSKINGDEECODE
  1243. LEFT JOIN TP_MST_GOODS gd on gd.GOODSCODE=TP_MST_GOODSKINGDEECODE.GOODSCODE
  1244. WHERE 1=1 AND TP_MST_GOODSKINGDEECODE.valueflag=1";
  1245. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"].ToString()))
  1246. {
  1247. sqlString += " AND TP_MST_GOODSKINGDEECODE.GOODSCODE like :GOODSCODE";
  1248. }
  1249. if (!string.IsNullOrEmpty(cre.Properties["GlazeType"].ToString()))
  1250. {
  1251. sqlString += " AND TP_MST_GOODSKINGDEECODE.GLAZETYPE = :GLAZETYPE";
  1252. }
  1253. if (!string.IsNullOrEmpty(cre.Properties["LogoName"].ToString()))
  1254. {
  1255. sqlString += " AND TP_MST_GOODSKINGDEECODE.LOGONAME = :LOGONAME";
  1256. }
  1257. if (!string.IsNullOrEmpty(cre.Properties["KingdeeCode"].ToString()))
  1258. {
  1259. sqlString += " AND TP_MST_GOODSKINGDEECODE.KINGDEECODE like :KINGDEECODE";
  1260. }
  1261. if (!string.IsNullOrEmpty(cre.Properties["GoodsName"].ToString()))
  1262. {
  1263. sqlString += " AND gd.goodsname like :GoodsName";
  1264. }
  1265. OracleParameter[] paras = new OracleParameter[]{
  1266. new OracleParameter(":GOODSCODE",'%'+cre.Properties["GoodsCode"].ToString()+'%'),
  1267. new OracleParameter(":GoodsName",'%'+cre.Properties["GoodsName"].ToString()+'%'),
  1268. new OracleParameter(":GLAZETYPE",cre.Properties["GlazeType"].ToString()),
  1269. new OracleParameter(":LOGONAME",cre.Properties["LogoName"].ToString()),
  1270. new OracleParameter(":KINGDEECODE",'%'+cre.Properties["KingdeeCode"].ToString()+'%'),
  1271. };
  1272. ServiceResultEntity sre = new ServiceResultEntity();
  1273. sre.Data = conn.GetSqlResultToDs(sqlString, paras);
  1274. return sre;
  1275. }
  1276. catch (Exception ex)
  1277. {
  1278. throw ex;
  1279. }
  1280. finally
  1281. {
  1282. if (conn != null &&
  1283. conn.ConnState == ConnectionState.Open)
  1284. {
  1285. conn.Close();
  1286. }
  1287. }
  1288. }
  1289. /// <summary>
  1290. /// 查询商标名称
  1291. /// </summary>
  1292. /// <param name="sUserInfo"></param>
  1293. /// <param name="goodsID"></param>
  1294. /// <returns></returns>
  1295. public static ServiceResultEntity GetLogoName(SUserInfo sUserInfo, ClientRequestEntity cre)
  1296. {
  1297. IDBConnection conn = null;
  1298. try
  1299. {
  1300. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1301. string sqlString = @"
  1302. SELECT
  1303. LogoID,
  1304. LogoName AS LogoNameCode
  1305. FROM
  1306. tp_mst_logo
  1307. WHERE
  1308. AccountID = 1
  1309. AND valueflag = '1'
  1310. ORDER BY
  1311. isdefault DESC,
  1312. displayno";
  1313. ServiceResultEntity sre = new ServiceResultEntity();
  1314. sre.Data = conn.GetSqlResultToDs(sqlString, null);
  1315. return sre;
  1316. }
  1317. catch (Exception ex)
  1318. {
  1319. throw ex;
  1320. }
  1321. finally
  1322. {
  1323. if (conn != null &&
  1324. conn.ConnState == ConnectionState.Open)
  1325. {
  1326. conn.Close();
  1327. }
  1328. }
  1329. }
  1330. ///<summary>
  1331. ///保存金蝶代码信息
  1332. /// </summary>
  1333. public static ServiceResultEntity AddKingdeeCode(SUserInfo sUserInfo, ClientRequestEntity cre)
  1334. {
  1335. IDBTransaction conn = null;
  1336. try
  1337. {
  1338. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  1339. ServiceResultEntity sre = new ServiceResultEntity();
  1340. DataTable dt = new DataTable();
  1341. string sqlString = string.Empty;
  1342. OracleParameter[] paras = new OracleParameter[] { };
  1343. //如果版面信息是新建的情况下,是否存在相同版面编码
  1344. if (cre.Properties["FromStatus"].ToString() == "Add")
  1345. {
  1346. sqlString = @"SELECT 1 FROM TP_MST_GOODSKINGDEECODE WHERE KINGDEECODE = :KINGDEECODE AND valueflag=1";
  1347. paras = new OracleParameter[] { new OracleParameter(":KINGDEECODE", cre.Properties["KINGDEECODE"].ToString()), };
  1348. dt = new DataTable();
  1349. dt = conn.GetSqlResultToDt(sqlString, paras);
  1350. if (dt != null && dt.Rows.Count > 0)
  1351. {
  1352. //存在相同金蝶代码
  1353. sre.OtherStatus = -1001;
  1354. return sre;
  1355. }
  1356. }
  1357. #region 新增
  1358. if (cre.Properties["FromStatus"].ToString() == "Add")
  1359. {
  1360. //保存客户信息
  1361. sqlString = @"INSERT INTO TP_MST_GOODSKINGDEECODE(
  1362. GOODSCODE,
  1363. GLAZETYPE,
  1364. LOGONAME,
  1365. KINGDEECODE,
  1366. VALUEFLAG
  1367. ) VALUES(
  1368. :GOODSCODE,
  1369. :GLAZETYPE,
  1370. :LOGONAME,
  1371. :KINGDEECODE,
  1372. '1' )";
  1373. paras = new OracleParameter[] {
  1374. new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"].ToString()),
  1375. new OracleParameter(":GLAZETYPE", cre.Properties["GLAZETYPE"].ToString()) ,
  1376. new OracleParameter(":LOGONAME", cre.Properties["LOGONAME"].ToString()) ,
  1377. new OracleParameter(":KINGDEECODE", cre.Properties["KINGDEECODE"].ToString()) ,
  1378. };
  1379. }
  1380. #endregion
  1381. #region 编辑
  1382. if (cre.Properties["FromStatus"].ToString() == "Edit")
  1383. {
  1384. sqlString = @"
  1385. SELECT 1 FROM TP_MST_GOODSKINGDEECODE WHERE KINGDEECODE = :KINGDEECODE AND KINGDEECODE != :KINGDEECODEONE AND valueflag=1";
  1386. paras = new OracleParameter[] {
  1387. new OracleParameter(":KINGDEECODE", cre.Properties["KINGDEECODE"].ToString()),
  1388. new OracleParameter(":KINGDEECODEONE", cre.Properties["KINGDEECODEONE"].ToString()),
  1389. };
  1390. dt = new DataTable();
  1391. dt = conn.GetSqlResultToDt(sqlString, paras);
  1392. if (dt != null && dt.Rows.Count > 0)
  1393. {
  1394. //存在相同版面编码
  1395. sre.OtherStatus = -1001;
  1396. return sre;
  1397. }
  1398. sqlString = @"UPDATE TP_MST_GOODSKINGDEECODE
  1399. SET
  1400. GOODSCODE=:GOODSCODE,
  1401. GLAZETYPE = :GLAZETYPE,
  1402. LOGONAME =:LOGONAME,
  1403. KINGDEECODE = :KINGDEECODE
  1404. WHERE
  1405. KINGDEECODE = :KINGDEECODEONE";
  1406. paras = new OracleParameter[] {
  1407. new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"].ToString()) ,
  1408. new OracleParameter(":GLAZETYPE", cre.Properties["GLAZETYPE"].ToString()) ,
  1409. new OracleParameter(":LOGONAME", cre.Properties["LOGONAME"].ToString()) ,
  1410. new OracleParameter(":KINGDEECODEONE", cre.Properties["KINGDEECODEONE"].ToString()) ,
  1411. new OracleParameter(":KINGDEECODE", cre.Properties["KINGDEECODE"].ToString()) ,
  1412. };
  1413. }
  1414. #endregion
  1415. #region 删除
  1416. if (cre.Properties["FromStatus"].ToString() == "Delete")
  1417. {
  1418. sqlString = @"UPDATE TP_MST_GOODSKINGDEECODE
  1419. SET
  1420. VALUEFLAG=0
  1421. WHERE
  1422. KINGDEECODE = :KINGDEECODEONE";
  1423. paras = new OracleParameter[] {
  1424. new OracleParameter(":KINGDEECODEONE", cre.Properties["KINGDEECODEONE"].ToString()) ,
  1425. };
  1426. }
  1427. #endregion
  1428. int result = conn.ExecuteNonQuery(sqlString, paras);
  1429. if (result <= 0)
  1430. {
  1431. //未改变任何数据
  1432. sre.OtherStatus = -1003;
  1433. return sre;
  1434. }
  1435. else
  1436. {
  1437. //提交数据
  1438. sre.OtherStatus = 1;
  1439. conn.Commit();
  1440. }
  1441. return sre;
  1442. }
  1443. catch (Exception ex)
  1444. {
  1445. throw ex;
  1446. }
  1447. finally
  1448. {
  1449. if (conn != null &&
  1450. conn.ConnState == ConnectionState.Open)
  1451. {
  1452. conn.Disconnect();
  1453. }
  1454. }
  1455. }
  1456. }
  1457. }