FrmPurMat.cs 150 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;using Pur.Entity;
  10. using Infragistics.Win;
  11. using Infragistics.Win.UltraWinGrid;
  12. using Core.Mes.Client.Comm.Control;
  13. using Infragistics.Win.UltraWinTree;
  14. using Pur.Entity.configureEntity;
  15. using System.Data.OracleClient;
  16. using Core.Mes.Client.Comm.Tool;
  17. using Infragistics.Win.UltraWinEditors;
  18. using Infragistics.Win.UltraWinScrollBar;
  19. using com.hnshituo.pur.vo;
  20. using System.Collections;
  21. using Core.Mes.Client.Comm.Server;
  22. using Pur.Pop_upWindow;
  23. using Pur.Entity.require_planEntiy;
  24. using System.Reflection;
  25. using Core.Mes.Client.Comm.Format;
  26. namespace Pur.configure
  27. {
  28. public partial class FrmPurMat : FrmPmsBase
  29. {
  30. DataTable dt_Purmatclass = null;
  31. Boolean QClickCellOrQuery = false;//是否点击查询按钮或grid数据单元格
  32. UltraTreeNode qUltraNode = null;
  33. //string strBUYER_DEPT_CODE = "";
  34. //string strMENT_UNIT_CODE = "";
  35. string QstrBUYER_ROLE_ID = "";
  36. string QstrPLANNER_ROLE_ID = "";
  37. string QstrBUYER_ROLE_ID1 = "";
  38. string QstrPLANNER_ROLE_ID1 = "";
  39. string QstrINV_PHYSIC_USERID = "";//库管员
  40. string planPrice = "";//计划价格
  41. MatEntity Q_mat = null;
  42. public FrmPurMat()
  43. {
  44. InitializeComponent();
  45. ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  46. ultraGrid3.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  47. ultraGrid4.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  48. txt_IS_DEFAULT_ATTR.SelectedIndex = 0;
  49. txt_IsLevel.SelectedIndex = 0;
  50. txt_IS_DEFAULT_STANDRANDS.SelectedIndex = 0;
  51. txt_IS_DEFAULT_UOM.SelectedIndex = 0;
  52. cmbNum.SelectedIndex = 0;//默认显示500条数据
  53. //给编辑区设置滚动条
  54. //foreach (Control gbox in ultraGroupBox6.Controls)
  55. //{
  56. // if (gbox is UltraScrollBar) continue;
  57. // gbox.Tag = gbox.Tag = gbox.Location.Y;
  58. //}
  59. //panel1.VerticalScroll.Value = panel1.VerticalScroll.Maximum;
  60. }
  61. /// <summary>
  62. /// 界面加载函数
  63. /// </summary>
  64. /// <param name="e"></param>
  65. protected override void OnLoad(EventArgs e)
  66. {
  67. base.OnLoad(e);
  68. ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  69. ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  70. //ultraGrid2.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  71. }
  72. /// <summary>
  73. /// 窗体加载事件
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="e"></param>
  77. private void FrmPurMat_Load(object sender, EventArgs e)
  78. {
  79. getUltcmbBindData();
  80. setUltCmbEdt_sel();
  81. string basecode = "1234";
  82. DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { basecode }, this.ob);
  83. dt = dt.AsEnumerable().Where(p => p["VALIDFLAG"].ToString().Equals("1")).CopyToDataTable();
  84. Ultcmb_MAT_TYPE.DataSource = dt;
  85. Ultcmb_MAT_TYPE.DisplayMember = "BASENAME";
  86. Ultcmb_MAT_TYPE.ValueMember = "BASECODE";
  87. GridHelper.RefreshAndAutoSize(ultraGrid1);
  88. GridHelper.RefreshAndAutoSize(ultraGrid2);
  89. }
  90. //菜单按钮事件
  91. public override void ToolBar_Click(object sender, string ToolbarKey)
  92. {
  93. switch (ToolbarKey)
  94. {
  95. case "Query":
  96. QClickCellOrQuery = true;
  97. GetPUR_MAT_Class();
  98. if (ultraGrid1.Rows.Count > 0)
  99. {
  100. ulTreeMat.CollapseAll();
  101. UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(ultraGrid1.Rows[0].Cells["ARCCODE"].Value.ToString());
  102. ulTreeMat.ActiveNode = uttNode;
  103. if (uttNode == null)
  104. {
  105. MessageUtil.ShowTips("物料名称:" + ultraGrid1.Rows[0].Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + ultraGrid1.Rows[0].Cells["ARCCODE"].Value.ToString());
  106. }
  107. else
  108. {
  109. while (ulTreeMat.ActiveNode != uttNode)
  110. {
  111. ulTreeMat.ActiveNode = uttNode;
  112. }
  113. uttNode.Expanded = true;
  114. //展开分类
  115. while (uttNode.Parent != null)
  116. {
  117. uttNode = uttNode.Parent;
  118. uttNode.Expanded = true;
  119. }
  120. }
  121. QClickCellOrQuery = false;//设置未点击
  122. }
  123. break;
  124. case "Add":
  125. AddPUR_MAT();
  126. break;
  127. case "Update":
  128. UpdPUR_MAT();
  129. break;
  130. case "Delete":
  131. DelPUR_MAT();
  132. break;
  133. case "UsePUR_MAT"://启用物料
  134. UsePUR_MAT();
  135. break;
  136. case "updateSrole_1":
  137. if (ulTreeMat.ActiveNode != null)
  138. {
  139. updateSrole(ulTreeMat.ActiveNode.Key, "1");
  140. }
  141. break;
  142. case "updateSrole_2":
  143. if (ulTreeMat.ActiveNode != null)
  144. {
  145. updateSrole(ulTreeMat.ActiveNode.Key, "2");
  146. }
  147. break;
  148. case "updateSrole_3"://批量修改库管员
  149. if (ulTreeMat.ActiveNode != null)
  150. {
  151. updateSrole(ulTreeMat.ActiveNode.Key, "3");
  152. }
  153. break;
  154. case "setMatClassPross":
  155. setMatClassPross();
  156. break;
  157. case "addSupps":
  158. addSupps(ulTreeMat.ActiveNode.Key, txt_suppCode.Text);
  159. break;
  160. case "updPrice"://维护计划价格
  161. updPrice();
  162. break;
  163. case "doExcel":
  164. doExcel();
  165. break;
  166. }
  167. }
  168. private void doExcel()
  169. {
  170. try
  171. {
  172. this.Cursor = Cursors.Default;
  173. if (ultraGrid2.Rows.Count <= 0)
  174. {
  175. MessageUtil.ShowTips( "无可导出明细!");
  176. }
  177. ArrayList alUltraGrid = new ArrayList();
  178. alUltraGrid.Add(ultraGrid1);
  179. ArrayList alSheeft = new ArrayList();
  180. alSheeft.Add("物料明细");
  181. if (ultraGrid1.Rows.Count > 0)
  182. {
  183. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "物料明细表");//导出excel
  184. }
  185. else
  186. {
  187. MessageUtil.ShowTips("无可导出明细!");
  188. }
  189. }
  190. catch (Exception e)
  191. {
  192. MessageUtil.ShowTips("导出失败" + e.Message);
  193. }
  194. finally
  195. {
  196. this.Cursor = Cursors.Default;
  197. }
  198. }
  199. /// <summary>
  200. /// 维护计划价格
  201. /// </summary>
  202. private void updPrice()
  203. {
  204. if(ultraTabControl2.SelectedTab.Key == "01")
  205. {
  206. ultraTabControl1.SelectedTab = ultraTabPageControl2.Tab;
  207. }
  208. }
  209. /// <summary>
  210. /// 查询物料分类
  211. /// </summary>
  212. public void GetPUR_MAT_Class()
  213. {
  214. //查询物料分类
  215. PurmatclassEntity mat = new PurmatclassEntity();
  216. mat.Validflag = "1";
  217. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "find", new object[] { mat, 0, 0 });
  218. getultree(dt);//绑定物料分类表
  219. //查询物料
  220. getMat(getEnSelContion(null));
  221. }
  222. /// <summary>
  223. /// 查询物料
  224. /// </summary>
  225. private void getMat(MatEntity mat)
  226. {
  227. if (ulTreeMat.Nodes.Count == 0)
  228. { return; }
  229. if(mat==null)
  230. { mat = new MatEntity(); }
  231. if(chk_showHasDelete.Checked)
  232. {
  233. mat.Validflag=null;
  234. }
  235. else
  236. {
  237. mat.Validflag="1";
  238. }
  239. DataTable dt_mat = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatService", "getMat", new object[] { mat});
  240. //按创建时间降序
  241. if (dt_mat.Rows.Count > 1)
  242. {
  243. dt_mat.DefaultView.Sort = "CREATETIME DESC";
  244. dt_mat = dt_mat.DefaultView.ToTable();
  245. }
  246. dataTable1.Rows.Clear();
  247. GridHelper.CopyDataToDatatable(ref dt_mat, ref dataTable1, true);//绑定物料分类表
  248. Q_mat = mat;
  249. dt_Purmatclass = dt_mat;
  250. showHasDelete(chk_showHasDelete.Checked);//隐藏作废的物料
  251. if (ultraGrid1.Rows.Count == 0)
  252. {
  253. dataTable2.Rows.Clear();
  254. dataTable3.Rows.Clear();
  255. dataTable4.Rows.Clear();
  256. dataTable5.Rows.Clear();
  257. getControlBoxValue(0);//清空控件
  258. setUltCmbEdt_sel();
  259. }
  260. ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  261. GridHelper.RefreshAndAutoSize(ultraGrid2);
  262. }
  263. /// <summary>
  264. /// 查询供应商
  265. /// </summary>
  266. /// <param name="Itemcode">物料代码</param>
  267. private void getSuppGrade(string strItemcode)
  268. {
  269. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.SuppGradeService", "getMat_Supp", new object[] { strItemcode });
  270. GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);//绑定物料分类表
  271. if (dataTable2.Rows.Count < 1)
  272. {
  273. getControlBoxValue(1);//清空控件
  274. }
  275. ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  276. GridHelper.RefreshAndAutoSize(ultraGrid2);
  277. }
  278. /// <summary>
  279. /// 获取物料属性
  280. /// </summary>
  281. /// <param name="parm"></param>
  282. private void getItemAttr()
  283. {
  284. //查询父表
  285. //查询属性父表
  286. PurMatAttrsEntity MatAttrsEntity = new PurMatAttrsEntity();
  287. MatAttrsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  288. MatAttrsEntity.Validflag = "1";
  289. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatAttrsService", "getMatAttrClass", new object[] { MatAttrsEntity });
  290. GridHelper.CopyDataToDatatable(ref dt, ref dataTable7, true);//获取物料属性
  291. //查询子表
  292. dataTable3.Rows.Clear();
  293. Dictionary<string, object> param = new Dictionary<string, object>();
  294. param.Add("ItemCode", ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());
  295. param.Add("Validflag", "1");
  296. DataTable dt_mat = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatAttrsService", "find", new object[] { param, 0, 0 });
  297. //按是否常用排序
  298. if (dt_mat.Rows.Count > 1)
  299. {
  300. dt_mat.DefaultView.Sort = "ISDEFAULT DESC";
  301. dt_mat = dt_mat.DefaultView.ToTable();
  302. }
  303. for (int i = 0; i < dt_mat.Rows.Count; i++)
  304. {
  305. if (dt_mat.Rows[i]["ISDEFAULT"].ToString() == "1")
  306. {
  307. dt_mat.Rows[i]["ISDEFAULT"] = "是";
  308. }
  309. else if (dt_mat.Rows[i]["ISDEFAULT"].ToString() == "0")
  310. {
  311. dt_mat.Rows[i]["ISDEFAULT"] = "否";
  312. }
  313. if (dt_mat.Rows[i]["islevel"].ToString() == "1")
  314. {
  315. dt_mat.Rows[i]["islevel"] = "是";
  316. }
  317. else
  318. {
  319. dt_mat.Rows[i]["islevel"] = "否";
  320. }
  321. }
  322. GridHelper.CopyDataToDatatable(ref dt_mat, ref dataTable3, true);//绑定物料规格
  323. if (dataTable3.Rows.Count < 1)
  324. {
  325. getControlBoxValue(2);//清空控件
  326. }
  327. }
  328. /// <summary>
  329. /// 获取物料标准编号
  330. /// </summary>
  331. private void getMatStandard()
  332. {
  333. dataTable4.Rows.Clear();
  334. if (ultraGrid1.ActiveRow != null)
  335. {
  336. PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
  337. PurMatStandards_Entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  338. PurMatStandards_Entity.Validflag = "1";
  339. DataTable dt_matStandards = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatStandardsService", "find", new object[] { PurMatStandards_Entity, 0, 0 });
  340. //按是否常用排序
  341. if (dt_matStandards.Rows.Count > 1)
  342. {
  343. dt_matStandards.DefaultView.Sort = "ISDEFAULT DESC";
  344. dt_matStandards = dt_matStandards.DefaultView.ToTable();
  345. }
  346. for (int i = 0; i < dt_matStandards.Rows.Count; i++)
  347. {
  348. if (dt_matStandards.Rows[i]["ISDEFAULT"].ToString() == "1")
  349. {
  350. dt_matStandards.Rows[i]["ISDEFAULT"] = "是";
  351. }
  352. else if (dt_matStandards.Rows[i]["ISDEFAULT"].ToString() == "0")
  353. {
  354. dt_matStandards.Rows[i]["ISDEFAULT"] = "否";
  355. }
  356. }
  357. GridHelper.CopyDataToDatatable(ref dt_matStandards, ref dataTable4, true);//绑定物料规格
  358. if (dataTable4.Rows.Count < 1)
  359. {
  360. getControlBoxValue(3);//清空控件
  361. }
  362. }
  363. }
  364. /// <summary>
  365. /// 获取单位转换
  366. /// </summary>
  367. private void getMatUOM()
  368. {
  369. dataTable5.Rows.Clear();
  370. if (ultraGrid1.ActiveRow != null)
  371. {
  372. PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
  373. MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  374. //MatUomsEntity.Validflag = "1";
  375. DataTable dt_matUOM = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatUomsService", "find", new object[] { MatUomsEntity, 0, 0 });
  376. //按是否常用排序
  377. if (dt_matUOM.Rows.Count > 1)
  378. {
  379. dt_matUOM.DefaultView.Sort = "ISDEFAULT DESC";
  380. dt_matUOM = dt_matUOM.DefaultView.ToTable();
  381. }
  382. for (int i = 0; i < dt_matUOM.Rows.Count; i++)
  383. {
  384. if (dt_matUOM.Rows[i]["ISDEFAULT"].ToString() == "1")
  385. {
  386. dt_matUOM.Rows[i]["ISDEFAULT"] = "是";
  387. }
  388. else if (dt_matUOM.Rows[i]["ISDEFAULT"].ToString() == "0")
  389. {
  390. dt_matUOM.Rows[i]["ISDEFAULT"] = "否";
  391. }
  392. //是否常用
  393. if (dt_matUOM.Rows[i]["Validflag"].ToString() == "1")
  394. {
  395. dt_matUOM.Rows[i]["Validflag"] = "正常";
  396. }
  397. else if (dt_matUOM.Rows[i]["Validflag"].ToString() == "0")
  398. {
  399. dt_matUOM.Rows[i]["Validflag"] = "作废";
  400. }
  401. }
  402. GridHelper.CopyDataToDatatable(ref dt_matUOM, ref dataTable5, true);//绑定物料规格
  403. if (dataTable5.Rows.Count < 1)
  404. {
  405. getControlBoxValue(4);//清空控件
  406. }
  407. foreach (UltraGridRow ugr in ultraGrid5.Rows)
  408. {
  409. if (ugr.Cells["VALIDFLAG"].Value.ToString() == "作废")
  410. {
  411. //ugr.Hidden = false;//显示
  412. ugr.Appearance.ForeColor = Color.Red;
  413. }
  414. }
  415. }
  416. }
  417. /// <summary>
  418. /// 增加物料
  419. /// </summary>
  420. public void AddPUR_MAT()
  421. {
  422. if (ultraTabControl1.SelectedTab.Key == "01")//添加物料
  423. {
  424. if (ulTreeMat.ActiveNode != null)//选中物料分类节点
  425. {
  426. MatEntity mat_entity = new MatEntity();
  427. if (ulTreeMat.ActiveNode.Key.Length < 5)
  428. {
  429. MessageUtil.ShowTips("当前节点不是物料小类,不能添加物料");
  430. return;
  431. }
  432. if (txt_ITEM_NAME.Text.Trim() == "")
  433. {
  434. MessageUtil.ShowTips("物料名称不能为空");
  435. return;
  436. }
  437. if (txt_ITEM_CODE.Text.Trim().Substring(0, 5) != ulTreeMat.ActiveNode.Key)
  438. {
  439. if (MessageUtil.ShowYesNoAndQuestion("填写的物料编码的前5位为【" + txt_ITEM_CODE.Text.Trim().Substring(0, 5) + "】,和当前所选分类编码【" + ulTreeMat.ActiveNode.Key + "】不同,确定是否添加?").Equals(DialogResult.No))
  440. { return; }
  441. }
  442. if (cb_BASE_UNIT_FLAG.Checked)
  443. {
  444. if (txt_BASE_UNIT_VALUE.Text == "" || !StringUtil.IsNumber(txt_BASE_UNIT_VALUE.Text))
  445. {
  446. MessageUtil.ShowTips("基吨值不能为空,且必须为数字");
  447. return;
  448. }
  449. if (txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') == -1 && txt_BASE_UNIT_VALUE.Text.Trim().Length > 6)
  450. {
  451. MessageUtil.ShowTips("基吨值整数长度不超过6位");
  452. return;
  453. }
  454. if (txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') != -1 && txt_BASE_UNIT_VALUE.Text.Trim().Length > 6)
  455. {
  456. if (txt_BASE_UNIT_VALUE.Text.Trim().Substring(0, txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.')).Length > 6)
  457. {
  458. MessageUtil.ShowTips("基吨值整数长度不超过6位");
  459. return;
  460. }
  461. if (txt_BASE_UNIT_VALUE.Text.Trim().Substring(txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') + 1).Length > 6)
  462. {
  463. MessageUtil.ShowTips("基吨值小数长度不超过6位");
  464. return;
  465. }
  466. }
  467. }
  468. mat_entity.ItemName = txt_ITEM_NAME.Text.Replace(" ","");
  469. if (isExsitRow("com.hnshituo.pur.configure.service.MatService","isExsitItemName", mat_entity) > 0)
  470. {
  471. MessageUtil.ShowTips("添加失败 " + "数据库中已存在相同的物料名称");
  472. return;
  473. }
  474. mat_entity.ItemName = null;//清空物料名称,方便下一步判断物料编码是否相同
  475. UltraTreeNode ultNode = ulTreeMat.ActiveNode;
  476. //判断物料名称是否相同
  477. if (ultraGrid1.ActiveRow==null || ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() != txt_ITEM_CODE.Text.Trim())//自定义输入物料编码
  478. {
  479. if (txt_ITEM_CODE.Text.Trim().Contains("@"))
  480. {
  481. MessageUtil.ShowTips("物料编码中不能包含“@”字符");
  482. return;
  483. }
  484. if (txt_ITEM_CODE.Text.Trim().Length != 15)
  485. {
  486. MessageUtil.ShowTips("手动输入编码必须为15位");
  487. return;
  488. }
  489. //判断编码是否存在
  490. mat_entity.ItemCode = txt_ITEM_CODE.Text.Trim();
  491. if (isExsitRow("com.hnshituo.pur.configure.service.MatService", mat_entity) > 0)
  492. {
  493. MessageUtil.ShowTips("添加失败 " + "数据库中已存在相同的物料编码");
  494. return;
  495. }
  496. }
  497. else
  498. {
  499. mat_entity.ItemCode = getItemCodeClass(ulTreeMat.ActiveNode.Key, "");//物料编码
  500. }
  501. // 是否使用采购单位
  502. //if (ultChkSuppUon.Checked)
  503. //{
  504. // mat_entity.ItemUseUom = "1";// 是否使用采购单位,0:否,1:是
  505. // mat_entity.ItemUom = Ultcmb_ITEM_UOM.Text;//采购单位(个、袋、桶)
  506. // double num = 0;
  507. // double.TryParse(txt_ITEM_UOM_CONEFFICIENT.Text, out num);
  508. // mat_entity.ItemUomConefficient = num;//转换系数
  509. //}
  510. //else
  511. //{
  512. // mat_entity.ItemUseUom = "0";// 是否使用采购单位,0:否,1:是
  513. // mat_entity.ItemUom = Ultcmb_WEIGHT_UNIT.Text;//库存单位赋给采购单位
  514. //}
  515. //mat_entity.ItemUom = Ultcmb_WEIGHT_UNIT.Text;//库存单位赋给采购单位
  516. //mat_entity.ItemUomConefficient = 1;//转换系数
  517. if (cb_BASE_UNIT_FLAG.Checked)//基顿标识
  518. {
  519. mat_entity.BaseUnitFlag = "1";
  520. mat_entity.BaseUnitValue = double.Parse(txt_BASE_UNIT_VALUE.Text);
  521. }
  522. else
  523. {
  524. mat_entity.BaseUnitFlag = "0";
  525. }
  526. mat_entity.IsBudgetCtrl = txt_IS_BUDGET_CTRL.Value == null ? null : txt_IS_BUDGET_CTRL.Value.ToString();
  527. mat_entity.WeightUnit = Ultcmb_WEIGHT_UNIT.Text;//库存单位
  528. mat_entity.WeightUnitCode = Ultcmb_WEIGHT_UNIT_CODE.Text;//库存单位编码
  529. mat_entity.ReceiveType = Ultcmb_RECEIVE_TYPE.Value == null ? null : Ultcmb_RECEIVE_TYPE.Value.ToString();//入库类型;1:直接入库2:收货质检入库3:JIT入库4:VMI入库
  530. if (Ultcmb_BATCH_FLAG.Value == null)
  531. {
  532. MessageUtil.ShowTips("添加失败 " + "“是否批次控制”不能为空");
  533. return;
  534. }
  535. if (txt_DELVRY_RANGE_TPE.SelectedIndex == -1)
  536. {
  537. MessageUtil.ShowTips("请选择交货量差方式");
  538. txt_DELVRY_RANGE_TPE.Focus();
  539. return;
  540. }
  541. mat_entity.DelvryRangeTpe =txt_DELVRY_RANGE_TPE.Value.ToString().Trim();//交货量差方式
  542. if ("1" == txt_DELVRY_RANGE_TPE.Value.ToString().Trim() || "2" == txt_DELVRY_RANGE_TPE.Value.ToString().Trim())
  543. {
  544. if (txt_DELVRY_RANGE_MIN.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MIN.Value.ToString().Trim()))
  545. {
  546. mat_entity.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN.Value.ToString());//交货量差下限
  547. }
  548. else
  549. {
  550. MessageUtil.ShowTips("请填写交货量差下限值");
  551. txt_DELVRY_RANGE_MIN.Focus();
  552. return;
  553. }
  554. if (txt_DELVRY_RANGE_MAX.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MAX.Value.ToString().Trim()))
  555. {
  556. mat_entity.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX.Value.ToString());//交货量差上限
  557. }
  558. else
  559. {
  560. MessageUtil.ShowTips("请填写交货量差上限值");
  561. txt_DELVRY_RANGE_MAX.Focus();
  562. return;
  563. }
  564. }
  565. else
  566. {
  567. mat_entity.DelvryRangeMin = 0;
  568. mat_entity.DelvryRangeMax = 0;
  569. }
  570. mat_entity.PcFlag = txt_PC_FLAG.Value == null ? null : txt_PC_FLAG.Value.ToString();//是检化验
  571. mat_entity.BatchFlag = Ultcmb_BATCH_FLAG.Value == null ? null : Ultcmb_BATCH_FLAG.Value.ToString();//是否批次控制
  572. mat_entity.PurStandards = Ultcmb_PUR_STANDARDS.Value == null ? null : Ultcmb_PUR_STANDARDS.Value.ToString();//采购标准
  573. mat_entity.InvWasteFacUom = Ultcmb_INV_WASTE_FAC_UOM.Value == null ? 0 : double.Parse(Ultcmb_INV_WASTE_FAC_UOM.Value.ToString());//库存损耗率单位
  574. //mat_entity.ShareCkSpecFlag = Ultcmb_SHARE_CK_SPEC_FLAG.Value == null ? null : Ultcmb_SHARE_CK_SPEC_FLAG.Value.ToString();//是否与子规格共用库存
  575. mat_entity.MeteringFlag = Ultcmb_METERING_FLAG.Value == null ? null : Ultcmb_METERING_FLAG.Value.ToString();//是否计量
  576. mat_entity.PriceType = Ultcmb_PRICE_TYPE.Text;//计价类型
  577. mat_entity.CurrencyCode = Ultcmb_CURRENCY_CODE.Text;//币种代码
  578. mat_entity.LifeCycleUom = Ultcmb_LIFE_CYCLE_UOM.Text;//有效期单位
  579. mat_entity.PurStandardsCode = txt_PUR_STANDARDS_CODE.Text;//采购标准编号
  580. mat_entity.MinStock = txt_MIN_STOCK.Text.Trim() == "" ? 0 : double.Parse(txt_MIN_STOCK.Text);//最小库存(预警)
  581. mat_entity.MaxStock = txt_MAX_STOCK.Text.Trim() == "" ? 0 : double.Parse(txt_MAX_STOCK.Text);//最大库存(预警)
  582. mat_entity.LeadTime = txt_LEAD_TIME.Text.Trim() == "" ? 0 : double.Parse(txt_LEAD_TIME.Text);//采购提前时间(天)
  583. mat_entity.InvWasteFac = txt_INV_WASTE_FAC.Text.Trim() == "" ? 0 : double.Parse(txt_INV_WASTE_FAC.Text);//库存损耗率
  584. mat_entity.LifeCycle = txt_LIFE_CYCLE.Text.Trim() == "" ? 0 : double.Parse(txt_LIFE_CYCLE.Text);//有效期
  585. mat_entity.MinQty = txt_MIN_QTY.Text.Trim() == "" ? 0 : double.Parse(txt_MIN_QTY.Text);//最小采购数量
  586. mat_entity.QtyMultiple = txt_QTY_MULTIPLE.Text.Trim() == "" ? 0 : double.Parse(txt_QTY_MULTIPLE.Text);//批量数
  587. mat_entity.BugPrice = txt_BUG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_BUG_PRICE.Text);//计划价
  588. mat_entity.LastPrice = txt_LAST_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_LAST_PRICE.Text);//最近采购价
  589. mat_entity.MonthEndAvgPrice = txt_MONTH_END_AVG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_MONTH_END_AVG_PRICE.Text);//月末移动平均价
  590. mat_entity.ItemName = txt_ITEM_NAME.Text.Trim().Replace(" "," ").Replace("(","(").Replace(")",")");//物料名称
  591. mat_entity.ItemDescE = txt_ITEM_DESC_E.Text;//物料英文名称
  592. mat_entity.ItemDesc = txt_ITEM_DESC.Text;//物料描述
  593. mat_entity.ItemModel = txt_ITEM_MODEL.Text;//物料材质
  594. mat_entity.ItemSpec = txt_ITEM_SPEC.Text;//物料型号规格
  595. mat_entity.BuyerRoleId = QstrBUYER_ROLE_ID;
  596. mat_entity.PlannerRoleId = QstrPLANNER_ROLE_ID;
  597. mat_entity.BuyerRoleName = txt_BUYER_ROLE_NAME.Text;
  598. mat_entity.PlannerRoleName = txt_PLANNER_ROLE_NAME.Text;
  599. mat_entity.InvPhysicUserid = QstrINV_PHYSIC_USERID;//库管员
  600. mat_entity.InvPhysicUsername = txt_INV_PHYSIC_USERID.Text;//库管员名称
  601. //mat_entity.BuyerUnitCode = strBUYER_DEPT_CODE;//采购科室代码
  602. //mat_entity.BuyerUnitDesc = txt_BUYER_UNITCODE.Text;//采购科室描述
  603. //mat_entity.MentUnitCode = strMENT_UNIT_CODE;//采购管理科室代码
  604. //mat_entity.MentUnitDesc = txt_MENT_UNIT_CODE.Text;//采购管理科室代码
  605. mat_entity.ArcCode = ulTreeMat.ActiveNode.Key;//物料只保存分类编码,不保存父类编码
  606. mat_entity.ArcItem = ulTreeMat.ActiveNode.Text;//物料分类编码名称
  607. mat_entity.CreateName = UserInfo.GetUserName();
  608. mat_entity.CreateUserid = UserInfo.GetUserID();
  609. mat_entity.CreateTime = System.DateTime.Now;
  610. mat_entity.Validflag = "1";
  611. mat_entity.MatType = Ultcmb_MAT_TYPE.Value.ToString2();
  612. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "doInsert", new object[] { mat_entity });//添加操作
  613. if (crt.Resultcode != 0)
  614. {
  615. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  616. return;
  617. }
  618. if (mat_entity.MeteringFlag.Equals("1"))
  619. {
  620. // 添加数据到计量系统
  621. string json = JSONFormat.Format(mat_entity);
  622. CoreClientParam ccp = new CoreClientParam();
  623. ccp.ServerName = "com.hnshituo.pur.configure.service.impl.MeterBaseMatterInforService";
  624. ccp.MethodName = "insert";
  625. ccp.ServerParams = new object[] { json };
  626. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  627. }
  628. MessageUtil.ShowTips("添加成功!");
  629. if (ulTreeMat.ActiveNode != null)
  630. {
  631. MatEntity mM = new MatEntity();
  632. mM.ArcCode = ulTreeMat.ActiveNode.Key;
  633. //mM.Validflag = "1";
  634. getMat(mM);//刷新物料
  635. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
  636. }
  637. }
  638. else
  639. {
  640. MessageUtil.ShowTips("请选择物料分类");
  641. }
  642. }
  643. else if (ultraTabControl1.SelectedTab.Key == "0")//增加供应商
  644. {
  645. if (ultraGrid1.ActiveRow != null)
  646. {
  647. if (txt_suppCode.Text.Trim() == "")
  648. {
  649. MessageUtil.ShowTips("请选择供应商");
  650. return;
  651. }
  652. Supp EntitySupp = this.execute<Supp>("com.hnshituo.pur.configure.service.SuppService", "findById", new object[] { txt_suppCode.Text });
  653. MatEntity mat_entity = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() });
  654. Entity_SuppGrade EntitySuppGrade = new Entity_SuppGrade();
  655. EntitySuppGrade.SuppCode = EntitySupp.SuppCode;
  656. EntitySuppGrade.ItemCode = mat_entity.ItemCode;
  657. if (isExsitRow("com.hnshituo.pur.configure.service.SuppGradeService", EntitySuppGrade) > 0)//包含相同的文件
  658. {
  659. MessageUtil.ShowTips("数据库中存在相同的供应商,请重新选择");
  660. return;
  661. }
  662. EntitySuppGrade.SuppName = EntitySupp.SuppName;
  663. EntitySuppGrade.SuppShortName = EntitySupp.SuppShortName;
  664. EntitySuppGrade.SuppPerGrade = EntitySupp.SuppCreditRate;
  665. EntitySuppGrade.IsDefault = txt_IS_DEFAULT.Value == null ? null : txt_IS_DEFAULT.Value.ToString();
  666. EntitySuppGrade.ItemCode = mat_entity.ItemCode;
  667. EntitySuppGrade.ItemDesc = mat_entity.ItemDesc;
  668. EntitySuppGrade.ItemDescE = mat_entity.ItemDescE;
  669. EntitySuppGrade.ItemName = mat_entity.ItemName;
  670. //EntitySuppGrade.BuyerRoleId = QstrBUYER_ROLE_ID1;
  671. //EntitySuppGrade.PlannerRoleName = QstrPLANNER_ROLE_ID1;
  672. //EntitySuppGrade.BuyerRoleName = txt_BUYER_ROLE_NAME1.Text;
  673. //EntitySuppGrade.PlannerRoleName = txt_PLANNER_ROLE_NAME1.Text;
  674. if (txt_delivery_type_2.SelectedIndex == -1)
  675. {
  676. MessageUtil.ShowTips("请选择交货差方式");
  677. txt_delivery_type_2.Focus();
  678. return;
  679. }
  680. EntitySuppGrade.DelvryRangeTpe = txt_delivery_type_2.Value.ToString().Trim();//交货量差方式
  681. if ("1" == txt_delivery_type_2.Value.ToString().Trim() || "2" == txt_delivery_type_2.Value.ToString().Trim())
  682. {
  683. if (txt_DELVRY_RANGE_MIN2.Value != null)
  684. {
  685. EntitySuppGrade.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN2.Value.ToString());//交货量差下限
  686. }
  687. else
  688. {
  689. MessageUtil.ShowTips("请填写交货量差下限值");
  690. txt_DELVRY_RANGE_MIN2.Focus();
  691. return;
  692. }
  693. if (txt_DELVRY_RANGE_MAX2.Value != null)
  694. {
  695. EntitySuppGrade.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX2.Value.ToString());//交货量差上限
  696. }
  697. else
  698. {
  699. MessageUtil.ShowTips("请填写交货量差上限值");
  700. txt_DELVRY_RANGE_MAX2.Focus();
  701. return;
  702. }
  703. }
  704. else
  705. {
  706. EntitySuppGrade.DelvryRangeMin = 0;
  707. EntitySuppGrade.DelvryRangeMax = 0;
  708. }
  709. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SuppGradeService", "insertSuppGrade", new object[] { EntitySuppGrade });//添加操作
  710. if (crt.Resultcode != 0)
  711. {
  712. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  713. return;
  714. }
  715. MessageUtil.ShowTips("添加成功!");
  716. getSuppGrade(ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());//刷新供应商
  717. ConfigureClassCommon.doActiveSelRow(ultraGrid2, "SUPPCODE", EntitySuppGrade.SuppCode);//激活当前行
  718. }
  719. else
  720. {
  721. MessageUtil.ShowTips("请选择供应商");
  722. }
  723. }
  724. else if (ultraTabControl1.SelectedTab.Key == "1")//增加属性
  725. {
  726. if (ultraGrid1.ActiveRow != null)
  727. {
  728. if (txt_ITEM_ATTR.Text.Trim() == "")
  729. {
  730. MessageUtil.ShowTips("请选择属性");
  731. return;
  732. }
  733. if (txt_IS_DEFAULT_ATTR.Value == null)
  734. {
  735. MessageUtil.ShowTips("请选择“是否常用”");
  736. txt_IS_DEFAULT_ATTR.Focus();
  737. return;
  738. }
  739. if (txt_IsLevel.Value == null)
  740. {
  741. MessageUtil.ShowTips("请选择“是否判定等级”");
  742. txt_IsLevel.Focus();
  743. return;
  744. }
  745. if (txt_IS_DEFAULT_ATTR.Text.ToString() == "常用")
  746. {
  747. for (int i = 0; i < ultraGrid3.Rows.Count; i++)
  748. {
  749. if (ultraGrid3.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid3.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
  750. {
  751. MessageUtil.ShowTips("只能有一个属性作为常用,请将此属性选为不常用");
  752. return;
  753. }
  754. }
  755. }
  756. PurMatAttrsEntity mat_entity = new PurMatAttrsEntity();
  757. //判断数据库中已经存在所选物料相同的属性名称
  758. mat_entity.ItemAttr = txt_ITEM_ATTR.Text.Trim();//属性名称
  759. mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  760. mat_entity.Validflag = "1";
  761. //if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
  762. //{
  763. // MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的属性名称");
  764. // return;
  765. //}
  766. mat_entity.ItemAttr = null;
  767. mat_entity.ItemAttrCode = txt_ITEM_ATTR_CODE.Text;//属性编码
  768. if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
  769. {
  770. MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的属性编码");
  771. mat_entity.ItemAttr = null;//型号规格
  772. return;
  773. }
  774. mat_entity.ItemAttr = txt_ITEM_ATTR.Text.Trim();//属性名称
  775. mat_entity.ItemAttrId = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getMaxSeq", new object[] { "PUR_MAT_ATTRS", "ITEM_ATTR_ID" });//属性ID
  776. //if (ultChkSuppUon.Checked)
  777. //{
  778. // 判断数据库中已经存在所选物料相同的采购单位
  779. // mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  780. // mat_entity.ItemUom = Ultcmb_ITEM_UOM.Text.Trim();//采购单位(个、袋、桶)
  781. // if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
  782. // {
  783. // MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的单位名称");
  784. // mat_entity.ItemUom = null;//采购单位(个、袋、桶)
  785. // return;
  786. // }
  787. // mat_entity.ItemUseUom = "1";// 是否使用采购单位,0:否,1:是
  788. // mat_entity.ItemUom = Ultcmb_ITEM_UOM.Text.Trim();//采购单位(个、袋、桶)
  789. // double num = 0;
  790. // double.TryParse(txt_ITEM_UOM_CONEFFICIENT.Text, out num);
  791. // mat_entity.ItemUomConefficient = num;//转换系数
  792. //}
  793. //else
  794. //{
  795. // mat_entity.ItemUseUom = "0";// 是否使用采购单位,0:否,1:是
  796. // mat_entity.ItemUom = ultraGrid1.ActiveRow.Cells["WEIGHTUNIT"].Value.ToString();//库存单位赋给采购单位
  797. // mat_entity.ItemUomConefficient = 1;
  798. //}
  799. //mat_entity.ItemAttrId = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber", new object[] { "PUR_MAT_ATTRS", "ITEM_ATTR_ID", ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString()+"@", "3" });//添加操作
  800. //mat_entity.ItemAttr = txt_ITEM_ATTR.Text.Trim();//型号规格
  801. mat_entity.ItemAttr4 = txt_item_Attr4.Text;//物料属性4
  802. mat_entity.ItemAttr3 = txt_item_Attr3.Text;//物料属性3
  803. mat_entity.ItemAttr2 = txt_item_Attr2.Text;//物料属性2
  804. mat_entity.ItemAttr1 = txt_item_Attr1.Text;//物料属性1
  805. //mat_entity.OrderNum = txt_ORDER_NUM.Value == null ? double.Parse(txt_ORDER_NUM.NullText) : double.Parse(txt_ORDER_NUM.Value.ToString());//排序
  806. mat_entity.IsDefault = txt_IS_DEFAULT_ATTR.Value.ToString();//是否常用
  807. mat_entity.IsLevel = txt_IsLevel.Value.ToString();//是否常用
  808. mat_entity.Remark = txt_REMARK_ATTR.Text;//备注
  809. mat_entity.ItemAttrClass = txt_MatAttrClass.Text;//属性分类编码
  810. mat_entity.ItemAttrClassName = txt_MatAttrClassName.Text;//属性分类名称
  811. mat_entity.CreateTime = System.DateTime.Now;//创建时间
  812. mat_entity.CreateName = UserInfo.GetUserName();
  813. mat_entity.CreateUserid = UserInfo.GetUserID();
  814. mat_entity.UpdateTime = null;
  815. mat_entity.UpdateName = null;
  816. mat_entity.UpdateUserid = null;
  817. mat_entity.Validflag = "1";
  818. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatAttrsService", "doInsert", new object[] { mat_entity });//添加操作
  819. if (crt.Resultcode != 0)
  820. {
  821. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  822. return;
  823. }
  824. MessageUtil.ShowTips("添加成功!");
  825. getItemAttr();//查询规格
  826. ConfigureClassCommon.doActiveSelRow(ultraGrid3, "ITEMATTRID", mat_entity.ItemAttrId);//激活当前行
  827. }
  828. else
  829. {
  830. MessageUtil.ShowTips("请选择物料");
  831. }
  832. }
  833. else if (ultraTabControl1.SelectedTab.Key == "2")//标准编号
  834. {
  835. PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
  836. if (txt_IS_DEFAULT_STANDRANDS.Text.ToString() == "常用")
  837. {
  838. for (int i = 0; i < ultraGrid4.Rows.Count; i++)
  839. {
  840. if (ultraGrid4.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid4.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
  841. {
  842. MessageUtil.ShowTips("只能有一个标准编号作为常用,请将此标准编号选为不常用");
  843. return;
  844. }
  845. }
  846. }
  847. PurMatStandards_Entity.StandardsCode = txt_STANDARDS_CODE.Text;
  848. PurMatStandards_Entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  849. PurMatStandards_Entity.Validflag = "1";
  850. if (isExsitRow("com.hnshituo.pur.configure.service.MatStandardsService", PurMatStandards_Entity) > 0)
  851. {
  852. MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的标准编号");
  853. return;
  854. }
  855. PurMatStandards_Entity.ItemStandardsId = Guid.NewGuid().ToString();//this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getMaxSeq", new object[] { "PUR_MAT_STANDARDS", "ITEM_ATTR_ID" });//标准编号ID;
  856. PurMatStandards_Entity.StandardsId = txt_STANDARDS_ID.Text;//标准编号ID
  857. PurMatStandards_Entity.IsDefault = txt_IS_DEFAULT_STANDRANDS.Value.ToString();
  858. PurMatStandards_Entity.Remark = txt_REMARK_STANDARD.Text;//备注
  859. //PurMatStandards_Entity.OrderNum = txtORDER_NUM.Text.Trim() == "" ? 0 : double.Parse(txtORDER_NUM.Text);//排序
  860. //PurMatStandards_Entity.PurStandardsCode = txtPUR_STANDARDS_CODE.Text;//采购标准编号
  861. PurMatStandards_Entity.CreateName = UserInfo.GetUserName();
  862. PurMatStandards_Entity.CreateUserid = UserInfo.GetUserID();
  863. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatStandardsService", "doInsert", new object[] { PurMatStandards_Entity });
  864. if (crt.Resultcode != 0)
  865. {
  866. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  867. return;
  868. }
  869. MessageUtil.ShowTips("添加成功!");
  870. getMatStandard();
  871. ConfigureClassCommon.doActiveSelRow(ultraGrid4, "StandardsId", PurMatStandards_Entity.StandardsId);//激活当前行
  872. }
  873. else if (ultraTabControl1.SelectedTab.Key == "3")//增加单位转换
  874. {
  875. if (txt_IS_DEFAULT_UOM.Text.ToString() == "常用")
  876. {
  877. for (int i = 0; i < ultraGrid5.Rows.Count; i++)
  878. {
  879. if (ultraGrid5.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid5.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
  880. {
  881. MessageUtil.ShowTips("只能有一个单位作为常用,请将此单位选为不常用");
  882. return;
  883. }
  884. }
  885. }
  886. PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
  887. MatUomsEntity.Validflag = "1";
  888. MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  889. MatUomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
  890. if (isExsitRow("com.hnshituo.pur.configure.service.MatUomsService", MatUomsEntity) > 0)
  891. {
  892. MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的采购单位名称");
  893. return;
  894. }
  895. if (txt_UOM_NAME.Text.Trim()=="")
  896. {
  897. MessageUtil.ShowTips("单位编码不能为空,请联系管理员 ");
  898. return;
  899. }
  900. if (txt_WEIGHT_UNIT.Text.Trim() == "")
  901. {
  902. MessageUtil.ShowTips("库存单位不能为空 ");
  903. return;
  904. }
  905. MatUomsEntity.ItemUomId = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getMaxSeq", new object[] { "PUR_MAT_UOMS", "ITEM_UOM_ID" });//标准编号ID;
  906. MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  907. MatUomsEntity.ItemUomConefficient = txt_ITEM_UOM_CONEFFICIENT.Text.Trim() == "" ? 0 : double.Parse(txt_ITEM_UOM_CONEFFICIENT.Text);//转换系数
  908. MatUomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE.Text;//库存单位编码
  909. MatUomsEntity.WeightUnit = txt_WEIGHT_UNIT.Text;//库存单位名称
  910. MatUomsEntity.UomCode = txt_UOM_CODE.Text;//采购单位名称
  911. MatUomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
  912. MatUomsEntity.Remark = txt_REMARK_UOM.Text;//备注
  913. MatUomsEntity.IsDefault = txt_IS_DEFAULT_UOM.Value.ToString();//是否常用
  914. MatUomsEntity.Validflag = "1";
  915. MatUomsEntity.CreateName = UserInfo.GetUserName();
  916. MatUomsEntity.CreateUserid = UserInfo.GetUserID();
  917. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatUomsService", "doInsert", new object[] { MatUomsEntity });
  918. if (crt.Resultcode != 0)
  919. {
  920. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  921. return;
  922. }
  923. MessageUtil.ShowTips("添加成功!");
  924. getMatUOM();
  925. ConfigureClassCommon.doActiveSelRow(ultraGrid5, "ITEMUOMID", MatUomsEntity.ItemUomId);//激活当前行
  926. }
  927. }
  928. /// <summary>
  929. /// 判断数据库中是否存在相同的列
  930. /// </summary>
  931. /// <param name="strJavaPackName"></param>
  932. /// <param name="o"></param>
  933. /// <returns>true存在</returns>
  934. public int isExsitRow(string strJavaPackName, object o)
  935. {
  936. DataTable dt = this.execute<DataTable>(strJavaPackName, "find", new object[] { o, 0, 0 });
  937. if (dt != null && dt.Rows.Count > 0)//存在相同的行
  938. {
  939. return dt.Rows.Count;
  940. }
  941. return 0;
  942. }
  943. /// <summary>
  944. /// 判断数据库中是否存在相同的列
  945. /// </summary>
  946. /// <param name="strJavaPackName"></param>
  947. /// <param name="o"></param>
  948. /// <returns>true存在</returns>
  949. public int isExsitRow(string strJavaPackName,string methodName, object o)
  950. {
  951. DataTable dt = this.execute<DataTable>(strJavaPackName, methodName, new object[] { o });
  952. if (dt != null && dt.Rows.Count > 0)//存在相同的行
  953. {
  954. return dt.Rows.Count;
  955. }
  956. return 0;
  957. }
  958. /// <summary>
  959. /// 更新物料
  960. /// </summary>
  961. public void UpdPUR_MAT()
  962. {
  963. if (ultraTabControl1.SelectedTab.Key == "01")
  964. {
  965. UltraGridRow ugr = ultraGrid1.ActiveRow;
  966. if (ugr != null)
  967. {
  968. //合法验证
  969. if (ugr.Cells["VALIDFLAG"].Value.ToString() == "作废")
  970. {
  971. MessageUtil.ShowTips("此物料已作废,不能修改");
  972. return;
  973. }
  974. if (txt_ITEM_CODE.Text.Trim() != ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString().Trim())//修改了物料编码
  975. {
  976. MessageUtil.ShowTips("物料编码不能修改");
  977. return;
  978. }
  979. if (Ultcmb_BATCH_FLAG.Text != "")
  980. {
  981. if (Ultcmb_BATCH_FLAG.Value.ToString() != ultraGrid1.ActiveRow.Cells["BATCHFLAG"].Value.ToString().Trim())//修改了是否批次控制
  982. {
  983. MessageUtil.ShowTips("“是否控制批次”不能修改");
  984. return;
  985. }
  986. }
  987. //修改库存单位
  988. if (Ultcmb_WEIGHT_UNIT.Text.ToString() != ultraGrid1.ActiveRow.Cells["WEIGHTUNIT"].Value.ToString().Trim())
  989. {
  990. RequirePlanD rq=new RequirePlanD();
  991. rq.ItemCode = ultraGrid1.ActiveRow.Cells["ItemCode"].Value.ToString();
  992. rq.Validflag = "1";
  993. int num= this.GetJsonService().execute<int>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "count", new object[] { rq, 0, 0 });
  994. if (num > 0)
  995. {
  996. MessageUtil.ShowTips("此物料已有需求,不能更改库存单位");
  997. return;
  998. }
  999. PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
  1000. MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ItemCode"].Value.ToString();
  1001. int num1 = this.execute<int>("com.hnshituo.pur.configure.service.MatUomsService", "count", new object[] { MatUomsEntity });
  1002. if (num1 > 0)
  1003. {
  1004. MessageUtil.ShowTips("如要修改库存单位,请先删除此物料的采购单位");
  1005. return;
  1006. }
  1007. }
  1008. UltraTreeNode ultNode = ulTreeMat.ActiveNode;
  1009. MatEntity mat_entity = new MatEntity();
  1010. if (txt_ITEM_NAME.Text.Trim() == "")
  1011. {
  1012. MessageUtil.ShowTips("请输入物料名称");
  1013. return;
  1014. }
  1015. if (cb_BASE_UNIT_FLAG.Checked)
  1016. {
  1017. if (txt_BASE_UNIT_VALUE.Text == "" || !StringUtil.IsNumber(txt_BASE_UNIT_VALUE.Text))
  1018. {
  1019. MessageUtil.ShowTips("基吨值不能为空,且必须为数字");
  1020. return;
  1021. }
  1022. if (txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') == -1 && txt_BASE_UNIT_VALUE.Text.Trim().Length > 6)
  1023. {
  1024. MessageUtil.ShowTips("基吨值整数长度不超过6位");
  1025. return;
  1026. }
  1027. if (txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') != -1 && txt_BASE_UNIT_VALUE.Text.Trim().Length > 6)
  1028. {
  1029. if (txt_BASE_UNIT_VALUE.Text.Trim().Substring(0, txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.')).Length > 6)
  1030. {
  1031. MessageUtil.ShowTips("基吨值整数长度不超过6位");
  1032. return;
  1033. }
  1034. if (txt_BASE_UNIT_VALUE.Text.Trim().Substring(txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') + 1).Length > 6)
  1035. {
  1036. MessageUtil.ShowTips("基吨值小数长度不超过6位");
  1037. return;
  1038. }
  1039. }
  1040. }
  1041. mat_entity.ItemName = txt_ITEM_NAME.Text.Replace(" ", "");
  1042. if (txt_ITEM_NAME.Text != ultraGrid1.ActiveRow.Cells["ITEMNAME"].Value.ToString())//修改了物料名称
  1043. {
  1044. if (isExsitRow("com.hnshituo.pur.configure.service.MatService", "isExsitItemName", mat_entity) > 0)
  1045. {
  1046. MessageUtil.ShowTips("修改失败 " + "数据库中已存在相同的物料名称");
  1047. return;
  1048. }
  1049. }
  1050. //修改分类
  1051. mat_entity.ArcCode = txt_ItemArcCode.Text;
  1052. mat_entity.ArcItem=txt_ItemArcCodeName.Text;
  1053. if (cb_BASE_UNIT_FLAG.Checked)//基顿标识
  1054. {
  1055. mat_entity.BaseUnitFlag = "1";
  1056. mat_entity.BaseUnitValue = double.Parse(txt_BASE_UNIT_VALUE.Text);
  1057. }
  1058. else
  1059. {
  1060. mat_entity.BaseUnitFlag = "0";
  1061. }
  1062. mat_entity.IsBudgetCtrl = txt_IS_BUDGET_CTRL.Value == null ? null : txt_IS_BUDGET_CTRL.Value.ToString();//是否定额控制
  1063. mat_entity.PcFlag = txt_PC_FLAG.Value == null ? null : txt_PC_FLAG.Value.ToString();//是检化验
  1064. if (txt_DELVRY_RANGE_TPE.SelectedIndex == -1)
  1065. {
  1066. MessageUtil.ShowTips("请选择交货量差方式");
  1067. txt_DELVRY_RANGE_TPE.Focus();
  1068. return;
  1069. }
  1070. mat_entity.DelvryRangeTpe = txt_DELVRY_RANGE_TPE.Value.ToString().Trim();//交货量差方式
  1071. if ("1" == txt_DELVRY_RANGE_TPE.Value.ToString().Trim() || "2" == txt_DELVRY_RANGE_TPE.Value.ToString().Trim())
  1072. {
  1073. if (txt_DELVRY_RANGE_MIN.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MIN.Value.ToString().Trim()))
  1074. {
  1075. mat_entity.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN.Value.ToString());//交货量差下限
  1076. }
  1077. else
  1078. {
  1079. MessageUtil.ShowTips("请填写交货量差下限值");
  1080. txt_DELVRY_RANGE_MIN.Focus();
  1081. return;
  1082. }
  1083. if (txt_DELVRY_RANGE_MAX.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MAX.Value.ToString().Trim()))
  1084. {
  1085. mat_entity.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX.Value.ToString());//交货量差上限
  1086. }
  1087. else
  1088. {
  1089. MessageUtil.ShowTips("请填写交货量差上限值");
  1090. txt_DELVRY_RANGE_MAX.Focus();
  1091. return;
  1092. }
  1093. }
  1094. else
  1095. {
  1096. mat_entity.DelvryRangeMin = 0;
  1097. mat_entity.DelvryRangeMax = 0;
  1098. }
  1099. mat_entity.WeightUnit = Ultcmb_WEIGHT_UNIT.Text;//库存单位
  1100. mat_entity.WeightUnitCode = Ultcmb_WEIGHT_UNIT_CODE.Text;//库存单位编码
  1101. mat_entity.ReceiveType = Ultcmb_RECEIVE_TYPE.Value == null ? null : Ultcmb_RECEIVE_TYPE.Value.ToString();//入库类型;1:直接入库2:收货质检入库3:JIT入库4:VMI入库
  1102. mat_entity.BatchFlag = Ultcmb_BATCH_FLAG.Value == null ? null : Ultcmb_BATCH_FLAG.Value.ToString();//是否批次控制
  1103. mat_entity.PurStandards = Ultcmb_PUR_STANDARDS.Value == null ? null : Ultcmb_PUR_STANDARDS.Value.ToString();//采购标准
  1104. mat_entity.InvWasteFacUom = Ultcmb_INV_WASTE_FAC_UOM.Value == null ? 0 : double.Parse(Ultcmb_INV_WASTE_FAC_UOM.Value.ToString());//库存损耗率单位
  1105. //mat_entity.ShareCkSpecFlag = Ultcmb_SHARE_CK_SPEC_FLAG.Value == null ? null : Ultcmb_SHARE_CK_SPEC_FLAG.Value.ToString();//是否与子规格共用库存
  1106. mat_entity.MeteringFlag = Ultcmb_METERING_FLAG.Value == null ? null : Ultcmb_METERING_FLAG.Value.ToString();//是否计量
  1107. mat_entity.PriceType = Ultcmb_PRICE_TYPE.Text;//计价类型
  1108. mat_entity.CurrencyCode = Ultcmb_CURRENCY_CODE.Text;//币种代码
  1109. mat_entity.LifeCycleUom = Ultcmb_LIFE_CYCLE_UOM.Text;//有效期单位
  1110. mat_entity.PurStandardsCode = txt_PUR_STANDARDS_CODE.Text;//采购标准编号
  1111. mat_entity.MinStock = txt_MIN_STOCK.Text.Trim() == "" ? 0 : double.Parse(txt_MIN_STOCK.Text);//最小库存(预警)
  1112. mat_entity.MaxStock = txt_MAX_STOCK.Text.Trim() == "" ? 0 : double.Parse(txt_MAX_STOCK.Text);//最大库存(预警)
  1113. mat_entity.LeadTime = txt_LEAD_TIME.Text.Trim() == "" ? 0 : double.Parse(txt_LEAD_TIME.Text);//采购提前时间(天)
  1114. mat_entity.InvWasteFac = txt_INV_WASTE_FAC.Text.Trim() == "" ? 0 : double.Parse(txt_INV_WASTE_FAC.Text);//库存损耗率
  1115. mat_entity.LifeCycle = txt_LIFE_CYCLE.Text.Trim() == "" ? 0 : double.Parse(txt_LIFE_CYCLE.Text);//有效期
  1116. mat_entity.MinQty = txt_MIN_QTY.Text.Trim() == "" ? 0 : double.Parse(txt_MIN_QTY.Text);//最小采购数量
  1117. mat_entity.QtyMultiple = txt_QTY_MULTIPLE.Text.Trim() == "" ? 0 : double.Parse(txt_QTY_MULTIPLE.Text);//批量数
  1118. if (planPrice != txt_BUG_PRICE.Text)
  1119. {
  1120. if (UserInfo.GetDepartment() != "综合管理科" && UserInfo.GetUserName() != "admin")
  1121. {
  1122. MessageUtil.ShowTips("不是综合管理科人员,不允许修改计划价!");
  1123. //txt_BUG_PRICE.Enabled = false;
  1124. return;
  1125. }
  1126. else
  1127. {
  1128. mat_entity.BugPrice = txt_BUG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_BUG_PRICE.Text);//计划价
  1129. }
  1130. }
  1131. else
  1132. {
  1133. mat_entity.BugPrice = txt_BUG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_BUG_PRICE.Text);//计划价
  1134. }
  1135. mat_entity.LastPrice = txt_LAST_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_LAST_PRICE.Text);//最近采购价
  1136. mat_entity.MonthEndAvgPrice = txt_MONTH_END_AVG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_MONTH_END_AVG_PRICE.Text);//月末移动平均价
  1137. mat_entity.ItemName = txt_ITEM_NAME.Text.Trim().Replace(" ", " ").Replace("(", "(").Replace(")", ")");//物料名称
  1138. mat_entity.ItemDescE = txt_ITEM_DESC_E.Text;//物料英文名称
  1139. mat_entity.ItemDesc = txt_ITEM_DESC.Text;//物料描述
  1140. mat_entity.ItemModel = txt_ITEM_MODEL.Text;//物料材质
  1141. mat_entity.ItemSpec = txt_ITEM_SPEC.Text;//物料型号规格
  1142. mat_entity.BuyerRoleId = QstrBUYER_ROLE_ID;
  1143. mat_entity.PlannerRoleId = QstrPLANNER_ROLE_ID;
  1144. mat_entity.BuyerRoleName = txt_BUYER_ROLE_NAME.Text;
  1145. mat_entity.PlannerRoleName = txt_PLANNER_ROLE_NAME.Text;
  1146. mat_entity.InvPhysicUserid = QstrINV_PHYSIC_USERID;//库管员
  1147. mat_entity.InvPhysicUsername = txt_INV_PHYSIC_USERID.Text;//库管员名称
  1148. //mat_entity.BuyerUnitCode = strBUYER_DEPT_CODE;//采购科室代码
  1149. //mat_entity.BuyerUnitDesc = txt_BUYER_UNITCODE.Text;//采购科室描述
  1150. //mat_entity.MentUnitCode = strMENT_UNIT_CODE;//采购管理科室代码
  1151. ///mat_entity.MentUnitDesc = txt_MENT_UNIT_CODE.Text;//采购管理科室代码
  1152. // 是否使用采购单位
  1153. //if (ultChkSuppUon.Checked)
  1154. //{
  1155. // mat_entity.ItemUseUom = "1";// 是否使用采购单位,0:否,1:是
  1156. // mat_entity.ItemUom = Ultcmb_ITEM_UOM.Text;//采购单位(个、袋、桶)
  1157. // double num = 0;
  1158. // double.TryParse(txt_ITEM_UOM_CONEFFICIENT.Text, out num);
  1159. // mat_entity.ItemUomConefficient = num;//转换系数
  1160. //}
  1161. //else
  1162. //{
  1163. // mat_entity.ItemUseUom = "0";// 是否使用采购单位,0:否,1:是
  1164. // mat_entity.ItemUom = Ultcmb_WEIGHT_UNIT.Text;//库存单位赋给采购单位
  1165. //}
  1166. mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  1167. mat_entity.UpdateTime = System.DateTime.Now;
  1168. mat_entity.UpdateName = UserInfo.GetUserName();
  1169. mat_entity.UpdateUserid = UserInfo.GetUserID();
  1170. mat_entity.MatType = Ultcmb_MAT_TYPE.Value.ToString2();
  1171. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料【" + ultraGrid1.ActiveRow.Cells["ITEMNAME"].Value.ToString().Trim() + "】?") == DialogResult.No)
  1172. {
  1173. return;
  1174. }
  1175. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "doUpdate", new object[] { mat_entity });//更新操作
  1176. if (crt.Resultcode != 0)
  1177. {
  1178. MessageUtil.ShowTips("更新失败 " + crt.Resultmsg);
  1179. return;
  1180. }
  1181. if (mat_entity.MeteringFlag.Equals("1"))
  1182. {
  1183. // 更新数据到计量系统
  1184. string json = JSONFormat.Format(mat_entity);
  1185. CoreClientParam ccp = new CoreClientParam();
  1186. ccp.ServerName = "com.hnshituo.pur.configure.service.impl.MeterBaseMatterInforService";
  1187. ccp.MethodName = "update";
  1188. ccp.ServerParams = new object[] { json };
  1189. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1190. }
  1191. MessageUtil.ShowTips("更新成功");
  1192. if (ulTreeMat.ActiveNode != null)
  1193. {
  1194. //MatEntity mM = new MatEntity();
  1195. //mM.ArcCode = ulTreeMat.ActiveNode.Key;
  1196. getMat(Q_mat);//刷新物料
  1197. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
  1198. }
  1199. }
  1200. else
  1201. {
  1202. MessageUtil.ShowTips("请选择物料");
  1203. }
  1204. }
  1205. else if (ultraTabControl1.SelectedTab.Key == "0")
  1206. {
  1207. if (ultraGrid2.ActiveRow == null)
  1208. {
  1209. MessageUtil.ShowTips("请选择供应商");
  1210. return;
  1211. }
  1212. if (ultraGrid2.ActiveRow.Cells["SUPPCODE"].Value.ToString() != txt_suppCode.Text)
  1213. {
  1214. MessageUtil.ShowTips("修改失败 供应商代码和名称不修改");
  1215. return;
  1216. }
  1217. Entity_SuppGrade EntitySuppGrade = new Entity_SuppGrade();
  1218. EntitySuppGrade.Id = ultraGrid2.ActiveRow.Cells["id"].Value.ToString();
  1219. //EntitySuppGrade.SuppCode = txt_suppCode.Text;
  1220. if (txt_IS_DEFAULT.Value != null)
  1221. {
  1222. EntitySuppGrade.IsDefault = txt_IS_DEFAULT.Value.ToString();
  1223. }
  1224. if (txt_delivery_type_2.SelectedIndex == -1)
  1225. {
  1226. MessageUtil.ShowTips("请选择交货差方式");
  1227. txt_delivery_type_2.Focus();
  1228. return;
  1229. }
  1230. EntitySuppGrade.DelvryRangeTpe = txt_delivery_type_2.Value.ToString().Trim();//交货量差方式
  1231. if ("1" == txt_delivery_type_2.Value.ToString().Trim() || "2" == txt_delivery_type_2.Value.ToString().Trim())
  1232. {
  1233. if (txt_DELVRY_RANGE_MIN2.Value != null &&! String.IsNullOrEmpty(txt_DELVRY_RANGE_MIN2.Value.ToString().Trim()))
  1234. {
  1235. EntitySuppGrade.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN2.Value.ToString());//交货量差下限
  1236. }
  1237. else
  1238. {
  1239. MessageUtil.ShowTips("请填写交货量差下限值");
  1240. txt_DELVRY_RANGE_MIN2.Focus();
  1241. return;
  1242. }
  1243. if (txt_DELVRY_RANGE_MAX2.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MAX2.Value.ToString().Trim()))
  1244. {
  1245. EntitySuppGrade.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX2.Value.ToString());//交货量差上限
  1246. }
  1247. else
  1248. {
  1249. MessageUtil.ShowTips("请填写交货量差上限值");
  1250. txt_DELVRY_RANGE_MAX2.Focus();
  1251. return;
  1252. }
  1253. }
  1254. else
  1255. {
  1256. EntitySuppGrade.DelvryRangeMin = 0;
  1257. EntitySuppGrade.DelvryRangeMax = 0;
  1258. }
  1259. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改供应商【" + ultraGrid2.ActiveRow.Cells["suppName"].Value.ToString() + "】?") == DialogResult.No)
  1260. {
  1261. return;
  1262. }
  1263. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SuppGradeService", "doUpdate", new object[] { EntitySuppGrade });//更新操作
  1264. if (crt.Resultcode != 0)
  1265. {
  1266. MessageUtil.ShowTips("更新失败 " + crt.Resultmsg);
  1267. return;
  1268. }
  1269. MessageUtil.ShowTips("修改成功!");
  1270. getSuppGrade(ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());//刷新供应商
  1271. ConfigureClassCommon.doActiveSelRow(ultraGrid2, "Id", EntitySuppGrade.Id);//激活当前行
  1272. }
  1273. else if (ultraTabControl1.SelectedTab.Key == "1")//修改属性
  1274. {
  1275. if (ultraGrid3.ActiveRow != null)
  1276. {
  1277. if (txt_ITEM_ATTR.Text.Trim() == "")
  1278. {
  1279. MessageUtil.ShowTips("请输入属性");
  1280. return;
  1281. }
  1282. if (txt_IS_DEFAULT_ATTR.Text.ToString() == "常用")
  1283. {
  1284. for (int i = 0; i < ultraGrid3.Rows.Count; i++)
  1285. {
  1286. if (ultraGrid3.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid3.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
  1287. {
  1288. if (!ultraGrid3.Rows[i].IsActiveRow)
  1289. {
  1290. MessageUtil.ShowTips("只能有一个属性作为常用,请将此属性选为不常用");
  1291. return;
  1292. }
  1293. }
  1294. }
  1295. }
  1296. PurMatAttrsEntity mat_entity = new PurMatAttrsEntity();
  1297. //判断数据库中已经存在所选物料相同的属性名称
  1298. mat_entity.ItemAttr = txt_ITEM_ATTR.Text.Trim();//属性名称
  1299. mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  1300. mat_entity.Validflag = "1";
  1301. if (txt_ITEM_ATTR.Text.Trim() != ultraGrid3.ActiveRow.Cells["ItemAttr"].Value.ToString())
  1302. {
  1303. if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
  1304. {
  1305. MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的属性名称");
  1306. return;
  1307. }
  1308. }
  1309. mat_entity.ItemAttrId = ultraGrid3.ActiveRow.Cells["ITEMATTRID"].Value.ToString();//属性Id
  1310. mat_entity.ItemAttrCode = txt_ITEM_ATTR_CODE.Text;//属性编码
  1311. mat_entity.ItemAttr4 = txt_item_Attr4.Text;//物料属性4
  1312. mat_entity.ItemAttr3 = txt_item_Attr3.Text;//物料属性3
  1313. mat_entity.ItemAttr2 = txt_item_Attr2.Text;//物料属性2
  1314. mat_entity.ItemAttr1 = txt_item_Attr1.Text;//物料属性1
  1315. mat_entity.IsDefault = txt_IS_DEFAULT_ATTR.Value.ToString();//是否常用
  1316. mat_entity.IsLevel = txt_IsLevel.Value.ToString();//是否常用
  1317. mat_entity.Remark = txt_REMARK_ATTR.Text;//备注
  1318. mat_entity.UpdateTime = System.DateTime.Now;//更新时间
  1319. mat_entity.UpdateName = UserInfo.GetUserName();
  1320. mat_entity.UpdateUserid = UserInfo.GetUserID();
  1321. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料属性【" + ultraGrid3.ActiveRow.Cells["ItemAttr"].Value.ToString() + "】?") == DialogResult.No)
  1322. {
  1323. return;
  1324. }
  1325. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatAttrsService", "doUpdate", new object[] { mat_entity });//添加操作
  1326. if (crt.Resultcode != 0)
  1327. {
  1328. MessageUtil.ShowTips("更新失败 " + crt.Resultmsg);
  1329. return;
  1330. }
  1331. MessageUtil.ShowTips("更新成功!");
  1332. getItemAttr();//查询属性
  1333. ConfigureClassCommon.doActiveSelRow(ultraGrid3, "ITEMATTRID", mat_entity.ItemAttrId);//激活当前行
  1334. }
  1335. else
  1336. {
  1337. MessageUtil.ShowTips("请选择物料");
  1338. }
  1339. }
  1340. else if (ultraTabControl1.SelectedTab.Key == "2")//修改标准编号
  1341. {
  1342. if (ultraGrid4.ActiveRow != null)
  1343. {
  1344. if (txt_IS_DEFAULT_STANDRANDS.Text.ToString() == "常用")
  1345. {
  1346. for (int i = 0; i < ultraGrid4.Rows.Count; i++)
  1347. {
  1348. if (ultraGrid4.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid4.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
  1349. {
  1350. if (!ultraGrid4.Rows[i].IsActiveRow)
  1351. {
  1352. MessageUtil.ShowTips("只能有一个标准编号作为常用,请将此标准编号选为不常用");
  1353. return;
  1354. }
  1355. }
  1356. }
  1357. }
  1358. PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
  1359. if (ultraGrid4.ActiveRow.Cells["StandardsCode"].Value.ToString() != txt_STANDARDS_CODE.Text)
  1360. {
  1361. PurMatStandards_Entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  1362. PurMatStandards_Entity.StandardsCode = txt_STANDARDS_CODE.Text;//采购标准编号
  1363. PurMatStandards_Entity.Validflag = "1";
  1364. if (isExsitRow("com.hnshituo.pur.configure.service.MatStandardsService", PurMatStandards_Entity) > 0)
  1365. {
  1366. MessageUtil.ShowTips("更新失败 数据库中已经存在所选物料相同的标准编号");
  1367. return;
  1368. }
  1369. }
  1370. //PurMatStandards_Entity.Id = ultraGrid4.ActiveRow.Cells["ID"].Value.ToString();
  1371. //PurMatStandards_Entity.StandardsId = txt_STANDARDS_ID.Text;
  1372. PurMatStandards_Entity.Validflag = "1";
  1373. PurMatStandards_Entity.IsDefault = txt_IS_DEFAULT_STANDRANDS.Value.ToString();//是否为常用
  1374. PurMatStandards_Entity.Remark = txt_REMARK_STANDARD.Text;//备注
  1375. //PurMatStandards_Entity.OrderNum = txtORDER_NUM.Text.Trim() == "" ? 0 : double.Parse(txtORDER_NUM.Text);//排序
  1376. PurMatStandards_Entity.ItemStandardsId = ultraGrid4.ActiveRow.Cells["ITEMSTANDARDSID"].Value.ToString();//采购标准编号
  1377. PurMatStandards_Entity.UpdateName = UserInfo.GetUserName();
  1378. PurMatStandards_Entity.UpdateUserid = UserInfo.GetUserID();
  1379. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料标准编号【" + ultraGrid4.ActiveRow.Cells["StandardsCode"].Value.ToString() + "】?") == DialogResult.No)
  1380. {
  1381. return;
  1382. }
  1383. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatStandardsService", "doUpdate", new object[] { PurMatStandards_Entity });
  1384. if (crt.Resultcode != 0)
  1385. {
  1386. MessageUtil.ShowTips("更新失败 " + crt.Resultmsg);
  1387. return;
  1388. }
  1389. MessageUtil.ShowTips("更新成功!");
  1390. getMatStandard();
  1391. ConfigureClassCommon.doActiveSelRow(ultraGrid4, "ITEMSTANDARDSID", PurMatStandards_Entity.ItemStandardsId);//激活当前行
  1392. }
  1393. }
  1394. else if (ultraTabControl1.SelectedTab.Key == "3")//修改单位转换
  1395. {
  1396. //MessageUtil.ShowTips("物料单位不能修改,请添加或作废");
  1397. //return;
  1398. if (ultraGrid5.ActiveRow != null)
  1399. {
  1400. PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
  1401. if (txt_IS_DEFAULT_UOM.Text.ToString() == "常用")
  1402. {
  1403. for (int i = 0; i < ultraGrid5.Rows.Count; i++)
  1404. {
  1405. if (ultraGrid5.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid5.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
  1406. {
  1407. if (!ultraGrid5.Rows[i].IsActiveRow)
  1408. {
  1409. MessageUtil.ShowTips("只能有一个单位作为常用,请将此单位选为不常用");
  1410. return;
  1411. }
  1412. }
  1413. }
  1414. }
  1415. MatUomsEntity.ItemUomId = ultraGrid5.ActiveRow.Cells["ITEMUOMID"].Value.ToString();
  1416. //MatUomsEntity.ItemUomConefficient = txt_ITEM_UOM_CONEFFICIENT.Text.Trim() == "" ? 0 : double.Parse(txt_ITEM_UOM_CONEFFICIENT.Text);//转换系数
  1417. MatUomsEntity.IsDefault = txt_IS_DEFAULT_UOM.Value == null ? null : txt_IS_DEFAULT_UOM.Value.ToString();//是否常用
  1418. //MatUomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE.Text;//库存单位编码
  1419. //MatUomsEntity.WeightUnit = txt_WEIGHT_UNIT.Text;//库存单位名称
  1420. //MatUomsEntity.UomCode = txt_UOM_CODE.Text;//采购单位名称
  1421. //MatUomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
  1422. MatUomsEntity.Remark = txt_REMARK_UOM.Text;//备注
  1423. MatUomsEntity.UpdateName = UserInfo.GetUserName();
  1424. MatUomsEntity.UpdateUserid = UserInfo.GetUserID();
  1425. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料采购单位【" + ultraGrid5.ActiveRow.Cells["UomName"].Value.ToString() + "】? 注:物料单位只能修改是否常用和备注") == DialogResult.No)
  1426. {
  1427. return;
  1428. }
  1429. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatUomsService", "doUpdate", new object[] { MatUomsEntity });
  1430. if (crt.Resultcode != 0)
  1431. {
  1432. MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
  1433. return;
  1434. }
  1435. MessageUtil.ShowTips("修改成功!");
  1436. getMatUOM();
  1437. ConfigureClassCommon.doActiveSelRow(ultraGrid5, "ITEMUOMID", MatUomsEntity.ItemUomId);//激活当前行
  1438. }
  1439. }
  1440. }
  1441. /// <summary>
  1442. /// 删除物料
  1443. /// </summary>
  1444. public void DelPUR_MAT()
  1445. {
  1446. if (ultraTabControl1.SelectedTab.Key == "01")
  1447. {
  1448. if (ultraGrid1.ActiveRow != null)
  1449. {
  1450. if (MessageUtil.ShowYesNoAndQuestion("确定作废物料【" + ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() + "】?") == DialogResult.No)
  1451. {
  1452. return;
  1453. }
  1454. //string resStr = "";
  1455. //resStr = this.execute<string>("com.hnshituo.pur.configure.service.MatService", "MatIsUsing", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString(), null });//删除操作
  1456. //if (resStr != "")
  1457. //{
  1458. // MessageUtil.ShowTips("物料在" + resStr + "中使用,不能作废");
  1459. // return;
  1460. //}
  1461. MatEntity mat_entity = new MatEntity();
  1462. mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  1463. mat_entity.Validflag = "0";
  1464. mat_entity.DeleteName = UserInfo.GetUserName();
  1465. mat_entity.DeleteTime = System.DateTime.Now;
  1466. mat_entity.DeleteUserid = UserInfo.GetUserID();
  1467. mat_entity.ArcCode = ulTreeMat.ActiveNode.Key;//物料只保存分类编码,不保存父类编码
  1468. mat_entity.ArcItem = ulTreeMat.ActiveNode.Text;//物料分类编码名称
  1469. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "doUpdate", new object[] { mat_entity });//删除操作
  1470. if (crt.Resultcode != 0)
  1471. {
  1472. MessageUtil.ShowTips("作废失败 " + crt.Resultmsg);
  1473. return;
  1474. }
  1475. string meteringFlag = Ultcmb_METERING_FLAG.Value == null ? null : Ultcmb_METERING_FLAG.Value.ToString();//是否计量
  1476. if (meteringFlag.Equals("1"))
  1477. {
  1478. // 作废 数据到计量系统
  1479. string json = JSONFormat.Format(mat_entity);
  1480. CoreClientParam ccp = new CoreClientParam();
  1481. ccp.ServerName = "com.hnshituo.pur.configure.service.impl.MeterBaseMatterInforService";
  1482. ccp.MethodName = "logicDelete";
  1483. ccp.ServerParams = new object[] { json };
  1484. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1485. }
  1486. MessageUtil.ShowTips("作废成功!");
  1487. if (ulTreeMat.ActiveNode != null)
  1488. {
  1489. //MatEntity mM = new MatEntity();
  1490. //mM.ArcCode = ulTreeMat.ActiveNode.Key;
  1491. getMat(Q_mat);//刷新物料
  1492. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
  1493. }
  1494. }
  1495. else
  1496. {
  1497. MessageUtil.ShowTips("请选择物料");
  1498. }
  1499. }
  1500. else if (ultraTabControl1.SelectedTab.Key == "0")
  1501. {
  1502. if (ultraGrid2.ActiveRow != null)
  1503. {
  1504. string id_SuppGrade = ultraGrid2.ActiveRow.Cells["ID"].Value.ToString().Trim();
  1505. string id_SuppGradename = ultraGrid2.ActiveRow.Cells["SUPPNAME"].Value.ToString().Trim();
  1506. if (String.IsNullOrEmpty(id_SuppGrade))
  1507. {
  1508. MessageUtil.ShowTips("未获取该供应商关联标识,无法删除");
  1509. return;
  1510. }
  1511. if (MessageUtil.ShowYesNoAndQuestion("确定要删除该物料与供应商【" + ultraGrid2.ActiveRow.Cells["SUPPNAME"].Value.ToString() + "】的挂接关系?") == DialogResult.No)
  1512. {
  1513. return;
  1514. }
  1515. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SuppGradeService", "doDelete", new object[] { id_SuppGrade });//删除操作
  1516. if (crt.Resultcode != 0)
  1517. {
  1518. MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
  1519. return;
  1520. }
  1521. MessageUtil.ShowTips("删除成功!");
  1522. getSuppGrade(ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());//刷新供应商
  1523. }
  1524. else
  1525. {
  1526. MessageUtil.ShowTips("请选择供应商");
  1527. }
  1528. }
  1529. else if (ultraTabControl1.SelectedTab.Key == "1")
  1530. {
  1531. if (ultraGrid3.ActiveRow != null)
  1532. {
  1533. if (MessageUtil.ShowYesNoAndQuestion("确定要删除物料属性【" + ultraGrid3.ActiveRow.Cells["ItemAttr"].Value.ToString() + "】?") == DialogResult.No)
  1534. {
  1535. return;
  1536. }
  1537. //string resStr = "";
  1538. //resStr = this.execute<string>("com.hnshituo.pur.configure.service.MatService", "MatIsUsing", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString(), ultraGrid3.ActiveRow.Cells["ITEMATTRID"].Value.ToString() });//删除操作
  1539. //if (resStr != "")
  1540. //{
  1541. // MessageUtil.ShowTips("此物料的属性在" + resStr + "中使用,不能删除");
  1542. // return;
  1543. //}
  1544. PurMatAttrsEntity mat_entity = new PurMatAttrsEntity();
  1545. mat_entity.ItemAttrId = ultraGrid3.ActiveRow.Cells["ITEMATTRID"].Value.ToString();
  1546. mat_entity.Validflag = "0";
  1547. mat_entity.DeleteName = UserInfo.GetUserName();
  1548. mat_entity.DeleteTime = System.DateTime.Now;
  1549. mat_entity.DeleteUserid = UserInfo.GetUserID();
  1550. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatAttrsService", "doUpdate", new object[] { mat_entity });//删除操作
  1551. if (crt.Resultcode != 0)
  1552. {
  1553. MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
  1554. return;
  1555. }
  1556. MessageUtil.ShowTips("删除成功!");
  1557. getItemAttr();//刷新物料规格
  1558. }
  1559. else
  1560. {
  1561. MessageUtil.ShowTips("请选择物料属性");
  1562. }
  1563. }
  1564. else if (ultraTabControl1.SelectedTab.Key == "2")//删除标准编号
  1565. {
  1566. if (ultraGrid4.ActiveRow != null)
  1567. {
  1568. if (MessageUtil.ShowYesNoAndQuestion("确定要删除物料标准编号【" + ultraGrid4.ActiveRow.Cells["STANDARDSCODE"].Value.ToString() + "】?") == DialogResult.No)
  1569. {
  1570. return;
  1571. }
  1572. PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
  1573. PurMatStandards_Entity.ItemStandardsId = ultraGrid4.ActiveRow.Cells["ItemStandardsId"].Value.ToString();
  1574. PurMatStandards_Entity.Validflag = "0";
  1575. PurMatStandards_Entity.DeleteName = UserInfo.GetUserName();
  1576. PurMatStandards_Entity.DeleteUserid = UserInfo.GetUserID();
  1577. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatStandardsService", "doUpdate", new object[] { PurMatStandards_Entity });
  1578. if (crt.Resultcode != 0)
  1579. {
  1580. MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
  1581. return;
  1582. }
  1583. MessageUtil.ShowTips("删除成功!");
  1584. getMatStandard();
  1585. }
  1586. }
  1587. else if (ultraTabControl1.SelectedTab.Key == "3")//删除单位
  1588. {
  1589. if (ultraGrid5.ActiveRow != null)
  1590. {
  1591. if (MessageUtil.ShowYesNoAndQuestion("确定要删除物料采购单位【" + ultraGrid5.ActiveRow.Cells["UOMNAME"].Value.ToString() + "】?") == DialogResult.No)
  1592. {
  1593. return;
  1594. }
  1595. PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
  1596. MatUomsEntity.ItemUomId = ultraGrid5.ActiveRow.Cells["ITEMUOMID"].Value.ToString();
  1597. MatUomsEntity.Validflag = "0";
  1598. MatUomsEntity.DeleteName = UserInfo.GetUserName();
  1599. MatUomsEntity.DeleteUserid = UserInfo.GetUserID();
  1600. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatUomsService", "doUpdate", new object[] { MatUomsEntity});
  1601. if (crt.Resultcode != 0)
  1602. {
  1603. MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
  1604. return;
  1605. }
  1606. MessageUtil.ShowTips("删除成功!");
  1607. getMatUOM();
  1608. }
  1609. }
  1610. }
  1611. /// <summary>
  1612. /// 启用物料
  1613. /// </summary>
  1614. public void UsePUR_MAT()
  1615. {
  1616. if (ultraTabControl1.SelectedTab.Key == "01")
  1617. {
  1618. if (ultraGrid1.ActiveRow != null)
  1619. {
  1620. if (ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString() != "作废")
  1621. {
  1622. MessageUtil.ShowTips("此物料正常使用,无须再做启用操作!");
  1623. return;
  1624. }
  1625. if (MessageUtil.ShowYesNoAndQuestion("确定要启用物料编码【" + ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() + "】?") == DialogResult.No)
  1626. {
  1627. return;
  1628. }
  1629. //string resStr = "";
  1630. //resStr = this.execute<string>("com.hnshituo.pur.configure.service.MatService", "MatIsUsing", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString(), null });//删除操作
  1631. //if (resStr != "")
  1632. //{
  1633. // MessageUtil.ShowTips("物料在" + resStr + "中使用,不能删除");
  1634. // return;
  1635. //}
  1636. MatEntity mat_entity = new MatEntity();
  1637. mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
  1638. mat_entity.Validflag = "1";
  1639. mat_entity.UpdateName = UserInfo.GetUserName();
  1640. mat_entity.UpdateTime = System.DateTime.Now;
  1641. mat_entity.UpdateUserid = UserInfo.GetUserID();
  1642. mat_entity.ArcCode = ulTreeMat.ActiveNode.Key;//物料只保存分类编码,不保存父类编码
  1643. mat_entity.ArcItem = ulTreeMat.ActiveNode.Text;//物料分类编码名称
  1644. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "doUpdate", new object[] { mat_entity });//删除操作
  1645. if (crt.Resultcode != 0)
  1646. {
  1647. MessageUtil.ShowTips("启用失败 " + crt.Resultmsg);
  1648. return;
  1649. }
  1650. string meteringFlag = Ultcmb_METERING_FLAG.Value == null ? null : Ultcmb_METERING_FLAG.Value.ToString();//是否计量
  1651. if (meteringFlag.Equals("1"))
  1652. {
  1653. // 启用 数据到计量系统
  1654. string json = JSONFormat.Format(mat_entity);
  1655. CoreClientParam ccp = new CoreClientParam();
  1656. ccp.ServerName = "com.hnshituo.pur.configure.service.impl.MeterBaseMatterInforService";
  1657. ccp.MethodName = "logicDelete";
  1658. ccp.ServerParams = new object[] { json };
  1659. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1660. }
  1661. MessageUtil.ShowTips("启用成功!");
  1662. if (ulTreeMat.ActiveNode != null)
  1663. {
  1664. //MatEntity mM = new MatEntity();
  1665. //mM.ArcCode = ulTreeMat.ActiveNode.Key;
  1666. getMat(Q_mat);//刷新物料
  1667. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
  1668. }
  1669. }
  1670. else
  1671. {
  1672. MessageUtil.ShowTips("请选择物料");
  1673. }
  1674. }
  1675. else//单位
  1676. {
  1677. if (ultraGrid5.ActiveRow==null)
  1678. {
  1679. MessageUtil.ShowYesNoAndQuestion("请选择要启用的单位");
  1680. return;
  1681. }
  1682. MatEntity mat = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { ultraGrid1.ActiveRow.Cells["itemcode"].Value.ToString() });
  1683. PurMatUomsEntity matUoms = this.execute<PurMatUomsEntity>("com.hnshituo.pur.configure.service.MatUomsService", "findById", new object[] { ultraGrid5.ActiveRow.Cells["itemuomid"].Value.ToString() });
  1684. if (matUoms.WeightUnit != mat.WeightUnit)
  1685. {
  1686. MessageUtil.ShowTips("启用失败:因为启用的单位和物料的库存单位不一致");
  1687. return;
  1688. }
  1689. if (MessageUtil.ShowYesNoAndQuestion("确定要启用单位【" + ultraGrid5.ActiveRow.Cells["UOMNAME"].Value.ToString() + "】?") == DialogResult.No)
  1690. {
  1691. return;
  1692. }
  1693. PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
  1694. MatUomsEntity.ItemUomId = ultraGrid5.ActiveRow.Cells["ITEMUOMID"].Value.ToString();
  1695. MatUomsEntity.Validflag = "1";//备注
  1696. MatUomsEntity.DeleteName = UserInfo.GetUserName();
  1697. MatUomsEntity.DeleteUserid = UserInfo.GetUserID();
  1698. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatUomsService", "doUpdate", new object[] { MatUomsEntity });
  1699. if (crt.Resultcode != 0)
  1700. {
  1701. MessageUtil.ShowTips("启用失败 " + crt.Resultmsg);
  1702. return;
  1703. }
  1704. MessageUtil.ShowTips("启用成功!");
  1705. getMatUOM();
  1706. ConfigureClassCommon.doActiveSelRow(ultraGrid5, "ITEMUOMID", MatUomsEntity.ItemUomId);//激活当前行
  1707. }
  1708. }
  1709. /// <summary>
  1710. /// 获取物料分类树形结构
  1711. /// </summary>
  1712. public void getultree(DataTable dt)
  1713. {
  1714. ulTreeMat.Nodes.Clear();
  1715. if (dt == null || dt.Rows.Count < 1)
  1716. {
  1717. return;
  1718. }
  1719. dt_Purmatclass = dt;//保存物料分类全局变量
  1720. DataTable dt_A = new DataTable();//物料分类
  1721. //筛选出根节点
  1722. DataRow[] rows = dt.Select("PARENTCODE='' or PARENTCODE is null");
  1723. dt_A = dt.Clone(); //克隆A的结构
  1724. foreach (DataRow row in rows)
  1725. {
  1726. dt_A.ImportRow(row);//复制行数据
  1727. }
  1728. //排序
  1729. dt_A.DefaultView.Sort = "basename";
  1730. dt_A = dt_A.DefaultView.ToTable();
  1731. //添加物料大类
  1732. for (int j = 0; j < dt_A.Rows.Count; j++)
  1733. {
  1734. UltraTreeNode Ultnode = ulTreeMat.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
  1735. Ultnode.LeftImages.Add(imageList1.Images[Ultnode.Level]);
  1736. getChildNodes(Ultnode);
  1737. }
  1738. }
  1739. /// <summary>
  1740. /// 递归查询父节点下的所有子节点
  1741. /// </summary>
  1742. /// <param name="Tnode"></param>
  1743. public void getChildNodes(UltraTreeNode Tnode)
  1744. {
  1745. DataTable dt_A = dt_Purmatclass.Clone();//物料分类
  1746. DataRow[] rows = dt_Purmatclass.Select("PARENTCODE='" + Tnode.Key + "'");
  1747. foreach (DataRow row in rows)
  1748. {
  1749. dt_A.ImportRow(row);//复制行数据
  1750. }
  1751. //排序
  1752. dt_A.DefaultView.Sort = "basename";
  1753. dt_A = dt_A.DefaultView.ToTable();
  1754. //添加物料分类
  1755. for (int j = 0; j < dt_A.Rows.Count; j++)
  1756. {
  1757. UltraTreeNode Ultnode = Tnode.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
  1758. try
  1759. {
  1760. Ultnode.LeftImages.Add(imageList1.Images[Ultnode.Level]);
  1761. //System.Drawing.Image image = System.Drawing.Image.FromFile(Environment.CurrentDirectory+"\\images\\IL_MAINMENU_IMAGE_LARGE\\01.png");
  1762. //Ultnode.LeftImages.Add(Environment.CurrentDirectory + "\\images\\IL_MAINMENU_IMAGE_LARGE\\01.png");
  1763. }
  1764. catch (Exception)
  1765. {
  1766. }
  1767. getChildNodes(Ultnode);//利用递归将当前节点的子节点添加进去
  1768. }
  1769. }
  1770. /// <summary>
  1771. /// 选中树形结构后自动展开,并且查询出相印的物料
  1772. /// </summary>
  1773. /// <param name="sender"></param>
  1774. /// <param name="e"></param>
  1775. private void ulTreeMat_AfterActivate(object sender, NodeEventArgs e)
  1776. {
  1777. if (!QClickCellOrQuery)//如果不是点击查询按钮或单击grig行数据,刷新右侧数据
  1778. {
  1779. ulTreeMat.ActiveNode.Expanded = true;
  1780. qUltraNode = ulTreeMat.ActiveNode;
  1781. getMat(getEnSelContion(qUltraNode.Key));
  1782. }
  1783. txt_ARC_CODE.Text = ulTreeMat.ActiveNode.Key;
  1784. txt_ARC_ITEM.Text = ulTreeMat.ActiveNode.Text;
  1785. }
  1786. /// <summary>
  1787. /// 查询物料规格
  1788. /// </summary>
  1789. /// <param name="sender"></param>
  1790. /// <param name="e"></param>
  1791. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  1792. {
  1793. UltraGridRow urg = ultraGrid1.ActiveRow;
  1794. if(urg!=null)
  1795. {
  1796. planPrice = urg.Cells["BUGPRICE"].Text.ToString();
  1797. }
  1798. if (ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString() == "作废")
  1799. {
  1800. dataTable2.Rows.Clear();
  1801. dataTable3.Rows.Clear();
  1802. dataTable4.Rows.Clear();
  1803. dataTable5.Rows.Clear();
  1804. getControlBoxValue(0);//清空控件
  1805. setUltCmbEdt_sel();
  1806. }
  1807. else
  1808. {
  1809. //查询物料属性
  1810. getItemAttr();
  1811. //查询供应商
  1812. getSuppGrade(ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString().Trim());
  1813. //查询物料标准编码
  1814. getMatStandard();
  1815. //单位
  1816. getMatUOM();
  1817. //给控件赋值
  1818. getControlBoxValue(sender);
  1819. }
  1820. this.ultraTabControl1.SelectedTab = ultraTabPageControl1.Tab;
  1821. UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(ultraGrid1.ActiveRow.Cells["ARCCODE"].Value.ToString());
  1822. if (ulTreeMat.ActiveNode == uttNode)
  1823. {
  1824. return;
  1825. }
  1826. ulTreeMat.CollapseAll();
  1827. QClickCellOrQuery = true;
  1828. ulTreeMat.ActiveNode = uttNode;
  1829. if (uttNode == null)
  1830. {
  1831. MessageUtil.ShowTips("物料名称:" + ultraGrid1.ActiveRow.Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + ultraGrid1.ActiveRow.Cells["ARCCODE"].Value.ToString());
  1832. }
  1833. else
  1834. {
  1835. while (ulTreeMat.ActiveNode != uttNode)
  1836. {
  1837. ulTreeMat.ActiveNode = uttNode;
  1838. }
  1839. uttNode.Expanded = true;
  1840. //展开分类
  1841. while (uttNode.Parent != null)
  1842. {
  1843. uttNode = uttNode.Parent;
  1844. uttNode.Expanded = true;
  1845. }
  1846. }
  1847. QClickCellOrQuery = false;//设置未点击
  1848. }
  1849. //供应商单击事件
  1850. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  1851. {
  1852. getControlBoxValue(sender);
  1853. }
  1854. //物料规格单击事件
  1855. private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
  1856. {
  1857. getControlBoxValue(sender);
  1858. }
  1859. private void ultraGrid5_AfterRowActivate(object sender, EventArgs e)
  1860. {
  1861. getControlBoxValue(sender);
  1862. }
  1863. /// <summary>
  1864. /// 单击数据列表赋值数据给控件
  1865. /// </summary>
  1866. private void getControlBoxValue(object sender)
  1867. {
  1868. if (sender.Equals(ultraGrid1) || sender.Equals(0))//清空文本框
  1869. {
  1870. foreach (Control ctr in ultraGroupBox6.Controls)
  1871. {
  1872. if (ctr is Label)
  1873. { continue; }
  1874. if (ctr is UltraCheckEditor)
  1875. {
  1876. UltraCheckEditor ultcmb = (UltraCheckEditor)ctr;
  1877. //ultChkSuppUon.Checked = false;
  1878. }
  1879. ctr.Text = null;
  1880. }
  1881. if (ultraGrid1.ActiveRow != null && !sender.Equals(0))//物料信息
  1882. {
  1883. MatEntity mat_entity = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() });
  1884. MatEntity mat_entity1 = CopyEntity<MatEntity>(mat_entity);
  1885. if (mat_entity.BaseUnitFlag == "1")//基顿标识
  1886. {
  1887. cb_BASE_UNIT_FLAG.Checked = true;
  1888. txt_BASE_UNIT_VALUE.Text = mat_entity.BaseUnitValue == null ? "" : mat_entity.BaseUnitValue.ToString();
  1889. }
  1890. else
  1891. {
  1892. cb_BASE_UNIT_FLAG.Checked = false;
  1893. }
  1894. txt_ItemArcCode.Text = mat_entity.ArcCode;
  1895. txt_ItemArcCodeName.Text = mat_entity.ArcItem;
  1896. txt_IS_BUDGET_CTRL.Value = mat_entity.IsBudgetCtrl == null ? null : mat_entity.IsBudgetCtrl;//是否定额控制
  1897. txt_DELVRY_RANGE_MIN.Value = mat_entity.DelvryRangeMin;//交货量差下限
  1898. txt_DELVRY_RANGE_MAX.Value = mat_entity.DelvryRangeMax;//交货量差上限
  1899. txt_DELVRY_RANGE_TPE.Value = mat_entity.DelvryRangeTpe;//交货量差方式
  1900. txt_DELVRY_RANGE_MIN2.Value = mat_entity.DelvryRangeMin;//交货量差下限
  1901. txt_DELVRY_RANGE_MAX2.Value = mat_entity.DelvryRangeMax;//交货量差上限
  1902. txt_delivery_type_2.Value = mat_entity.DelvryRangeTpe;//交货量差方式
  1903. //txt_MENT_UNIT_CODE.Text = mat_entity.MentUnitDesc == null ? null : mat_entity.MentUnitDesc.ToString();//采购管理科室代码
  1904. //txt_BUYER_UNITCODE.Text = mat_entity.BuyerUnitDesc == null ? null : mat_entity.BuyerUnitDesc.ToString();//采购管理部门代码
  1905. txt_BUYER_ROLE_NAME.Text = mat_entity.BuyerRoleName == null ? null : mat_entity.BuyerRoleName;
  1906. txt_PLANNER_ROLE_NAME.Text = mat_entity.PlannerRoleName == null ? null : mat_entity.PlannerRoleName;
  1907. QstrBUYER_ROLE_ID = ultraGrid1.ActiveRow.Cells["BUYERROLEID"].Value.ToString();
  1908. QstrPLANNER_ROLE_ID = ultraGrid1.ActiveRow.Cells["PLANNERROLEID"].Value.ToString();
  1909. txt_INV_PHYSIC_USERID.Text = mat_entity.InvPhysicUsername == null ? null : mat_entity.InvPhysicUsername;//库管员名称
  1910. QstrINV_PHYSIC_USERID = mat_entity.InvPhysicUserid;
  1911. Ultcmb_WEIGHT_UNIT.Text = mat_entity.WeightUnit == null ? null : mat_entity.WeightUnit.ToString();//库存单位
  1912. Ultcmb_WEIGHT_UNIT_CODE.Text = mat_entity.WeightUnitCode == null ? null : mat_entity.WeightUnitCode.ToString();//库存单位编码
  1913. txt_WEIGHT_UNIT.Text = mat_entity.WeightUnit == null ? null : mat_entity.WeightUnit.ToString();//库存单位
  1914. txt_WEIGHT_UNIT_CODE.Text = mat_entity.WeightUnitCode == null ? null : mat_entity.WeightUnitCode.ToString();//库存单位编码
  1915. Ultcmb_RECEIVE_TYPE.Value = mat_entity.ReceiveType;//入库类型;1:直接入库2:收货质检入库3:JIT入库4:VMI入库
  1916. Ultcmb_BATCH_FLAG.Value = mat_entity.BatchFlag;//是否批次控制
  1917. Ultcmb_PUR_STANDARDS.Value = mat_entity.PurStandards;//采购标准
  1918. Ultcmb_INV_WASTE_FAC_UOM.Value = mat_entity.InvWasteFacUom == null ? null : mat_entity.InvWasteFacUom.ToString();//库存损耗率单位
  1919. //Ultcmb_SHARE_CK_SPEC_FLAG.Value = mat_entity.ShareCkSpecFlag;//是否与子规格共用库存
  1920. Ultcmb_METERING_FLAG.Value = mat_entity.MeteringFlag;//是否计量
  1921. txt_PC_FLAG.Value = mat_entity.PcFlag;
  1922. Ultcmb_PRICE_TYPE.Text = mat_entity.PriceType == null ? null : mat_entity.PriceType.ToString();//计价类型
  1923. Ultcmb_CURRENCY_CODE.Text = mat_entity.CurrencyCode == null ? null : mat_entity.CurrencyCode.ToString();//币种代码
  1924. Ultcmb_LIFE_CYCLE_UOM.Text = mat_entity.LifeCycleUom == null ? null : mat_entity.LifeCycleUom.ToString();//有效期单位
  1925. //txt_UOM_NAME.Text = mat_entity.ItemUom == null ? null : mat_entity.ItemUom.ToString();//采购单位(个、袋、桶)
  1926. //txt_PUR_STANDARDS_CODE.Text = mat_entity.PurStandardsCode == null ? null : mat_entity.PurStandardsCode.ToString();//采购标准编号
  1927. txt_MIN_STOCK.Text = mat_entity.MinStock == null ? null : mat_entity.MinStock.ToString();//最小库存(预警)
  1928. txt_MAX_STOCK.Text = mat_entity.MaxStock == null ? null : mat_entity.MaxStock.ToString();//最大库存(预警)
  1929. txt_LEAD_TIME.Text = mat_entity.LeadTime == null ? null : mat_entity.LeadTime.ToString();//采购提前时间(天)
  1930. txt_INV_WASTE_FAC.Text = mat_entity.InvWasteFac == null ? null : mat_entity.InvWasteFac.ToString();//库存损耗率
  1931. txt_LIFE_CYCLE.Text = mat_entity.LifeCycle == null ? null : mat_entity.LifeCycle.ToString();//有效期
  1932. txt_MIN_QTY.Text = mat_entity.MinQty == null ? null : mat_entity.MinQty.ToString();//最小采购数量
  1933. txt_QTY_MULTIPLE.Text = mat_entity.QtyMultiple == null ? null : mat_entity.QtyMultiple.ToString();//批量数
  1934. txt_BUG_PRICE.Text = mat_entity.BugPrice == null ? null : mat_entity.BugPrice.ToString();//计划价
  1935. txt_LAST_PRICE.Text = mat_entity.LastPrice == null ? null : mat_entity.LastPrice.ToString();//最近采购价
  1936. //txt_ITEM_UOM_CONEFFICIENT.Text = mat_entity.ItemUomConefficient == null ? null : mat_entity.ItemUomConefficient.ToString();//转换系数
  1937. txt_MONTH_END_AVG_PRICE.Text = mat_entity.MonthEndAvgPrice == null ? null : mat_entity.MonthEndAvgPrice.ToString();//月末移动平均价
  1938. txt_ITEM_NAME.Text = mat_entity.ItemName == null ? null : mat_entity.ItemName.ToString();//物料名称
  1939. txt_ITEM_DESC_E.Text = mat_entity.ItemDescE == null ? null : mat_entity.ItemDescE.ToString();//物料英文名称
  1940. txt_ITEM_DESC.Text = mat_entity.ItemDesc == null ? null : mat_entity.ItemDesc.ToString();//物料描述
  1941. txt_ITEM_MODEL.Text = mat_entity.ItemModel == null ? null : mat_entity.ItemModel.ToString();//物料材质
  1942. txt_ITEM_SPEC.Text = mat_entity.ItemSpec == null ? null : mat_entity.ItemSpec.ToString();//物料型号规格
  1943. txt_ITEM_CODE.Text = mat_entity.ItemCode == null ? null : mat_entity.ItemCode.ToString();//物料编码
  1944. Ultcmb_MAT_TYPE.Text = mat_entity.MatType == null ? null : mat_entity.MatType.ToString();//物料大类
  1945. }
  1946. }
  1947. else if (sender.Equals(ultraGrid2) || sender.Equals(1))
  1948. {
  1949. if (ultraGrid2.ActiveRow == null)
  1950. {
  1951. foreach (Control ctr in ultraTabPageControl2.Controls)
  1952. {
  1953. if (ctr.Name.Contains("label"))
  1954. { continue; }
  1955. ctr.Text = null;
  1956. }
  1957. return;
  1958. }
  1959. if (ultraGrid2.ActiveRow != null && !sender.Equals(1))//物料供应商供应商信息
  1960. {
  1961. String strid = ultraGrid2.ActiveRow.GetCellValue("id").ToString().Trim();
  1962. if (String.IsNullOrEmpty(strid))
  1963. { return; }
  1964. Entity_SuppGrade mat_entity = this.execute<Entity_SuppGrade>("com.hnshituo.pur.configure.service.SuppGradeService", "findById", new object[] { strid });
  1965. txt_suppCode.Text = ultraGrid2.ActiveRow.Cells["SUPPCODE"].Value.ToString();
  1966. txt_SUPP_NAME.Text = ultraGrid2.ActiveRow.Cells["SUPPNAME"].Value.ToString();
  1967. txt_IS_DEFAULT.Value = mat_entity.IsDefault;
  1968. txt_DELVRY_RANGE_MIN2.Value = mat_entity.DelvryRangeMin;//交货量差下限
  1969. txt_DELVRY_RANGE_MAX2.Value = mat_entity.DelvryRangeMax;//交货量差上限
  1970. txt_delivery_type_2.Value = mat_entity.DelvryRangeTpe;//交货量差方式
  1971. }
  1972. }
  1973. else if (sender.Equals(ultraGrid3) || sender.Equals(2))
  1974. {
  1975. if (ultraGrid3.ActiveRow == null)
  1976. {
  1977. foreach (Control ctr in ultraTabPageControl3.Controls)
  1978. {
  1979. //if (ctr.Name.Contains("label") || ctr.GetType().FullName == "txt_IS_DEFAULT_ATTR")
  1980. //{ continue; }
  1981. //ctr.Text = null;
  1982. ConfigureClassCommon.clearOldData(ultraTabPageControl3);
  1983. }
  1984. return;
  1985. }
  1986. if (ultraGrid3.ActiveRow != null && !sender.Equals(2))//编辑属性
  1987. {
  1988. txt_item_Attr4.Text = ultraGrid3.ActiveRow.Cells["itemAttr4"].Value.ToString();
  1989. txt_item_Attr3.Text = ultraGrid3.ActiveRow.Cells["itemAttr3"].Value.ToString();
  1990. txt_item_Attr2.Text = ultraGrid3.ActiveRow.Cells["itemAttr2"].Value.ToString();
  1991. txt_item_Attr1.Text = ultraGrid3.ActiveRow.Cells["itemAttr1"].Value.ToString();
  1992. txt_ITEM_ATTR.Text = ultraGrid3.ActiveRow.Cells["ITEMATTR"].Value.ToString();//属性名称
  1993. txt_ITEM_ATTR_CODE.Text = ultraGrid3.ActiveRow.Cells["ITEMATTRCODE"].Value.ToString();//属性编码
  1994. if (ultraGrid3.ActiveRow.Cells["ISDEFAULT"].Value.ToString() == "是")//是否常用
  1995. {
  1996. txt_IS_DEFAULT_ATTR.Value = "1";//是
  1997. }
  1998. else
  1999. {
  2000. txt_IS_DEFAULT_ATTR.Value = "0";//否
  2001. }
  2002. if (ultraGrid3.ActiveRow.Cells["txtIsLevel"].Value.ToString() == "是") //IsLevel
  2003. {
  2004. txt_IsLevel.Value = "1";//是
  2005. }
  2006. else
  2007. {
  2008. txt_IsLevel.Value = "0";//否
  2009. }
  2010. txt_REMARK_ATTR.Text = ultraGrid3.ActiveRow.Cells["REMARK"].Value.ToString();//备注
  2011. //txt_ORDER_NUM.Value = ultraGrid3.ActiveRow.Cells["ORDERNUM"].Value.ToString();//排序
  2012. //txt_UOM_NAME.Text = ultraGrid3.ActiveRow.Cells["ITEMUOM"].Value.ToString();//采购单位
  2013. //txt_ITEM_UOM_CONEFFICIENT.Text = ultraGrid3.ActiveRow.Cells["ITEMUOMCONEFFICIENT"].Value.ToString();//转换系数
  2014. //if (ultraGrid3.ActiveRow.Cells["ITEMUSEUOM"].Value.ToString() == "1")//是否使用采购单位
  2015. //{
  2016. //ultChkSuppUon.Checked = true;
  2017. // }
  2018. //else
  2019. //{
  2020. // ultChkSuppUon.Checked = false;
  2021. //}
  2022. }
  2023. }
  2024. else if (sender.Equals(ultraGrid4) || sender.Equals(3))
  2025. {
  2026. if (ultraGrid4.ActiveRow == null)
  2027. {
  2028. foreach (Control ctr in ultraTabPageControl7.Controls)
  2029. {
  2030. if (ctr.Name.Contains("label") || ctr.Name == "txt_IS_DEFAULT_STANDRANDS")
  2031. { continue; }
  2032. ctr.Text = null;
  2033. }
  2034. return;
  2035. }
  2036. if (ultraGrid4.ActiveRow != null && !sender.Equals(3))
  2037. {
  2038. txt_STANDARDS_ID.Text = ultraGrid4.ActiveRow.Cells["STANDARDSID"].Value.ToString();//标准编号ID
  2039. txt_STANDARDS_CODE.Text = ultraGrid4.ActiveRow.Cells["STANDARDSCODE"].Value.ToString();//标准编号
  2040. txt_REMARK_STANDARD.Text = ultraGrid4.ActiveRow.Cells["REMARK"].Value.ToString();//备注
  2041. if (ultraGrid4.ActiveRow.Cells["ISDEFAULT"].Value.ToString() == "是")//是否常用
  2042. {
  2043. txt_IS_DEFAULT_STANDRANDS.Value = "1";//是
  2044. }
  2045. else
  2046. {
  2047. txt_IS_DEFAULT_STANDRANDS.Value = "0";//否
  2048. }
  2049. }
  2050. }
  2051. else if (sender.Equals(ultraGrid5) || sender.Equals(4))
  2052. {
  2053. if (ultraGrid5.ActiveRow == null)
  2054. {
  2055. foreach (Control ctr in ultraTabPageControl9.Controls)
  2056. {
  2057. if (ctr.Name.Contains("label") || ctr.Name == "txt_IS_DEFAULT_UOM")
  2058. { continue; }
  2059. ctr.Text = null;
  2060. }
  2061. return;
  2062. }
  2063. if (ultraGrid5.ActiveRow != null && !sender.Equals(4))
  2064. {
  2065. txt_UOM_NAME.Text = ultraGrid5.ActiveRow.Cells["UOMNAME"].Value.ToString();//采购单位名称
  2066. txt_UOM_CODE.Text = ultraGrid5.ActiveRow.Cells["UOMCODE"].Value.ToString();//采购单位编码
  2067. txt_WEIGHT_UNIT_CODE.Text = ultraGrid1.ActiveRow.Cells["WEIGHTUNITCODE"].Value.ToString();//库存单位编码
  2068. txt_WEIGHT_UNIT.Text = ultraGrid1.ActiveRow.Cells["WEIGHTUNIT"].Value.ToString();//库存单位名称
  2069. txt_ITEM_UOM_CONEFFICIENT.Text = ultraGrid5.ActiveRow.Cells["ITEMUOMCONEFFICIENT"].Value.ToString();//转换系数
  2070. txt_REMARK_UOM.Text = ultraGrid5.ActiveRow.Cells["REMARK"].Value.ToString();//备注
  2071. if (ultraGrid5.ActiveRow.Cells["ISDEFAULT"].Value.ToString() == "是")//是否常用
  2072. {
  2073. txt_IS_DEFAULT_UOM.Value = "1";//是
  2074. }
  2075. else
  2076. {
  2077. txt_IS_DEFAULT_UOM.Value = "0";//否
  2078. }
  2079. }
  2080. }
  2081. }
  2082. /// <summary>
  2083. /// 设置下拉列表默认选中事件
  2084. /// </summary>
  2085. public void setUltCmbEdt_sel()
  2086. {
  2087. if (Ultcmb_RECEIVE_TYPE.Items.Count > 0)
  2088. Ultcmb_RECEIVE_TYPE.SelectedIndex = 0;
  2089. if (Ultcmb_BATCH_FLAG.Items.Count > 0)
  2090. Ultcmb_BATCH_FLAG.SelectedIndex = 0;
  2091. if (Ultcmb_PUR_STANDARDS.Items.Count > 0)
  2092. Ultcmb_PUR_STANDARDS.SelectedIndex = 0;
  2093. if (Ultcmb_INV_WASTE_FAC_UOM.Items.Count > 0)
  2094. Ultcmb_INV_WASTE_FAC_UOM.SelectedIndex = 0;
  2095. if (Ultcmb_METERING_FLAG.Items.Count > 0)
  2096. Ultcmb_METERING_FLAG.SelectedIndex = 0;
  2097. if (Ultcmb_PRICE_TYPE.Items.Count > 0)
  2098. Ultcmb_PRICE_TYPE.SelectedIndex = 0;
  2099. if (Ultcmb_CURRENCY_CODE.Items.Count > 0)
  2100. Ultcmb_CURRENCY_CODE.SelectedIndex = 0;
  2101. if (Ultcmb_LIFE_CYCLE_UOM.Items.Count > 0)
  2102. Ultcmb_LIFE_CYCLE_UOM.SelectedIndex = 0;
  2103. if (txt_DELVRY_RANGE_TPE.Items.Count > 0)
  2104. txt_DELVRY_RANGE_TPE.SelectedIndex = 0;
  2105. }
  2106. /// ultraGrid1行单击事件
  2107. /// </summary>
  2108. /// <param name="sender"></param>
  2109. /// <param name="e"></param>
  2110. private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
  2111. {
  2112. this.ultraTabControl1.SelectedTab = ultraTabPageControl1.Tab;
  2113. UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(e.Cell.Row.Cells["ARCCODE"].Value.ToString());
  2114. if (ulTreeMat.ActiveNode == uttNode)
  2115. {
  2116. return;
  2117. }
  2118. ulTreeMat.CollapseAll();
  2119. QClickCellOrQuery = true;
  2120. ulTreeMat.ActiveNode = uttNode;
  2121. if (uttNode == null)
  2122. {
  2123. MessageUtil.ShowTips("物料名称:" + e.Cell.Row.Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + e.Cell.Row.Cells["ARCCODE"].Value.ToString());
  2124. }
  2125. else
  2126. {
  2127. while (ulTreeMat.ActiveNode != uttNode)
  2128. {
  2129. ulTreeMat.ActiveNode = uttNode;
  2130. }
  2131. uttNode.Expanded = true;
  2132. //展开分类
  2133. while (uttNode.Parent != null)
  2134. {
  2135. uttNode = uttNode.Parent;
  2136. uttNode.Expanded = true;
  2137. }
  2138. }
  2139. QClickCellOrQuery = false;//设置未点击
  2140. }
  2141. /// <summary>
  2142. /// ultraGrid2行单击事件
  2143. /// </summary>
  2144. /// <param name="sender"></param>
  2145. /// <param name="e"></param>
  2146. private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
  2147. {
  2148. }
  2149. /// <summary>
  2150. /// ultraGrid3行单击事件
  2151. /// </summary>
  2152. /// <param name="sender"></param>
  2153. /// <param name="e"></param>
  2154. private void ultraGrid3_ClickCell(object sender, ClickCellEventArgs e)
  2155. {
  2156. }
  2157. /// <summary>
  2158. /// ultraGrid5行单击事件
  2159. /// </summary>
  2160. /// <param name="sender"></param>
  2161. /// <param name="e"></param>
  2162. private void ultraGrid5_ClickCell(object sender, ClickCellEventArgs e)
  2163. {
  2164. this.ultraTabControl1.SelectedTab = ultraTabPageControl9.Tab;
  2165. }
  2166. private void ultraGrid2_Click(object sender, EventArgs e)
  2167. {
  2168. this.ultraTabControl1.SelectedTab = ultraTabPageControl2.Tab;
  2169. }
  2170. private void ultraGrid3_Click(object sender, EventArgs e)
  2171. {
  2172. this.ultraTabControl1.SelectedTab = ultraTabPageControl3.Tab;
  2173. }
  2174. private void ultraGrid4_Click(object sender, EventArgs e)
  2175. {
  2176. this.ultraTabControl1.SelectedTab = ultraTabPageControl7.Tab;
  2177. }
  2178. /// <summary>
  2179. /// 单击选择编辑区tab页
  2180. /// </summary>
  2181. /// <param name="sender"></param>
  2182. /// <param name="e"></param>
  2183. private void ultraGrid5_Click(object sender, EventArgs e)
  2184. {
  2185. this.ultraTabControl1.SelectedTab = ultraTabPageControl9.Tab;
  2186. }
  2187. /// <summary>
  2188. /// 是否使用采购单位
  2189. /// </summary>
  2190. /// <param name="sender"></param>
  2191. /// <param name="e"></param>
  2192. private void ultChkSuppUon_CheckedChanged(object sender, EventArgs e)
  2193. {
  2194. ////if (ultChkSuppUon.Checked)
  2195. //{
  2196. // Ultcmb_ITEM_UOM.Enabled = true;
  2197. // txt_ITEM_UOM_CONEFFICIENT.Enabled = true;
  2198. //}
  2199. //else
  2200. //{
  2201. // Ultcmb_ITEM_UOM.Enabled = false;
  2202. // txt_ITEM_UOM_CONEFFICIENT.Enabled = false;
  2203. //}
  2204. }
  2205. /// <summary>
  2206. /// 单机选择采购部门
  2207. /// </summary>
  2208. /// <param name="sender"></param>
  2209. /// <param name="e"></param>
  2210. //private void txt_BUYER_DEPT_CODE_MouseClick(object sender, MouseEventArgs e)
  2211. //{
  2212. // //查询采购科室
  2213. // frmdepartment frm = new frmdepartment(ob);
  2214. // frm.StartPosition = FormStartPosition.Manual;
  2215. // frm.Location = new Point(Cursor.Position.X, Cursor.Position.Y - frm.Height);//还需设置frm.StartPosition属性
  2216. // frm.ShowDialog();
  2217. // if (frm.BuyerUnitCode == null)
  2218. // return;
  2219. // if (sender.Equals(txt_BUYER_UNITCODE))
  2220. // {
  2221. // txt_BUYER_UNITCODE.Text = frm.BuyerUnitDesc;
  2222. // strBUYER_DEPT_CODE = frm.BuyerUnitCode;
  2223. // }
  2224. // else if (sender.Equals(txt_MENT_UNIT_CODE))
  2225. // {
  2226. // txt_MENT_UNIT_CODE.Text = frm.BuyerUnitDesc;
  2227. // strMENT_UNIT_CODE = frm.BuyerUnitCode;
  2228. // }
  2229. //}
  2230. private void ultraScrollBar1_Scroll(object sender, ScrollEventArgs e)
  2231. {
  2232. foreach (Control gbox in ultraGroupBox6.Controls)
  2233. {
  2234. if (gbox is UltraScrollBar) continue;
  2235. gbox.Location = new Point(gbox.Location.X, (int)gbox.Tag - e.NewValue);
  2236. }
  2237. }
  2238. /// <summary>
  2239. /// 获取查询条件
  2240. /// </summary>
  2241. /// <returns></returns>
  2242. private MatEntity getEnSelContion(string str)
  2243. {
  2244. MatEntity eMat = new MatEntity();
  2245. if (str == null)
  2246. {
  2247. if (ultraTextEditor1.Text.Trim() != "")
  2248. {
  2249. eMat.ItemCode = ultraTextEditor1.Text;
  2250. }
  2251. if (ultraTextEditor2.Text.Trim() != "")
  2252. {
  2253. string strItemName = ultraTextEditor2.Text.Trim();
  2254. while (strItemName.Contains(" "))
  2255. {
  2256. strItemName=strItemName.Replace(" ", " ");
  2257. }
  2258. eMat.MatItems = strItemName.Split(' ');
  2259. }
  2260. //物料分类
  2261. if (checkBox1.Checked)
  2262. {
  2263. eMat.UpdateName = txt_ARC_CODE.Text;
  2264. }
  2265. }
  2266. else
  2267. {
  2268. eMat.ArcCode = str;
  2269. }
  2270. if (cmbNum.Value != null && cmbNum.Value.ToString() != "")
  2271. {
  2272. eMat.ItemUomConefficient = double.Parse(cmbNum.Value.ToString());
  2273. }
  2274. return eMat;
  2275. }
  2276. /// <summary>
  2277. /// 获取物料编码
  2278. /// </summary>
  2279. /// <param name="str"></param>
  2280. /// <returns></returns>
  2281. public string getItemCodeClass(string str, string strParentCode)
  2282. {
  2283. //在后台获取编码
  2284. string strCode = this.execute<string>("com.hnshituo.pur.configure.service.MatService", "getItemCode", new object[] { str });
  2285. return strCode;
  2286. //在前台获取编码
  2287. //string strChild = "";
  2288. //string strJion = "";
  2289. //int num = 0;
  2290. //MatEntity mat = new MatEntity();
  2291. //if (strParentCode == "")//获取物料编码
  2292. //{
  2293. // num = 7;
  2294. // mat.ArcCode = str;
  2295. //}
  2296. //else//获取属性物料编码
  2297. //{
  2298. // strJion = "@";
  2299. // num = 3;
  2300. // mat.ParentItemCode = str;
  2301. //}
  2302. //int intChild = this.execute<int>("com.hnshituo.pur.configure.service.MatService", "count", new object[] { mat, 0, 0 });
  2303. //intChild++;
  2304. //strChild = intChild.ToString();
  2305. //while (strChild.Length < num)
  2306. //{
  2307. // strChild = "0" + strChild;
  2308. //}
  2309. ////判断编码是否存在
  2310. //MatEntity matIsExsitRow = new MatEntity();
  2311. //matIsExsitRow.ItemCode = str + strJion + strChild;
  2312. //while (isExsitRow("com.hnshituo.pur.configure.service.MatService", matIsExsitRow) > 0)
  2313. //{
  2314. // intChild++;
  2315. // strChild = intChild.ToString();
  2316. // while (strChild.Length < num)
  2317. // {
  2318. // strChild = "0" + strChild;
  2319. // }
  2320. // matIsExsitRow.ItemCode = str + strJion + strChild;
  2321. //}
  2322. //return str + strJion + strChild;
  2323. }
  2324. /// <summary>
  2325. /// 选择供应商
  2326. /// </summary>
  2327. /// <param name="sender"></param>
  2328. /// <param name="e"></param>
  2329. /// <summary>
  2330. private void txt_SUPP_NAME_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2331. {
  2332. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.SuppService", "findAll", new object[] { });
  2333. if (dt == null || dt.Rows.Count < 1)
  2334. {
  2335. MessageUtil.ShowTips("暂无供应商可选");
  2336. return;
  2337. }
  2338. frmSuppSel frm = new frmSuppSel(this.ob);
  2339. frm.ShowDialog();
  2340. if (!string.IsNullOrEmpty(frm.strSUPP_NAME))
  2341. {
  2342. txt_SUPP_NAME.Text = frm.strSUPP_NAME;
  2343. txt_suppCode.Text = frm.strSUPP_CODE;
  2344. }
  2345. }
  2346. /// <summary>
  2347. /// 选择采购员角色ID
  2348. /// </summary>
  2349. /// <param name="sender"></param>
  2350. /// <param name="e"></param>
  2351. private void txt_BUYER_ROLE_ID_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2352. {
  2353. FrmPop_core_app_srole frm = new FrmPop_core_app_srole(this.ob);
  2354. frm.ShowDialog();
  2355. if (frm.StrDeptid != "")
  2356. {
  2357. if (sender.Equals(txt_BUYER_ROLE_NAME))//物料
  2358. {
  2359. QstrBUYER_ROLE_ID = frm.StrDeptid;
  2360. txt_BUYER_ROLE_NAME.Text = frm.StrName;
  2361. }
  2362. else//供应商
  2363. {
  2364. QstrBUYER_ROLE_ID1 = frm.StrDeptid;
  2365. txt_BUYER_ROLE_NAME1.Text = frm.StrName;
  2366. }
  2367. }
  2368. }
  2369. /// <summary>
  2370. /// 选择库管员
  2371. /// </summary>
  2372. /// <param name="sender"></param>
  2373. /// <param name="e"></param>
  2374. private void txt_INV_PHYSIC_USERID_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2375. {
  2376. SetectManByDept frm = new SetectManByDept(this.ob, "002001029006");
  2377. frm.ShowDialog();
  2378. if (!string.IsNullOrEmpty(frm.StrUserID))
  2379. {
  2380. QstrINV_PHYSIC_USERID = frm.StrUserID;
  2381. txt_INV_PHYSIC_USERID.Text = frm.StrUserName;
  2382. }
  2383. }
  2384. /// <summary>
  2385. /// 选择计划员角色ID
  2386. /// </summary>
  2387. /// <param name="sender"></param>
  2388. /// <param name="e"></param>
  2389. private void txt_PLANNER_ROLE_ID_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2390. {
  2391. FrmPop_core_app_srole frm = new FrmPop_core_app_srole(this.ob);
  2392. frm.ShowDialog();
  2393. if (sender.Equals(txt_PLANNER_ROLE_NAME))//物料
  2394. {
  2395. if (frm.StrDeptid != "")
  2396. {
  2397. QstrPLANNER_ROLE_ID = frm.StrDeptid;
  2398. txt_PLANNER_ROLE_NAME.Text = frm.StrName;
  2399. }
  2400. }
  2401. else//供应商
  2402. {
  2403. if (frm.StrDeptid != "")
  2404. {
  2405. QstrPLANNER_ROLE_ID1 = frm.StrDeptid;
  2406. txt_PLANNER_ROLE_NAME1.Text = frm.StrName;
  2407. }
  2408. }
  2409. }
  2410. /// <summary>
  2411. /// 批量修改物料采购员或计划员角色
  2412. /// </summary>
  2413. /// <param name="strParentMatCode"></param>
  2414. /// <param name="PeopleType">1为采购员,2为计划员</param>
  2415. private void updateSrole(string strParentMatCode, string PeopleType)
  2416. {
  2417. if (PeopleType == "2")
  2418. { //修改采购员角色
  2419. FrmPop_core_app_srole frm = new FrmPop_core_app_srole(this.ob);
  2420. frm.ShowDialog();
  2421. if (frm.StrDeptid != "")
  2422. {
  2423. if (MessageUtil.ShowYesNoAndTips("是否确定批量修改物料分类【" + ulTreeMat.ActiveNode.Text + "】所有物料的采购员角色为【" + frm.StrName + "】?").Equals(DialogResult.No))
  2424. { return; }
  2425. MatEntity mat_entity = new MatEntity();
  2426. mat_entity.ArcCode = strParentMatCode;
  2427. mat_entity.BuyerRoleId = frm.StrDeptid;
  2428. mat_entity.BuyerRoleName = frm.StrName;
  2429. mat_entity.UpdateName = UserInfo.GetUserName();
  2430. mat_entity.UpdateUserid = UserInfo.GetUserID();
  2431. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "updateSrole", new object[] { mat_entity });//更新操作
  2432. if (crt.Resultcode != 0)
  2433. {
  2434. MessageUtil.ShowTips("批量更新失败 " + crt.Resultmsg);
  2435. return;
  2436. }
  2437. MessageUtil.ShowTips("批量更新成功");
  2438. if (Q_mat != null)
  2439. getMat(Q_mat);//刷新物料
  2440. }
  2441. }
  2442. //修改
  2443. else if (PeopleType == "3")
  2444. {
  2445. SetectManByDept frm = new SetectManByDept(this.ob, "002001029006");
  2446. frm.ShowDialog();
  2447. if (!string.IsNullOrEmpty(frm.StrUserID))
  2448. {
  2449. if (MessageUtil.ShowYesNoAndTips("是否确定批量修改物料分类【" + ulTreeMat.ActiveNode.Text + "】所有物料的库管员为【" + frm.StrUserName + "】?").Equals(DialogResult.No))
  2450. { return; }
  2451. QstrINV_PHYSIC_USERID = frm.StrUserID;
  2452. txt_INV_PHYSIC_USERID.Text = frm.StrUserName;
  2453. MatEntity mat_entity = new MatEntity();
  2454. mat_entity.ArcCode = strParentMatCode;
  2455. mat_entity.InvPhysicUserid = frm.StrUserID;
  2456. mat_entity.InvPhysicUsername = frm.StrUserName;
  2457. mat_entity.UpdateName = UserInfo.GetUserName();
  2458. mat_entity.UpdateUserid = UserInfo.GetUserID();
  2459. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "updateSrole", new object[] { mat_entity });//更新操作
  2460. if (crt.Resultcode != 0)
  2461. {
  2462. MessageUtil.ShowTips("批量更新库管员失败 " + crt.Resultmsg);
  2463. return;
  2464. }
  2465. MessageUtil.ShowTips("批量更新库管员成功");
  2466. if (Q_mat != null)
  2467. getMat(Q_mat);//刷新物料
  2468. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
  2469. }
  2470. }
  2471. else if (PeopleType == "1")//修改计划员角色
  2472. {
  2473. FrmPop_core_app_srole frm = new FrmPop_core_app_srole(this.ob);
  2474. frm.ShowDialog();
  2475. if (frm.StrDeptid != "")
  2476. {
  2477. if (MessageUtil.ShowYesNoAndTips("是否确定批量修改物料分类【" + ulTreeMat.ActiveNode.Text + "】所有物料的计划员角色为【" + frm.StrName + "】?").Equals(DialogResult.No))
  2478. { return; }
  2479. MatEntity mat_entity = new MatEntity();
  2480. mat_entity.ArcCode = strParentMatCode;
  2481. mat_entity.Validflag = "1";
  2482. mat_entity.PlannerRoleId = frm.StrDeptid;
  2483. mat_entity.PlannerRoleName = frm.StrName;
  2484. mat_entity.UpdateName = UserInfo.GetUserName();
  2485. mat_entity.UpdateUserid = UserInfo.GetUserID();
  2486. // if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料分类【" + ulTreeMat.ActiveNode.Text + "】的计划员角色为【" + frm.StrName + "】?") == DialogResult.No)
  2487. //{
  2488. // return;
  2489. // }
  2490. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "updateSrole", new object[] { mat_entity });//更新操作
  2491. if (crt.Resultcode != 0)
  2492. {
  2493. MessageUtil.ShowTips("批量更新失败 " + crt.Resultmsg);
  2494. return;
  2495. }
  2496. MessageUtil.ShowTips("批量更新成功");
  2497. if (Q_mat != null)
  2498. getMat(Q_mat);//刷新物料
  2499. }
  2500. }
  2501. }
  2502. /// <summary>
  2503. /// 批量新增供应商
  2504. /// </summary>
  2505. /// <param name="strParentMatCode"></param>
  2506. /// <param name="PeopleType">1为采购员,2为计划员</param>
  2507. private void addSupps(string strParentMatCode, string strSuppCode)
  2508. {
  2509. if (txt_suppCode.Text.Trim() == "")
  2510. {
  2511. MessageUtil.ShowTips("请选择供应商");
  2512. return;
  2513. }
  2514. if (strParentMatCode == "")
  2515. {
  2516. MessageUtil.ShowTips("请选择分类");
  2517. return;
  2518. }
  2519. Supp EntitySupp = this.execute<Supp>("com.hnshituo.pur.configure.service.SuppService", "findById", new object[] { strSuppCode });
  2520. MatEntity mat_entity = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() });
  2521. Entity_SuppGrade EntitySuppGrade = new Entity_SuppGrade();
  2522. EntitySuppGrade.SuppCode = EntitySupp.SuppCode;
  2523. EntitySuppGrade.ItemCode = mat_entity.ItemCode;
  2524. if (isExsitRow("com.hnshituo.pur.configure.service.SuppGradeService", EntitySuppGrade) > 0)//包含相同的文件
  2525. {
  2526. MessageUtil.ShowTips("数据库中存在相同的供应商,请重新选择");
  2527. return;
  2528. }
  2529. EntitySuppGrade.SuppName = EntitySupp.SuppName;
  2530. EntitySuppGrade.SuppShortName = EntitySupp.SuppShortName;
  2531. EntitySuppGrade.SuppPerGrade = EntitySupp.SuppCreditRate;
  2532. EntitySuppGrade.IsDefault = txt_IS_DEFAULT.Value == null ? null : txt_IS_DEFAULT.Value.ToString();
  2533. EntitySuppGrade.ItemCode = mat_entity.ItemCode;
  2534. EntitySuppGrade.ItemDesc = mat_entity.ItemDesc;
  2535. EntitySuppGrade.ItemDescE = mat_entity.ItemDescE;
  2536. EntitySuppGrade.ItemName = mat_entity.ItemName;
  2537. //EntitySuppGrade.BuyerRoleId = QstrBUYER_ROLE_ID1;
  2538. //EntitySuppGrade.PlannerRoleName = QstrPLANNER_ROLE_ID1;
  2539. //EntitySuppGrade.BuyerRoleName = txt_BUYER_ROLE_NAME1.Text;
  2540. //EntitySuppGrade.PlannerRoleName = txt_PLANNER_ROLE_NAME1.Text;
  2541. if (txt_delivery_type_2.SelectedIndex == -1)
  2542. {
  2543. MessageUtil.ShowTips("请选择交货差方式");
  2544. txt_delivery_type_2.Focus();
  2545. return;
  2546. }
  2547. EntitySuppGrade.DelvryRangeTpe = txt_delivery_type_2.Value.ToString().Trim();//交货量差方式
  2548. if ("1" == txt_delivery_type_2.Value.ToString().Trim() || "2" == txt_delivery_type_2.Value.ToString().Trim())
  2549. {
  2550. if (txt_DELVRY_RANGE_MIN2.Value != null)
  2551. {
  2552. EntitySuppGrade.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN2.Value.ToString());//交货量差下限
  2553. }
  2554. else
  2555. {
  2556. MessageUtil.ShowTips("请填写交货量差下限值");
  2557. txt_DELVRY_RANGE_MIN2.Focus();
  2558. return;
  2559. }
  2560. if (txt_DELVRY_RANGE_MAX2.Value != null)
  2561. {
  2562. EntitySuppGrade.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX2.Value.ToString());//交货量差上限
  2563. }
  2564. else
  2565. {
  2566. MessageUtil.ShowTips("请填写交货量差上限值");
  2567. txt_DELVRY_RANGE_MAX2.Focus();
  2568. return;
  2569. }
  2570. }
  2571. else
  2572. {
  2573. EntitySuppGrade.DelvryRangeMin = 0;
  2574. EntitySuppGrade.DelvryRangeMax = 0;
  2575. }
  2576. if (MessageUtil.ShowYesNoAndQuestion("是否确定添加供应商【" + txt_SUPP_NAME.Text.Trim() + "】到物料分类【" + ulTreeMat.ActiveNode.Text.ToString().Trim() + "】下的所有物料中?") == DialogResult.No)
  2577. {
  2578. return;
  2579. }
  2580. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "AddSupps", new object[] { mat_entity,EntitySuppGrade });//更新操作
  2581. if (crt.Resultcode != 0)
  2582. {
  2583. MessageUtil.ShowTips("批量新增失败 " + crt.Resultmsg);
  2584. return;
  2585. }
  2586. MessageUtil.ShowTips("批量新增成功");
  2587. if (Q_mat != null)
  2588. getMat(Q_mat);//刷新物料
  2589. }
  2590. /// <summary>
  2591. /// 采购单位单击按钮
  2592. /// </summary>
  2593. /// <param name="sender"></param>
  2594. /// <param name="e"></param>
  2595. private void Ultcmb_ITEM_UOM_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2596. {
  2597. //frmPopItemUon frm = new frmPopItemUon(this.ob);
  2598. //frm.ShowDialog();
  2599. //txt_UOM_NAME.Text = frm.QstrWeightName;
  2600. //txt_UOM_NAME.Text = frm.QstrWeightName;
  2601. }
  2602. private void Ultcmb_WEIGHT_UNIT_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2603. {
  2604. FrmPopItemWeight frm = new FrmPopItemWeight(this.ob);
  2605. frm.ShowDialog();
  2606. if (!string.IsNullOrEmpty(frm.QstrWeightName))
  2607. {
  2608. Ultcmb_WEIGHT_UNIT.Text = frm.QstrWeightName;
  2609. Ultcmb_WEIGHT_UNIT_CODE.Text = frm.QstrWeightCode;
  2610. }
  2611. }
  2612. /// <summary>
  2613. /// 绑定所有的下拉列表的数据
  2614. /// </summary>
  2615. private void getUltcmbBindValueList(DataTable dt, UltraComboEditor ultcmb)
  2616. {
  2617. for (int i = 0; i < dt.Rows.Count; i++)
  2618. {
  2619. ValueListItem vlItem = new ValueListItem(dt.Rows[i]["BASECODE"].ToString().Trim(), dt.Rows[i]["BASENAME"].ToString().Trim());
  2620. ultcmb.Items.Add(vlItem);
  2621. }
  2622. }
  2623. /// <summary>
  2624. /// 切换tab功能界面同时切换相应的编辑区界面
  2625. /// </summary>
  2626. /// <param name="sender"></param>
  2627. /// <param name="e"></param>
  2628. private void ultraTabControl2_Click(object sender, EventArgs e)
  2629. {
  2630. if (this.ultraTabControl2.SelectedTab.Key == "0")
  2631. {
  2632. this.ultraTabControl1.SelectedTab = ultraTabPageControl2.Tab;
  2633. }
  2634. else if (this.ultraTabControl2.SelectedTab.Key == "1")
  2635. {
  2636. this.ultraTabControl1.SelectedTab = ultraTabPageControl3.Tab;
  2637. }
  2638. else if (this.ultraTabControl2.SelectedTab.Key == "2")
  2639. {
  2640. this.ultraTabControl1.SelectedTab = ultraTabPageControl7.Tab;
  2641. }
  2642. else if (this.ultraTabControl2.SelectedTab.Key == "3")
  2643. {
  2644. this.ultraTabControl1.SelectedTab = ultraTabPageControl9.Tab;
  2645. }
  2646. }
  2647. /// <summary>
  2648. /// 移除无效数据
  2649. /// </summary>
  2650. /// <param name="dt"></param>
  2651. private void removeNotValiflagData(DataTable dt)
  2652. {
  2653. for (int i = 0; i < dt.Rows.Count; )
  2654. {
  2655. if (dt.Rows[i]["VALIDFLAG"].ToString() == "0")
  2656. {
  2657. dt.Rows.RemoveAt(i);
  2658. }
  2659. else
  2660. {
  2661. i++;
  2662. }
  2663. }
  2664. }
  2665. /// 单击选择列表区tab页
  2666. /// </summary>
  2667. /// <param name="sender"></param>
  2668. /// <param name="e"></param>
  2669. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  2670. {
  2671. if (this.ultraTabControl1.SelectedTab.Key == "0")
  2672. {
  2673. this.ultraTabControl2.SelectedTab = ultraTabPageControl4.Tab;
  2674. }
  2675. else if (this.ultraTabControl1.SelectedTab.Key == "1")
  2676. {
  2677. this.ultraTabControl2.SelectedTab = ultraTabPageControl5.Tab;
  2678. }
  2679. else if (this.ultraTabControl1.SelectedTab.Key == "2")
  2680. {
  2681. this.ultraTabControl2.SelectedTab = ultraTabPageControl6.Tab;
  2682. }
  2683. else if (this.ultraTabControl1.SelectedTab.Key == "3")
  2684. {
  2685. this.ultraTabControl2.SelectedTab = ultraTabPageControl8.Tab;
  2686. }
  2687. }
  2688. /// <summary>
  2689. /// 绑定下拉列表的数据
  2690. /// </summary>
  2691. /// <param name="dt"></param>
  2692. /// <summary>
  2693. private void getUltcmbBindData()
  2694. {
  2695. DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1101" }, this.ob);
  2696. removeNotValiflagData(dt);
  2697. getUltcmbBindValueList(dt, Ultcmb_RECEIVE_TYPE);
  2698. //Ultcmb_RECEIVE_TYPE.DataSource = dt;
  2699. //Ultcmb_RECEIVE_TYPE.DisplayMember = "BASENAME";
  2700. //Ultcmb_RECEIVE_TYPE.ValueMember = "BASECODE";
  2701. //ComboBoxHelper.FillUltraComboItems(Ultcmb_RECEIVE_TYPE, dt, "VALIDFLAG='1'");//接收方式
  2702. }
  2703. /// <summary>
  2704. /// 点击弹出属性选择窗口
  2705. /// </summary>
  2706. /// <param name="sender"></param>
  2707. /// <param name="e"></param>
  2708. private void txt_ITEM_ATTR_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2709. {
  2710. FrmPopAttrs frm = new FrmPopAttrs(this.ob);
  2711. frm.ShowDialog();
  2712. if (frm.QstrItemAttrCode != "")
  2713. {
  2714. txt_ITEM_ATTR.Text = frm.QstrItemAttr;
  2715. txt_ITEM_ATTR_CODE.Text = frm.QstrItemAttrCode;
  2716. txt_MatAttrClass.Text = frm.QstrItemAttrClass;
  2717. txt_MatAttrClassName.Text = frm.QstrItemAttrClassName;
  2718. }
  2719. }
  2720. /// <summary>
  2721. /// 点击弹出标准编号选择窗口
  2722. /// </summary>
  2723. /// <param name="sender"></param>
  2724. /// <param name="e"></param>
  2725. private void txt_STANDARDS_CODE_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2726. {
  2727. FrmPopStandards frm = new FrmPopStandards(this.ob);
  2728. frm.ShowDialog();
  2729. if (frm.QstrStandardsCode != "")
  2730. {
  2731. txt_STANDARDS_CODE.Text = frm.QstrStandardsCode;
  2732. txt_STANDARDS_ID.Text = frm.QstrStandardsId;
  2733. }
  2734. }
  2735. /// <summary>
  2736. /// 点击弹出单位选择窗口
  2737. /// </summary>
  2738. /// <param name="sender"></param>
  2739. /// <param name="e"></param>
  2740. private void txt_UOM_NAME_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2741. {
  2742. string strWeight = "";
  2743. if (ultraGrid1.ActiveRow != null)
  2744. {
  2745. strWeight = ultraGrid1.ActiveRow.Cells["WEIGHTUNITCODE"].Value.ToString();
  2746. }
  2747. frmPopItemUon frm = new frmPopItemUon(this.ob, strWeight);
  2748. frm.ShowDialog();
  2749. if (frm.QstrUOMCode != "")
  2750. {
  2751. txt_ITEM_UOM_CONEFFICIENT.Text = frm.QstrItemUomConefficient;//转换系数
  2752. txt_WEIGHT_UNIT_CODE.Text = frm.QstrWeightCode;//库存单位编码
  2753. txt_WEIGHT_UNIT.Text = frm.QstrWeightName;//库存单位名称
  2754. txt_UOM_CODE.Text = frm.QstrUOMCode;//采购单位名称
  2755. txt_UOM_NAME.Text = frm.QstrUOMName;//采购单位名称
  2756. }
  2757. }
  2758. /// <summary>
  2759. /// 基顿标识
  2760. /// </summary>
  2761. /// <param name="sender"></param>
  2762. /// <param name="e"></param>
  2763. private void cb_BASE_UNIT_FLAG_CheckedChanged(object sender, EventArgs e)
  2764. {
  2765. txt_BASE_UNIT_VALUE.ReadOnly = !cb_BASE_UNIT_FLAG.Checked;
  2766. }
  2767. /// <summary>
  2768. /// 是否显示已作废的物料
  2769. /// </summary>
  2770. /// <param name="sender"></param>
  2771. /// <param name="e"></param>
  2772. private void chk_showHasDelete_CheckedChanged(object sender, EventArgs e)
  2773. {
  2774. getMat(Q_mat);
  2775. }
  2776. /// <summary>
  2777. /// 是否显示已作废的物料
  2778. /// </summary>
  2779. /// <param name="bl"></param>
  2780. private void showHasDelete(bool bl)
  2781. {
  2782. if (bl)//true 显示作废物料
  2783. {
  2784. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  2785. {
  2786. if (ugr.Cells["VALIDFLAG"].Value.ToString() == "作废")
  2787. {
  2788. //ugr.Hidden = false;//显示
  2789. ugr.Appearance.ForeColor = Color.Red;
  2790. }
  2791. }
  2792. }
  2793. //else
  2794. //{
  2795. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  2796. // {
  2797. // if (ugr.Cells["VALIDFLAG"].Value.ToString() == "作废")
  2798. // {
  2799. // //ugr.Hidden = true;//隐藏
  2800. // }
  2801. // }
  2802. //}
  2803. }
  2804. /// <summary>
  2805. /// 物料分类维护审批流程
  2806. /// </summary>
  2807. private void setMatClassPross()
  2808. {
  2809. if (ulTreeMat.ActiveNode != null && ulTreeMat.ActiveNode.Key.Length==5)
  2810. {
  2811. frmPopMatClassPross frm = new frmPopMatClassPross(this.ob, ulTreeMat.ActiveNode.Key);
  2812. frm.StartPosition = FormStartPosition.Manual;//设置窗体初始位置由Location决定
  2813. frm.StartPosition = FormStartPosition.CenterParent;//设置窗体初始位置
  2814. frm.ShowDialog();
  2815. }
  2816. else
  2817. {
  2818. MessageUtil.ShowTips("请选择物料小类");
  2819. return;
  2820. }
  2821. }
  2822. private void txt_DELVRY_RANGE_TPE_ValueChanged(object sender, EventArgs e)
  2823. {
  2824. if (txt_DELVRY_RANGE_TPE.Value != null)
  2825. {
  2826. if (txt_DELVRY_RANGE_TPE.Value.ToString() == "1")//绝对值
  2827. {
  2828. label73.Visible = false;
  2829. label74.Visible = false;
  2830. }
  2831. else//百分比
  2832. {
  2833. label73.Visible = true;
  2834. label74.Visible = true;
  2835. }
  2836. }
  2837. }
  2838. private void txt_delivery_type_2_ValueChanged(object sender, EventArgs e)
  2839. {
  2840. if (txt_DELVRY_RANGE_TPE.Value != null)
  2841. {
  2842. if (txt_DELVRY_RANGE_TPE.Value.ToString() == "1")//绝对值
  2843. {
  2844. label81.Visible = false;
  2845. label82.Visible = false;
  2846. }
  2847. else//百分比
  2848. {
  2849. label81.Visible = true;
  2850. label82.Visible = true;
  2851. }
  2852. }
  2853. }
  2854. /// <summary>
  2855. /// 选择物料分类
  2856. /// </summary>
  2857. /// <param name="sender"></param>
  2858. /// <param name="e"></param>
  2859. private void txt_ItemArcCode_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2860. {
  2861. }
  2862. private void txt_ItemArcCodeName_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2863. {
  2864. frmPopMatClass frm = new frmPopMatClass(this.ob,"1");
  2865. frm.ShowDialog();
  2866. if (frm.Q_Ultnode != null)
  2867. {
  2868. txt_ItemArcCodeName.Text = frm.Q_Ultnode.Text;
  2869. txt_ItemArcCode.Text = frm.Q_Ultnode.Key;
  2870. }
  2871. }
  2872. /// <summary>
  2873. /// 复制实体类数据(源数据可以为任何类型,该方法只赋值属性名称相同的属性。)
  2874. /// </summary>
  2875. /// <typeparam name="T">实体类</typeparam>
  2876. /// <param name="srcObj">源对象</param>
  2877. public T CopyEntity<T>(object srcObj)
  2878. {
  2879. Type type1 = typeof(T);
  2880. T t = (T)type1.Assembly.CreateInstance(type1.FullName);
  2881. PropertyInfo[] props = srcObj.GetType().GetProperties();
  2882. foreach (PropertyInfo prop in props)
  2883. {
  2884. PropertyInfo pobj = type1.GetProperty(prop.Name);
  2885. if (pobj != null)
  2886. {
  2887. pobj.SetValue(t, prop.GetValue(srcObj, null), null);
  2888. }
  2889. }
  2890. T t1 = (T)typeof(T).Assembly.CreateInstance(typeof(T).FullName);
  2891. Type tp = t1.GetType();
  2892. PropertyInfo[] proInfo = srcObj.GetType().GetProperties();
  2893. foreach (PropertyInfo prop in proInfo)
  2894. {
  2895. PropertyInfo propObj = tp.GetProperty(prop.Name);
  2896. if (propObj != null)
  2897. {
  2898. propObj.SetValue(t1, prop.GetValue(srcObj, null), null);
  2899. }
  2900. }
  2901. try
  2902. {
  2903. T Desobj = (T)typeof(T).Assembly.CreateInstance(typeof(T).FullName);
  2904. PropertyInfo[] srcPropertyInfos = srcObj.GetType().GetProperties();
  2905. foreach (PropertyInfo srcPropertyInfo in srcPropertyInfos)
  2906. {
  2907. PropertyInfo DespropertyInfo = Desobj.GetType().GetProperty(srcPropertyInfo.Name);
  2908. if (DespropertyInfo == null) continue;
  2909. DespropertyInfo.SetValue(Desobj, srcPropertyInfo.GetValue(srcObj, null), null);
  2910. }
  2911. return Desobj;
  2912. }
  2913. catch (Exception ex)
  2914. {
  2915. throw;
  2916. }
  2917. }
  2918. }
  2919. }