FrmPurRequirePlanOld.cs 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106
  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;
  10. using Core.Mes.Client.Comm.Control;
  11. using Pur.Entity.configureEntity;
  12. using Infragistics.Win.UltraWinGrid;
  13. using System.Collections;
  14. using Pur.Entity.require_planEntiy;
  15. using Pur.configure;
  16. using Core.Mes.Client.Comm.Tool;
  17. using com.hnshituo.pur.vo;
  18. using Pur.Pop_upWindow;
  19. using Bpm;
  20. using Pur.Entity;
  21. using Infragistics.Win;
  22. using Core.Mes.Client.Comm.Server;
  23. using Infragistics.Win.UltraWinEditors;
  24. namespace Pur.require_plan
  25. {
  26. public partial class FrmPurRequirePlanOld : FrmPmsBase
  27. {
  28. public FrmPurRequirePlanOld()
  29. {
  30. InitializeComponent();
  31. }
  32. private void FrmPurRequirePlanOld_Load(object sender, EventArgs e)//Load
  33. {
  34. strCoustomInfo=this.CustomInfo == null ? "" : this.CustomInfo.ToString();
  35. //初始化查询区域信息
  36. ck_ctime.Checked = true;
  37. txtCreateTimeStart.Value = DateTime.Now.AddMonths(-2);
  38. txtCreateTimeEnd.Value = DateTime.Now.AddDays(2);
  39. //状态
  40. txt_Status.SelectedIndex = 0;
  41. Ck_IsJIT.Checked = false;
  42. txt_deliveryLocation.Enabled = false;
  43. //紧急程度
  44. cop_UrgencyType.SelectedIndex = 0;
  45. //审批流程
  46. txt_auditType.SelectedIndex = -1;
  47. txt_MRPERIODEND.Enabled = false;
  48. //加载计划类型数据
  49. DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob);
  50. if (strCoustomInfo == "1")//生产厂
  51. {
  52. comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122101')", false, "", "");
  53. txt_auditType.Visible = true;
  54. txt_auditType_lab.Visible = true;
  55. txt_itemAuditType_lab.Visible = true;
  56. txt_itemAuditType.Visible = true;
  57. }
  58. else if (strCoustomInfo == "2")//供应部
  59. {
  60. comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122103','122101')", false, "", "");
  61. this.ToolBarItemEnable(this, "DoReceive", false);
  62. this.ToolBarItemEnable(this, "Process", false);
  63. //ultraTabControl2.Tabs[1].Visible = false;
  64. txt_auditType.Visible = false;
  65. txt_auditType_lab.Visible = false;
  66. txt_itemAuditType_lab.Visible = false;
  67. txt_itemAuditType.Visible = false;
  68. }
  69. else//厂区
  70. {
  71. comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122104')", false, "", "");
  72. //this.ToolBarItemEnable(this, "Query", true);
  73. //this.ToolBarItemEnable(this, "Add", true);
  74. //this.ToolBarItemEnable(this, "Update", true);
  75. //this.ToolBarItemEnable(this, "Delete", true);
  76. //this.ToolBarItemEnable(this, "Revocation", true);
  77. //this.ToolBarItemEnable(this, "Submittal", true);
  78. //this.ToolBarItemEnable(this, "doExcel", true);
  79. this.ToolBarItemEnable(this, "DoReceive", false);
  80. this.ToolBarItemEnable(this, "Process", false);
  81. ultraTabControl2.Tabs[1].Visible = false;
  82. txt_auditType.Visible = true;
  83. txt_auditType_lab.Visible = true;
  84. txt_itemAuditType_lab.Visible = true;
  85. txt_itemAuditType.Visible = true;
  86. }
  87. //加载流程类型
  88. DataTable dt8 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "122601" }, this.ob);
  89. comm.FilComboboxAdd(txt_auditType, dt8, "baseCode", "baseName", "validflag NOT in ('0')", false, "", "");
  90. //加载数据
  91. GetPUR_REQUIRE_PLAN();
  92. ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
  93. ultraExpandableGroupBox2.Expanded = false;
  94. ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  95. ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  96. ultraGrid3.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  97. }
  98. //初始化数据
  99. string init_itemUomId="";//物料单位换算ID
  100. string init_itemStandardsId = "";//采购标准ID
  101. string init_itemAttrId = "";//物料属性编码
  102. string init_auditFlag = "";//审批标识
  103. string init_itemUnique = "";//物料唯一码
  104. string deliveryLocationCode="";//地点编码
  105. string init_itemAutitTypeId = "";//物料审批流程ID
  106. string PRICE_TYPE = "";
  107. private string m_szCurPath = ""; //启动路径
  108. string strCoustomInfo = "";
  109. #region toolbar工具栏事件
  110. /// <summary>
  111. /// toolbar
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="ToolbarKey"></param>
  115. public override void ToolBar_Click(object sender, string ToolbarKey)//菜单toolbar按钮
  116. {
  117. switch (ToolbarKey)
  118. {
  119. case "Query":
  120. GetPUR_REQUIRE_PLAN();
  121. break;
  122. case "Add":
  123. AddPUR_REQUIRE_PLAN();
  124. break;
  125. case "Update":
  126. UpdPUR_REQUIRE_PLAN();
  127. break;
  128. case "Delete":
  129. DelPUR_REQUIRE_PLAN();
  130. break;
  131. case "Submittal":
  132. SubPUR_REQUIRE_PLAN();
  133. break;
  134. case "Revocation":
  135. RevPUR_REQUIRE_PLAN();
  136. break;
  137. case "DoReceive":
  138. ReceivePUR_REQUIRE_PLAN();
  139. break;
  140. case "Process":
  141. Process();
  142. break;
  143. case "doExcel":
  144. doExcel();
  145. break;
  146. }
  147. }
  148. /// <summary>
  149. /// 撤销提报
  150. /// </summary>
  151. private void RevPUR_REQUIRE_PLAN()//提报撤销
  152. {
  153. if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1])
  154. {
  155. MessageUtil.ShowTips("未发现可撤销的需求计划头!");
  156. return;
  157. }
  158. UltraGridRow uge = ultraGrid1.ActiveRow;
  159. if (uge == null)
  160. {
  161. MessageUtil.ShowTips("请选择可操作的需求计划头!");
  162. return;
  163. }
  164. String mrId = uge.Cells["MrId"].Value.ToString();
  165. if ( mrId == "")
  166. {
  167. MessageUtil.ShowTips("请选择可操作的需求计划头");
  168. return;
  169. }
  170. //头是否处于可撤回状态
  171. if (testReqMStatus(mrId, 3) == false)
  172. {
  173. return;
  174. }
  175. ArrayList list = new ArrayList();
  176. RequirePlanM ReqM = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
  177. if (strCoustomInfo != "2")
  178. {
  179. if (ReqM.Status == "-1")
  180. {
  181. ReqM.Status = "-2";
  182. }
  183. else
  184. {
  185. ReqM.Status = "1";
  186. }
  187. }
  188. else//供应部直接撤回(直接有已审批3-》1)
  189. {
  190. ReqM.Status = "31";
  191. }
  192. ReqM.UpdateUserid = UserInfo.GetUserID();
  193. if (MessageUtil.ShowYesNoAndQuestion("确定撤回该需求计划头?") == DialogResult.No)
  194. {
  195. return;
  196. }
  197. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "submit", new object[] { ReqM });
  198. if (rt.Resultcode != 0)
  199. {
  200. MessageUtil.ShowTips("撤回失败!" + rt.Resultmsg);
  201. return;
  202. }
  203. MessageUtil.ShowTips("撤回成功!");
  204. GetPUR_REQUIRE_PLAN();
  205. comm.doActiveSelRow(ultraGrid1, "MrId", ReqM.MrId);
  206. }
  207. /// <summary>
  208. /// 提报
  209. /// </summary>
  210. private void SubPUR_REQUIRE_PLAN()//提报需求
  211. {
  212. if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0])
  213. {
  214. UltraGridRow uge = ultraGrid1.ActiveRow;
  215. if (uge == null)
  216. {
  217. MessageUtil.ShowTips("请选择需操作的需求计划头!");
  218. return;
  219. }
  220. String mrId = uge.Cells["MrId"].Value.ToString().Trim();
  221. if (mrId == "")
  222. {
  223. MessageUtil.ShowTips("请选择需操作的需求计划头!");
  224. return;
  225. }
  226. //验证是否可以提报
  227. if (testReqMStatus(mrId, 2) == false)
  228. {
  229. return;
  230. }
  231. RequirePlanM ReqM = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
  232. if (strCoustomInfo != "2")
  233. {
  234. if (ReqM.Status == "-2")
  235. {
  236. ReqM.Status = "-1";//子计划提交
  237. }
  238. else
  239. {
  240. ReqM.Status = "2";//主计划提报
  241. }
  242. }
  243. else
  244. {
  245. ReqM.Status = "13";//供应部默认直接审批并接受(由1知道到3)
  246. }
  247. ReqM.UpdateUserid = UserInfo.GetUserID();
  248. if (MessageUtil.ShowYesNoAndQuestion("确定提报该需求计划头?") == DialogResult.No)
  249. {
  250. return;
  251. }
  252. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "submit", new object[] { ReqM});
  253. if (rt.Resultcode != 0)
  254. {
  255. MessageUtil.ShowTips("提报失败!" + rt.Resultmsg);
  256. return;
  257. }
  258. MessageUtil.ShowTips("提报成功!");
  259. GetPUR_REQUIRE_PLAN();
  260. comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
  261. }
  262. else
  263. {
  264. UltraGridRow uge = ultraGrid3.ActiveRow;
  265. if (uge == null)
  266. {
  267. MessageUtil.ShowTips("未选择需提报的退回需求计划行!");
  268. return;
  269. }
  270. String strMrLineId = uge.Cells["MrLineId"].Value.ToString().Trim();
  271. if (strMrLineId=="")
  272. {
  273. MessageUtil.ShowWarning("未获取到该需求计划行的需求计划行号!");
  274. return;
  275. }
  276. if (testReqCStatus(strMrLineId, 2) == false)
  277. {
  278. return;
  279. }
  280. ArrayList list = new ArrayList();
  281. RequirePlanD ReqD = new RequirePlanD();
  282. ReqD.MrLineId = strMrLineId;
  283. ReqD.FlagGeneratedPurPlan = "1";
  284. ReqD.UpdateName = UserInfo.GetUserName();
  285. ReqD.UpdateUserid = UserInfo.GetUserID();
  286. ReqD.UpdateTime = DateTime.Now;
  287. list.Add(ReqD);
  288. if (MessageUtil.ShowYesNoAndQuestion("确定重新提报?") == DialogResult.No)
  289. {
  290. return;
  291. }
  292. CoreResult rt = new CoreResult();
  293. if (strCoustomInfo == "2")
  294. {
  295. rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "32" });//供应部直接提报(3—>2)
  296. }
  297. else
  298. {
  299. rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "4" });//生成厂提报
  300. }
  301. if (rt.Resultcode != 0)
  302. {
  303. MessageUtil.ShowTips("提报失败!" + rt.Resultmsg);
  304. return;
  305. }
  306. MessageUtil.ShowTips("提报成功!");
  307. GetPUR_REQUIRE_PLAN();
  308. comm.doActiveSelRow(ultraGrid3, "MrLineId", ReqD.MrLineId);
  309. }
  310. }
  311. /// <summary>
  312. /// 删除需求
  313. /// </summary>
  314. private void DelPUR_REQUIRE_PLAN()//删除需求
  315. {
  316. //删除非退回需求
  317. if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0])
  318. {
  319. UltraGridRow uge = ultraGrid1.ActiveRow;
  320. if (uge == null)
  321. {
  322. MessageUtil.ShowTips("请选择需要操作的需求计划头!");
  323. return;
  324. }
  325. String mrId=uge.Cells["MrId"].Value.ToString().Trim();
  326. if (String.IsNullOrEmpty(mrId))
  327. {
  328. MessageUtil.ShowTips("该需求计划头号为空!");
  329. return;
  330. }
  331. //删除头
  332. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
  333. {
  334. //验证是否有权利删除头
  335. if (testReqMStatus(mrId,1) == false)
  336. {
  337. return;
  338. }
  339. ArrayList list = new ArrayList();
  340. RequirePlanM ReqM = new RequirePlanM();
  341. ReqM.MrId = mrId;
  342. ReqM.Validflag = "0";
  343. ReqM.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  344. ReqM.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  345. ReqM.DeleteTime = DateTime.Now;
  346. list.Add(ReqM);
  347. if (MessageUtil.ShowYesNoAndQuestion("确定删除该需求计划头?") == DialogResult.No)
  348. {
  349. return;
  350. }
  351. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doDelete_batch", new object[] { list, strCoustomInfo });
  352. if (rt.Resultcode != 0)
  353. {
  354. MessageUtil.ShowTips("删除失败!" + rt.Resultmsg);
  355. return;
  356. }
  357. MessageUtil.ShowTips("删除成功!");
  358. GetPUR_REQUIRE_PLAN();
  359. }
  360. //删除行
  361. else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
  362. {
  363. UltraGridRow uRe = ultraGrid2.ActiveRow;
  364. if (uRe == null)
  365. {
  366. MessageUtil.ShowTips("请选择需删除的需求计划行!");
  367. return;
  368. }
  369. string strMrLineId = uRe.Cells["MrLineId"].Value.ToString().Trim();
  370. if (String.IsNullOrEmpty(strMrLineId))
  371. {
  372. MessageUtil.ShowTips("未获取到该需求计划行号!");
  373. return;
  374. }
  375. //验证是否有权利删改行
  376. if (testReqCStatus(strMrLineId,1) == false)
  377. {
  378. return;
  379. }
  380. RequirePlanD ReqD = new RequirePlanD();
  381. ReqD.MrLineId = strMrLineId;
  382. ReqD.Validflag = "0";
  383. ReqD.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  384. ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  385. ReqD.DeleteTime = DateTime.Now;
  386. if (MessageUtil.ShowYesNoAndQuestion("是否确定删除该需求计划行?") != DialogResult.Yes)
  387. {
  388. return;
  389. }
  390. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate", new object[] { ReqD });
  391. if (rt.Resultcode != 0)
  392. {
  393. MessageUtil.ShowTips("删除失败!" + rt.Resultmsg);
  394. return;
  395. }
  396. Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("删除成功!");
  397. GetPUR_REQUIRE_PLAN();
  398. comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
  399. String YY = mrId;
  400. RequirePlanD rpd1 = new RequirePlanD();
  401. rpd1.MrLineId = YY;
  402. rpd1.Validflag = "1";
  403. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
  404. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  405. clearkongjian();
  406. }
  407. }
  408. //删除退回需求行
  409. else
  410. {
  411. UltraGridRow uRe = ultraGrid3.ActiveRow;
  412. if (uRe == null)
  413. {
  414. MessageUtil.ShowTips("请选择需作废的退回需求计划行!");
  415. return;
  416. }
  417. String strMrLineId = uRe.Cells["MrLineId"].Value.ToString();
  418. if (String.IsNullOrEmpty(strMrLineId))
  419. {
  420. MessageUtil.ShowTips("需求计划行号为空!");
  421. return;
  422. }
  423. //判断是否有权力修改
  424. if (testReqCStatus(strMrLineId, 2) == false)
  425. {
  426. return;
  427. }
  428. ArrayList list = new ArrayList();
  429. RequirePlanD ReqD = new RequirePlanD();
  430. ReqD.MrLineId = strMrLineId;
  431. ReqD.FlagGeneratedPurPlan = "9";
  432. ReqD.UpdateName = UserInfo.GetUserName();
  433. ReqD.UpdateUserid = UserInfo.GetUserID();
  434. ReqD.UpdateTime = DateTime.Now;
  435. list.Add(ReqD);
  436. if (MessageUtil.ShowYesNoAndQuestion("确定作废该退回的需求计划行?") == DialogResult.No)
  437. {
  438. return;
  439. }
  440. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "5" });
  441. if (rt.Resultcode != 0)
  442. {
  443. MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
  444. return;
  445. }
  446. MessageUtil.ShowTips("操作成功!");
  447. GetPUR_REQUIRE_PLAN();
  448. }
  449. }
  450. /// <summary>
  451. /// 修改
  452. /// </summary>
  453. private void UpdPUR_REQUIRE_PLAN()//更新需求
  454. {
  455. //修改非退回需求
  456. if (ultraTabControl2.SelectedTab.Text == ultraTabControl2.Tabs[0].Text)
  457. {
  458. UltraGridRow uge = ultraGrid1.ActiveRow;
  459. String mrId = uge.Cells["mrId"].Value.ToString();
  460. if (uge == null || mrId=="")
  461. {
  462. MessageUtil.ShowTips("未选择需求订单");
  463. return;
  464. }
  465. ////判断是否处于可增删改的状态
  466. //if (!uge.Cells["Status"].Value.Equals("待编制") && !uge.Cells["Status"].Value.Equals("待提报") && !uge.Cells["Status"].Value.Equals("审批不通过"))
  467. //{
  468. // MessageUtil.ShowWarning("需求计划头【" + uge.Cells["MrId"].Value.ToString() + "】为已编制、审批中或已审批状态之一,无权限增删改,或请刷新后再操作!");
  469. // return;
  470. //}
  471. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
  472. {
  473. //验证是否有权力修改头
  474. if (testReqMStatus(mrId, 4) == false)
  475. {
  476. return;
  477. }
  478. //验证输入的数据
  479. if (testReqM() == false)
  480. {
  481. return;
  482. }
  483. RequirePlanM ReqM = new RequirePlanM();
  484. ReqM.UpdateName = UserInfo.GetUserName();
  485. ReqM.UpdateUserid = UserInfo.GetUserID();
  486. ReqM.UpdateTime = DateTime.Now;
  487. ReqM.MrId = mrId;
  488. ReqM.ReqOrgName = UserInfo.GetDepartment();//申请者机构名称
  489. ReqM.ReqOrgId = UserInfo.GetDeptid();//申请者机构ID
  490. if (txt_MRPERIODEND.Enabled == false)
  491. {
  492. ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  493. }
  494. else
  495. {
  496. ReqM.MrPeriodEnd = Convert.ToDateTime(txt_MRPERIODEND.Value);
  497. }
  498. ReqM.UrgencyType = txt_URGENCYTYPE.Value.ToString().Trim().Trim();
  499. ReqM.RequireType = txt_RequeType.Value.ToString().Trim();
  500. ReqM.TenantId = strCoustomInfo != "2" ? txt_auditType.Value.ToString().Trim() : null;
  501. ReqM.TenantName = strCoustomInfo != "2" ? txt_auditType.Text.Trim() : null;
  502. if (MessageUtil.ShowYesNoAndQuestion("确定要修改该需求计划头?") == DialogResult.No)
  503. {
  504. return;
  505. }
  506. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doUpdate", new object[] { ReqM });
  507. if (rt.Resultcode != 0)
  508. {
  509. MessageUtil.ShowTips("修改失败!" + rt.Resultmsg);
  510. return;
  511. }
  512. MessageUtil.ShowTips("修改成功!");
  513. GetPUR_REQUIRE_PLAN();
  514. comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
  515. clearkongjian1();
  516. }
  517. else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])//需求计划行修改
  518. {
  519. UltraGridRow uged = ultraGrid2.ActiveRow;
  520. if (uged == null)
  521. {
  522. MessageUtil.ShowWarning("未选择需求计划行");
  523. return;
  524. }
  525. String strMrLineId = uged.GetCellValue("MrLineId").ToString().Trim();
  526. if (String.IsNullOrEmpty(strMrLineId) || String.IsNullOrEmpty(mrId))
  527. {
  528. MessageUtil.ShowTips("未获取到需求计划号或者需求计划行号!");
  529. return;
  530. }
  531. //判断是否有权力进行操作行
  532. if (testReqCStatus(strMrLineId, 1) == false)
  533. {
  534. return;
  535. }
  536. if (uged.GetCellValue("itemCode") == null)
  537. {
  538. MessageUtil.ShowWarning("需求计划行物料编码为空物");
  539. return;
  540. }
  541. if (testReqC() == false)
  542. {
  543. return;
  544. }
  545. RequirePlanD ReqD = new RequirePlanD();
  546. ReqD.MrId = mrId;
  547. ReqD.Validflag = "1";
  548. ReqD.ItemUnique = init_itemUnique;
  549. //2016年2月28新增leitao
  550. if (Ck_IsJIT.Checked)
  551. {
  552. ReqD.DeliveryLocationFlag = "1";
  553. ReqD.DeliveryLocation = txt_deliveryLocation.Text;
  554. ReqD.DeliveryLocationCode = deliveryLocationCode;
  555. if (ReqD.DeliveryLocationCode == "")
  556. {
  557. MessageUtil.ShowTips("JIT送货的地址信息不能为空");
  558. txt_deliveryLocation.Focus();
  559. return;
  560. }
  561. }
  562. else
  563. {
  564. ReqD.DeliveryLocationFlag = "0";
  565. ReqD.DeliveryLocation = "";
  566. ReqD.DeliveryLocationCode = "";
  567. }
  568. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD });
  569. for(int ii=0;ii<dt2.Rows.Count;ii++)
  570. {
  571. if (dt2.Rows[ii]["mrLIneId"].ToString().Trim() != txt_MRLINEID.Text.ToString().Trim())
  572. {
  573. MessageUtil.ShowWarning("已存在相同需求计划行【" + dt2.Rows[ii]["MrLineId"].ToString() + "】");
  574. return;
  575. }
  576. }
  577. ReqD.MrLineId = txt_MRLINEID.Text.ToString().Trim();
  578. ReqD.ItemCode = txt_ItemCode.Text.ToString().Trim();
  579. ReqD.ItemName = txt_ItemName.Text.ToString().Trim();
  580. ReqD.Remark = txt_Remark.Text.ToString().Trim();
  581. ReqD.ItemAttr = txt_item_Attr.Text.ToString().Trim();//属性名称
  582. if (txt_BUGPRICE.Text != "")
  583. {
  584. ReqD.BugPrice = Convert.ToDouble(txt_BUGPRICE.Text);
  585. }
  586. double dbItemUomConefficien;
  587. if (txt_ItemUom.Text.ToString().Trim() == "" || txt_WEIGHTUNIT.Text.ToString().Trim() == "" || !Double.TryParse(txt_ItemUomConefficient.Value.ToString().ToString().Trim(), out dbItemUomConefficien))
  588. {
  589. MessageUtil.ShowTips("采购单位、库存单位、单位转化系数都不能为空");
  590. return;
  591. }
  592. ReqD.ItemUom = txt_ItemUom.Text.ToString().Trim();//采购单位
  593. ReqD.WeightUnit = txt_WEIGHTUNIT.Text.ToString().Trim();//库存单位
  594. ReqD.ItemUomConefficient = dbItemUomConefficien;//转化系数
  595. ReqD.Qty = Convert.ToDouble(txt_QTY.Value);
  596. ReqD.BudgetAmt = Convert.ToDouble(txt_BUDGETAMT.Text);//消耗预算
  597. ReqD.UpdateName = UserInfo.GetUserName();
  598. ReqD.UpdateUserid = UserInfo.GetUserID();
  599. ReqD.UpdateTime = DateTime.Now;
  600. ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
  601. ReqD.ItemStandardsCode = txt_itemStandardsCode.Text.ToString().Trim();
  602. ReqD.ItemStandardsId = init_itemStandardsId;
  603. ReqD.ItemUomId = init_itemUomId;
  604. ReqD.ItemAttrId = init_itemAttrId;
  605. ReqD.AuditFlag = "0";
  606. ReqD.DeleteUserid = UserInfo.GetDeptid();
  607. if (MessageUtil.ShowYesNoAndQuestion("确定修改该需求计划行?") == DialogResult.No)
  608. {
  609. return;
  610. }
  611. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_D", new object[] { ReqD });
  612. if (rt.Resultcode != 0)
  613. {
  614. MessageUtil.ShowTips("修改失败! " + rt.Resultmsg);
  615. return;
  616. }
  617. Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("修改成功!");
  618. GetPUR_REQUIRE_PLAN();
  619. comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
  620. comm.doActiveSelRow(ultraGrid2, "MrLineId", ReqD.MrLineId);
  621. RequirePlanD rpd1 = new RequirePlanD();
  622. rpd1.MrLineId = mrId;
  623. rpd1.Validflag = "1";
  624. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
  625. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  626. clearkongjian();
  627. }
  628. }
  629. //退回需求计划行修改
  630. else
  631. {
  632. UltraGridRow uged = ultraGrid3.ActiveRow;
  633. if (uged == null)
  634. {
  635. MessageUtil.ShowWarning("未选择退回需求计划行");
  636. return;
  637. }
  638. String strMrlineId = uged.GetCellValue("MrLineId").ToString().Trim();
  639. String strMrId = uged.GetCellValue("MrId").ToString().Trim();
  640. if(String.IsNullOrEmpty(strMrlineId)||String.IsNullOrEmpty(strMrId))
  641. {
  642. MessageUtil.ShowTips("未获取到需求计划号或者需求计划行号!");
  643. return;
  644. }
  645. //判断是否有权力修改
  646. //判断是否有权力进行操作行
  647. if (testReqCStatus(strMrlineId, 2) == false)
  648. {
  649. return;
  650. }
  651. if (testReqC() == false)
  652. {
  653. return;
  654. }
  655. if (uged.GetCellValue("itemCode") == null)
  656. {
  657. MessageUtil.ShowWarning("需求计划行物料编码为空物");
  658. return;
  659. }
  660. if (uged.GetCellValue("itemCode").ToString().Trim() != txt_ItemCode.Value.ToString().Trim())
  661. {
  662. MessageUtil.ShowWarning("退回物料不予许修改需求物料编码");
  663. return;
  664. }
  665. RequirePlanD ReqD = new RequirePlanD();
  666. ReqD.MrId = strMrId;
  667. ReqD.Validflag = "1";
  668. ReqD.ItemUnique = init_itemUnique;
  669. //2016年2月28新增leitao
  670. if (Ck_IsJIT.Checked)
  671. {
  672. ReqD.DeliveryLocationFlag = "1";
  673. ReqD.DeliveryLocation = txt_deliveryLocation.Text;
  674. ReqD.DeliveryLocationCode = deliveryLocationCode;
  675. if (ReqD.DeliveryLocationCode == "")
  676. {
  677. MessageUtil.ShowTips("JIT送货的地址信息不能为空");
  678. txt_deliveryLocation.Focus();
  679. return;
  680. }
  681. }
  682. else
  683. {
  684. ReqD.DeliveryLocationFlag = "0";
  685. ReqD.DeliveryLocation = "";
  686. ReqD.DeliveryLocationCode = "";
  687. }
  688. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD });
  689. for (int ii = 0; ii < dt2.Rows.Count; ii++)
  690. {
  691. if (dt2.Rows[ii]["mrLIneId"].ToString().Trim() != strMrlineId)
  692. {
  693. MessageUtil.ShowWarning("已存在相同需求计划行【" + dt2.Rows[ii]["MrLineId"].ToString() + "】");
  694. return;
  695. }
  696. }
  697. ReqD.MrLineId = strMrlineId;
  698. ReqD.ItemCode = txt_ItemCode.Text.Trim();
  699. ReqD.ItemName = txt_ItemName.Text.Trim();
  700. ReqD.Remark = txt_Remark.Text.Trim();
  701. ReqD.ItemAttr = txt_item_Attr.Text.Trim();//属性名称
  702. if (txt_BUGPRICE.Text.Trim() != "")
  703. {
  704. ReqD.BugPrice = Convert.ToDouble(txt_BUGPRICE.Text.Trim());
  705. }
  706. double dbItemUomConefficien;
  707. if (txt_ItemUom.Text.ToString().Trim() == "" || txt_WEIGHTUNIT.Text.ToString().Trim() == "" || !Double.TryParse(txt_ItemUomConefficient.Value.ToString().ToString().Trim(), out dbItemUomConefficien))
  708. {
  709. MessageUtil.ShowTips("采购单位、库存单位、单位转化系数都不能为空!");
  710. return;
  711. }
  712. ReqD.ItemUom = txt_ItemUom.Text.ToString().Trim();//采购单位
  713. ReqD.WeightUnit = txt_WEIGHTUNIT.Text.ToString().Trim();//库存单位
  714. ReqD.ItemUomConefficient = dbItemUomConefficien;//转化系数
  715. ReqD.Qty = Convert.ToDouble(txt_QTY.Value);
  716. ReqD.BudgetAmt = Convert.ToDouble(txt_BUDGETAMT.Text);
  717. ReqD.UpdateName = UserInfo.GetUserName();
  718. ReqD.UpdateUserid = UserInfo.GetUserID();
  719. ReqD.UpdateTime = DateTime.Now;
  720. ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
  721. ReqD.ItemStandardsCode = txt_itemStandardsCode.Text.ToString().Trim();
  722. ReqD.ItemStandardsId = init_itemStandardsId;
  723. ReqD.ItemUomId = init_itemUomId;
  724. ReqD.ItemAttrId = init_itemAttrId;
  725. ReqD.AuditFlag = "0";
  726. //this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "update", new object[] { ReqD });
  727. if (MessageUtil.ShowYesNoAndQuestion("确定修改该需求计划行(退回):" + strMrlineId + "?") == DialogResult.No)
  728. {
  729. return;
  730. }
  731. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_D", new object[] { ReqD });
  732. if (rt.Resultcode != 0)
  733. {
  734. MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
  735. return;
  736. }
  737. MessageUtil.ShowTips("操作成功!");
  738. GetPUR_REQUIRE_PLAN();
  739. comm.doActiveSelRow(ultraGrid3, "MrLineId", ReqD.MrLineId);
  740. clearkongjian();
  741. }
  742. }
  743. /// <summary>
  744. /// 新增
  745. /// </summary>
  746. private void AddPUR_REQUIRE_PLAN()//新增需求
  747. {
  748. //退回标签页不允许新增
  749. if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1])
  750. {
  751. MessageUtil.ShowTips("未发现可新增项");
  752. return;
  753. }
  754. UltraGridRow uge = ultraGrid1.ActiveRow;
  755. //需求头标签页可以新增
  756. try
  757. {
  758. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])//新增头信息
  759. {
  760. if (testReqM() == false)
  761. {
  762. return;
  763. }
  764. RequirePlanM ReqM = new RequirePlanM();
  765. ReqM.CreateName = UserInfo.GetUserName();
  766. ReqM.CreateUserid = UserInfo.GetUserID();
  767. ReqM.CreateTime = DateTime.Now;
  768. if (txt_MRPERIODEND.Enabled == false)
  769. {
  770. ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  771. }
  772. else
  773. {
  774. ReqM.MrPeriodEnd = Convert.ToDateTime(txt_MRPERIODEND.Value);
  775. }
  776. ReqM.UrgencyType = txt_URGENCYTYPE.Value.ToString();
  777. ReqM.ReqOrgName = UserInfo.GetDepartment();//申请者机构名称
  778. ReqM.ReqOrgId = UserInfo.GetDeptid();//申请者机构ID
  779. ReqM.Validflag = "1";
  780. ReqM.RequireType = txt_RequeType.Value.ToString();
  781. ReqM.Status = "1";
  782. ReqM.TenantId = strCoustomInfo!="2"?txt_auditType.Value.ToString().Trim():null;
  783. ReqM.TenantName = strCoustomInfo!= "2" ? txt_auditType.Text.Trim() : null;
  784. if (ReqM.RequireType == "122104")
  785. {
  786. ReqM.Status = "-2";//子计划
  787. }
  788. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "insert_id", new object[] { ReqM, strCoustomInfo});
  789. if (crt.Resultcode != 0)
  790. {
  791. MessageUtil.ShowTips("新增头失败! " + crt.Resultmsg);
  792. return;
  793. }
  794. MessageUtil.ShowTips("操作成功! 新增头:" + crt.Resultmsg);
  795. GetPUR_REQUIRE_PLAN();
  796. comm.doActiveSelRow(ultraGrid1, "MrId", crt.Resultmsg);
  797. clearkongjian1();
  798. }
  799. else if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[1].Text)//新增需求行信息
  800. {
  801. String strMrId = uge.Cells["mrId"].Value.ToString();
  802. if (uge == null || strMrId == "")
  803. {
  804. MessageUtil.ShowTips("请选择可操作的需求计划头");
  805. }
  806. if (testReqC() == false)
  807. {
  808. return;
  809. }
  810. //判断是否有权力新增
  811. if (testReqMStatus(strMrId, 1) == false)
  812. {
  813. return;
  814. }
  815. //是否新增了相同的物料
  816. RequirePlanD ReqD = new RequirePlanD();
  817. ReqD.MrId = strMrId;
  818. ReqD.Validflag = "1";
  819. ReqD.ItemUnique = init_itemUnique;
  820. //2016年2月28新增leitao
  821. if (Ck_IsJIT.Checked)
  822. {
  823. ReqD.DeliveryLocationFlag = "1";
  824. ReqD.DeliveryLocation = txt_deliveryLocation.Text;
  825. ReqD.DeliveryLocationCode = deliveryLocationCode;
  826. if (ReqD.DeliveryLocationCode == "")
  827. {
  828. MessageUtil.ShowTips("JIT送货的地址信息不能为空");
  829. txt_deliveryLocation.Focus();
  830. return;
  831. }
  832. }
  833. else
  834. {
  835. ReqD.DeliveryLocationFlag = "0";
  836. ReqD.DeliveryLocation = "";
  837. ReqD.DeliveryLocationCode = "";
  838. }
  839. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD });
  840. if (dt2.Rows.Count>0)
  841. {
  842. MessageUtil.ShowWarning("已存在相同需求计划行【"+dt2.Rows[0]["MrLineId"].ToString() + "】");
  843. return;
  844. }
  845. ReqD.ItemCode = txt_ItemCode.Text;//物料编码
  846. ReqD.ItemName = txt_ItemName.Text.Trim();//物料名称
  847. ReqD.Remark = txt_Remark.Text;//备注
  848. ReqD.BugPrice = Convert.ToDouble(txt_BUGPRICE.Text);//预算价
  849. ReqD.ItemAttr = txt_item_Attr.Text;//属性名称
  850. double dbItemUomConefficien;
  851. if (txt_ItemUom.Text.ToString().Trim() == "" || txt_WEIGHTUNIT.Text.ToString().Trim() == "" || !Double.TryParse(txt_ItemUomConefficient.Value.ToString().ToString().Trim(), out dbItemUomConefficien))
  852. {
  853. MessageUtil.ShowTips("采购单位、库存单位、单位转化系数都不能为空");
  854. return;
  855. }
  856. ReqD.ItemUom = txt_ItemUom.Text.ToString().Trim();//采购单位
  857. ReqD.WeightUnit =txt_WEIGHTUNIT.Text.ToString().Trim();//库存单位
  858. ReqD.ItemUomConefficient = dbItemUomConefficien;//转化系数
  859. ReqD.Validflag = "1";
  860. ReqD.Qty = Convert.ToDouble(txt_QTY.Value);
  861. ReqD.BudgetAmt = Convert.ToDouble(txt_BUDGETAMT.Text);//消耗预算
  862. ReqD.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  863. ReqD.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  864. ReqD.CreateTime = DateTime.Now;
  865. ReqD.FlagGeneratedPurPlan = "1";//默认未接受
  866. ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
  867. ReqD.ItemStandardsCode = txt_itemStandardsCode.Text.ToString().Trim();
  868. ReqD.ItemStandardsId = init_itemStandardsId;
  869. ReqD.ItemUomId = init_itemUomId;
  870. ReqD.ItemAttrId = init_itemAttrId;
  871. ReqD.AuditFlag = "";
  872. ReqD.DeleteUserid = UserInfo.GetDeptid();//部门ID
  873. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doInsert_D", new object[] { ReqD });
  874. if (rt.Resultcode != 0)
  875. {
  876. MessageUtil.ShowTips("新增失败!" + rt.Resultmsg);
  877. return;
  878. }
  879. MessageUtil.ShowTips("新增行信息成功!");
  880. GetPUR_REQUIRE_PLAN();
  881. comm.doActiveSelRow(ultraGrid1, "MrId", strMrId);
  882. String YY = strMrId;
  883. RequirePlanD rpd1 = new RequirePlanD();
  884. rpd1.MrLineId = YY;
  885. rpd1.Validflag = "1";
  886. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
  887. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  888. comm.doActiveSelRow(ultraGrid2, "MrLineId", rt.Resultmsg);
  889. clearkongjian();
  890. }
  891. }
  892. catch (Exception e)
  893. {
  894. MessageUtil.ShowTips("新增失败!" + e);
  895. return;
  896. }
  897. }
  898. /// <summary>
  899. /// 导出Excel
  900. /// </summary>
  901. private void doExcel()// 导出Excel
  902. {
  903. try
  904. {
  905. this.Cursor = Cursors.Default;
  906. if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0])
  907. {
  908. if (ultraGrid1.ActiveRow == null)
  909. {
  910. MessageUtil.ShowTips("请选择需导出明细的汇总需求计划!");
  911. return;
  912. }
  913. //获取导出的采购计划行表
  914. ArrayList alUltraGrid = new ArrayList();
  915. alUltraGrid.Add(ultraGrid2);
  916. ArrayList alSheeft = new ArrayList();
  917. alSheeft.Add("物料明细");
  918. if (ultraGrid2.Rows.Count > 0)
  919. {
  920. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "需求计划[" + ultraGrid1.ActiveRow.GetCellValue("mrId") + "]明细表");//导出excel
  921. }
  922. else
  923. {
  924. MessageUtil.ShowTips("需求计划:" + ultraGrid1.ActiveRow.GetCellValue("mrId") + "无可导出明细!");
  925. }
  926. }
  927. else
  928. {
  929. ArrayList alUltraGrid = new ArrayList();
  930. alUltraGrid.Add(ultraGrid3);
  931. ArrayList alSheeft = new ArrayList();
  932. alSheeft.Add("物料明细");
  933. if (ultraGrid3.Rows.Count > 0)
  934. {
  935. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "退回需求行明细表");//导出excel
  936. }
  937. else
  938. {
  939. MessageUtil.ShowTips("无可导出退回需求计划行明细!");
  940. }
  941. }
  942. }
  943. catch (Exception e)
  944. {
  945. MessageUtil.ShowTips("导出失败" + e.Message);
  946. }
  947. finally
  948. {
  949. this.Cursor = Cursors.Default;
  950. }
  951. }
  952. /// <summary>
  953. /// 查询
  954. /// </summary>
  955. private void GetPUR_REQUIRE_PLAN()//刷新
  956. {
  957. clearkongjian();
  958. clearkongjian1();
  959. dataTable1.Clear();
  960. dataTable2.Clear();
  961. dataTable3.Clear();
  962. try
  963. {
  964. this.Cursor = Cursors.WaitCursor;
  965. //string str = Core.Mes.Client.Comm.Tool.EntityHelper.StrGetControlvalueFromMod("tg_128_st", "cxuser", "cxuser", "PUR_REQUIRE_PLAN_M", "suppone_entity", new string[] { "txt_" }, true, txt_MRID.Parent);
  966. //str = Core.Mes.Client.Comm.Tool.EntityHelper.StrGetControlvalueFromMod("tg_128_st", "cxuser", "cxuser", "PUR_REQUIRE_PLAN_D", "suppone_entity", new string[] { "txt_" }, true, txt_MRLINEID.Parent);
  967. RequirePlanM RqPM = new RequirePlanM();
  968. RequirePlanD rpd = new RequirePlanD();
  969. if (txt_Status.Value != null)
  970. {
  971. RqPM.Status = txt_Status.Value.ToString();
  972. }
  973. if (ultraTextEditor1.Text != null)
  974. {
  975. RqPM.MrId = ultraTextEditor1.Text;
  976. rpd.MrId = ultraTextEditor1.Text;
  977. }
  978. if (cop_UrgencyType.Value != null)
  979. {
  980. RqPM.UrgencyType = cop_UrgencyType.Value.ToString();
  981. }
  982. if (ck_ctime.Checked==true)
  983. {
  984. if (txtCreateTimeStart.Text != "")
  985. {
  986. RqPM.MrPeriodStart = Convert.ToDateTime(txtCreateTimeStart.Value);
  987. rpd.CreateTime = Convert.ToDateTime(txtCreateTimeStart.Value);
  988. }
  989. if (txtCreateTimeEnd.Text != "")
  990. {
  991. RqPM.MrPeriodEnd = Convert.ToDateTime(txtCreateTimeEnd.Value);
  992. rpd.UpdateTime = Convert.ToDateTime(txtCreateTimeEnd.Value);
  993. }
  994. }
  995. //生成厂
  996. if (strCoustomInfo == "1")
  997. {
  998. RqPM.DeleteName = "1";
  999. rpd.DeleteName = "1";
  1000. }
  1001. //供应部
  1002. else if (strCoustomInfo == "2")
  1003. {
  1004. RqPM.DeleteName = "0";
  1005. rpd.DeleteName = "0";
  1006. }
  1007. else
  1008. {
  1009. RqPM.DeleteName = "3";
  1010. rpd.DeleteName = "3";
  1011. }
  1012. //RqPM.Status = txt_Status.Value.ToString();
  1013. //RqPM.MrId = ultraTextEditor1.Text;
  1014. //RqPM.UrgencyType = ultraComboEditor2.Value.ToString();
  1015. //RqPM.MrPeriodStart = Convert.ToDateTime(txtMrPeriodStart.Value);
  1016. //RqPM.MrPeriodEnd = Convert.ToDateTime(txtMrPeriodEnd.Value);
  1017. RqPM.Validflag = "1";
  1018. RqPM.ValidDataPurviewIds = this.ValidDataPurviewIds;
  1019. RqPM.OperatorUserId = UserInfo.GetUserID();
  1020. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_status", new object[] { RqPM });
  1021. foreach (DataRow row in dt.Rows)
  1022. {
  1023. row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM");
  1024. }
  1025. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  1026. GridHelper.RefreshAndAutoSize(ultraGrid1);
  1027. //查询的退回需求信息
  1028. rpd.Validflag = "1";
  1029. rpd.FlagGeneratedPurPlan = "3";
  1030. rpd.ValidDataPurviewIds = this.ValidDataPurviewIds;
  1031. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd });
  1032. foreach (DataRow row in dt2.Rows)
  1033. {
  1034. row["itemDescE"] = Convert.ToDateTime(row["itemDescE"]).ToString("yyyy/MM");
  1035. }
  1036. GridHelper.CopyDataToDatatable(dt2, dataTable3, true);
  1037. GridHelper.RefreshAndAutoSize(ultraGrid3);
  1038. }
  1039. catch (Exception ex)
  1040. {
  1041. MessageUtil.ShowTips("加载数据失败:" + ex);
  1042. }
  1043. finally
  1044. {
  1045. this.Cursor = Cursors.Default;
  1046. }
  1047. }
  1048. /// <summary>
  1049. /// 需求计划接收准备汇总
  1050. /// </summary>
  1051. private void ReceivePUR_REQUIRE_PLAN()
  1052. {
  1053. string[] strViews=this.ValidDataPurviewIds;
  1054. FrmPurRequirePlanReceive2 frm = new FrmPurRequirePlanReceive2(this.ob, strViews,strCoustomInfo);
  1055. frm.ShowDialog();
  1056. if (frm.tips == "1")
  1057. {
  1058. GetPUR_REQUIRE_PLAN();
  1059. }
  1060. }
  1061. /// <summary>
  1062. /// 查看流程详情
  1063. /// </summary>
  1064. private void Process()//查看流程详情
  1065. {
  1066. UltraGridRow uge = ultraGrid1.ActiveRow;
  1067. if (uge == null)
  1068. {
  1069. MessageUtil.ShowWarning("请选择一条记录");
  1070. return;
  1071. }
  1072. string mrId = uge.Cells["mrId"].Value.ToString();
  1073. ProcInstDetail detail = new ProcInstDetail(BpmFlowConstants.PROCDEF_PUR_REQUIREPLAN_AUDIT, mrId);
  1074. detail.ShowDialog();
  1075. }
  1076. #endregion
  1077. #region 界面事件
  1078. /// <summary>
  1079. /// 文件上传
  1080. /// </summary>
  1081. /// <param name="sender"></param>
  1082. /// <param name="e"></param>
  1083. private void ultraButton1_Click(object sender, EventArgs e)//文件上传
  1084. {
  1085. m_szCurPath = "Image/pss/sale/order";
  1086. // PlanFile.FlileUpload(m_szCurPath);
  1087. }
  1088. /// <summary>
  1089. /// 文件查看
  1090. /// </summary>
  1091. /// <param name="sender"></param>
  1092. /// <param name="e"></param>
  1093. private void ultraTextEditor2_DoubleClick(object sender, EventArgs e)//文件查看
  1094. {
  1095. OpenFileDialog ofd = new OpenFileDialog();
  1096. ofd.ShowDialog();
  1097. //ultraTextEditor2.Value = ofd.FileName;
  1098. //选择文件夹
  1099. //FolderBrowserDialog fbd = new FolderBrowserDialog();
  1100. //fbd.ShowDialog();
  1101. //MessageBox.Show(fbd.SelectedPath);
  1102. }
  1103. /// <summary>
  1104. /// 需求数量变化事件
  1105. /// </summary>
  1106. /// <param name="sender"></param>
  1107. /// <param name="e"></param>
  1108. private void txt_QTY_ValueChanged(object sender, EventArgs e)//需求数量变化事件
  1109. {
  1110. if (!string.IsNullOrEmpty(txt_QTY.Value.ToString()))
  1111. {
  1112. double useBuget = Convert.ToDouble(txt_BUGPRICE.Value) * Convert.ToDouble(txt_QTY.Value) * Convert.ToDouble(txt_ItemUomConefficient.Value);
  1113. txt_BUDGETAMT.Value = useBuget;
  1114. if (!string.IsNullOrEmpty(txt_ItemUomConefficient.Text))
  1115. {
  1116. ultraTextEditor6.Value = Convert.ToDouble(txt_ItemUomConefficient.Value) * Convert.ToDouble(txt_QTY.Value);
  1117. }
  1118. double canUseBuget = Convert.ToDouble(txt_orgBudget.Value);
  1119. if (useBuget > canUseBuget)
  1120. {
  1121. if (CK_isBugCtrl.Checked == true)
  1122. {
  1123. txt_tipsForBudget.Visible = true;
  1124. txt_orgBudget.Appearance.ForeColor = Color.Red;
  1125. }
  1126. }
  1127. else
  1128. {
  1129. txt_tipsForBudget.Visible = false;
  1130. }
  1131. }
  1132. else
  1133. {
  1134. txt_BUDGETAMT.Text = "";
  1135. ultraTextEditor6.Text = "";
  1136. }
  1137. }
  1138. /// <summary>
  1139. /// 要求交期验证
  1140. /// </summary>
  1141. /// <param name="sender"></param>
  1142. /// <param name="e"></param>
  1143. private void txt_LastDeliveryDate_ValueChanged(object sender, EventArgs e)// 要求交期验证
  1144. {
  1145. if (txt_LastDeliveryDate.Text == "")
  1146. {
  1147. txt_tipsForDate.Text = "*无效交期";
  1148. txt_tipsForDate.ForeColor = Color.Red;
  1149. txt_tipsForDate.Visible = true;
  1150. }
  1151. else
  1152. {
  1153. DateTime inputDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
  1154. DateTime timeNow = DateTime.Now;
  1155. if (inputDate <= timeNow)
  1156. {
  1157. txt_tipsForDate.Text = "*无效交期";
  1158. txt_tipsForDate.ForeColor = Color.Red;
  1159. txt_tipsForDate.Visible = true;
  1160. }
  1161. else
  1162. {
  1163. txt_tipsForDate.Visible = false;
  1164. }
  1165. }
  1166. }
  1167. /// <summary>
  1168. /// 需求数量校验
  1169. /// </summary>
  1170. /// <param name="sender"></param>
  1171. /// <param name="e"></param>
  1172. private void txt_QTY_KeyPress(object sender, KeyPressEventArgs e)//需求数量校验
  1173. {
  1174. if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
  1175. {
  1176. e.Handled = true;
  1177. }
  1178. }
  1179. /// <summary>
  1180. /// 切换Tab1
  1181. /// </summary>
  1182. /// <param name="sender"></param>
  1183. /// <param name="e"></param>
  1184. private void ultraGrid1_Click(object sender, EventArgs e)//切换Tab0
  1185. {
  1186. this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
  1187. }
  1188. /// <summary>
  1189. /// 切换Tab1
  1190. /// </summary>
  1191. /// <param name="sender"></param>
  1192. /// <param name="e"></param>
  1193. private void ultraGrid2_Click(object sender, EventArgs e)//切换Tab1
  1194. {
  1195. this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1];
  1196. }
  1197. /// <summary>
  1198. /// 切换Tab0
  1199. /// </summary>
  1200. /// <param name="sender"></param>
  1201. /// <param name="e"></param>
  1202. private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)//切换Tab0
  1203. {
  1204. this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
  1205. clearkongjian1();
  1206. clearkongjian();
  1207. UltraGridRow uge = ultraGrid1.ActiveRow;
  1208. if (uge == null)
  1209. return;
  1210. txt_MRID.Text = uge.Cells["MRID"].Value.ToString();
  1211. txt_MRPERIODEND.Value = uge.Cells["MRPERIODEND"].Value;//计划期间-结束
  1212. txt_REQORGNAME.Text = UserInfo.GetDepartment();//申请者机构名称
  1213. txt_URGENCYTYPE.Text = uge.Cells["URGENCYTYPE"].Value.ToString();//紧急程度类型
  1214. txt_RequeType.Text = uge.Cells["REQUIRETYPE"].Value.ToString().Trim();//需求计划类型
  1215. txt_auditType.Value = uge.Cells["tenantId"].Value.ToString().Trim();//审批流程计划类型
  1216. String YY = uge.Cells["mrId"].Value.ToString();
  1217. RequirePlanD rpd = new RequirePlanD();
  1218. rpd.Validflag = "1";
  1219. rpd.MrId = YY;
  1220. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd });
  1221. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  1222. GridHelper.RefreshAndAutoSize(ultraGrid2);
  1223. }
  1224. /// <summary>
  1225. /// 切换Tab1
  1226. /// </summary>
  1227. /// <param name="sender"></param>
  1228. /// <param name="e"></param>
  1229. private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)//切换Tab1
  1230. {
  1231. this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1];
  1232. clearkongjian();
  1233. UltraGridRow uge = ultraGrid2.ActiveRow;
  1234. if (uge == null)
  1235. return;
  1236. String strMrLineId = uge.Cells["MRLINEID"].Value.ToString();
  1237. RequirePlanD ppd = this.execute<RequirePlanD>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId });
  1238. txt_ItemUomConefficient.Text = uge.Cells["ItemUomConefficient"].Value.ToString();
  1239. txt_WEIGHTUNIT.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
  1240. txt_WEIGHTUNIT1.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
  1241. txt_WEIGHTUNIT2.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
  1242. txt_ItemUom.Text = uge.Cells["ItemUom"].Value.ToString();
  1243. txt_deliveryLocation.Text = uge.Cells["deliveryLocation"].Value.ToString();
  1244. deliveryLocationCode = uge.Cells["deliveryLocationCode"].Value.ToString();
  1245. txt_MRLINEID.Text = strMrLineId;
  1246. txt_Remark.Text = uge.Cells["Remark"].Value.ToString();//备注
  1247. txt_ItemCode.Text = uge.Cells["ItemCode"].Value.ToString();//物料编码
  1248. PurmatclassEntity matclass1 = this.execute<PurmatclassEntity>("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { txt_ItemCode.Text });
  1249. if (matclass1 != null)
  1250. {
  1251. init_itemAutitTypeId = matclass1.TenantId;
  1252. txt_itemAuditType.Text = matclass1.TenantName;
  1253. }
  1254. txt_ItemName.Text = uge.Cells["ItemName"].Value.ToString();//物料名称
  1255. txt_MRLINEID.Text = uge.Cells["MRLINEID"].Value.ToString();//申请单行号
  1256. txt_item_Attr.Text = uge.Cells["itemAttr"].Value.ToString();//属性名称
  1257. txt_BUGPRICE.Text = uge.Cells["BUGPRICE"].Value.ToString();
  1258. txt_BUDGETAMT.Text = uge.Cells["BUDGETAMT"].Value.ToString();
  1259. txt_QTY.Value = uge.Cells["QTY"].Value.ToString();
  1260. txt_LastDeliveryDate.Text = uge.Cells["LastDeliveryDate"].Value.ToString();
  1261. //2016年2月28日新增字段leitao
  1262. txt_itemStandardsCode.Text = uge.Cells["itemStandardsCode"].Value.ToString();//采购标准值
  1263. txt_inStockQty.Text = "10000";//在库库存
  1264. txt_pipeLineStock.Text = "100";//在途库存
  1265. init_itemAttrId = ppd.ItemAttrId;//属性编码
  1266. init_itemStandardsId = ppd.ItemStandardsId;//采购标准编码
  1267. init_itemUomId = ppd.ItemUomId;//单位换算编码
  1268. init_auditFlag = ppd.AuditFlag;//审批标识
  1269. if (ppd.DeliveryLocationFlag == "1")//JIT标识
  1270. {
  1271. Ck_IsJIT.Checked = true;
  1272. }
  1273. else
  1274. {
  1275. Ck_IsJIT.Checked = false;
  1276. }
  1277. init_itemUnique = ppd.ItemUnique;
  1278. //加载是否定额控制
  1279. getBugCtrl(uge.Cells["ItemCode"].Value.ToString(), "2");
  1280. //剩余预算
  1281. getBudget(strMrLineId);
  1282. //加载可用库存数量
  1283. getInStockQty(ppd.ItemUnique);
  1284. //加载可用在途库存数量
  1285. getPipeLineStock(ppd.ItemUnique);
  1286. }
  1287. /// <summary>
  1288. /// 点击退回需求
  1289. /// </summary>
  1290. /// <param name="sender"></param>
  1291. /// <param name="e"></param>
  1292. private void ultraGrid3_ClickCell(object sender, ClickCellEventArgs e)// 点击退回需求
  1293. {
  1294. clearkongjian();
  1295. UltraGridRow uge = ultraGrid3.ActiveRow;
  1296. if (uge == null)
  1297. return;
  1298. String strMrLineId = uge.Cells["MRLINEID"].Value.ToString();
  1299. RequirePlanD ppd = this.execute<RequirePlanD>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId });
  1300. txt_ItemUomConefficient.Text = uge.Cells["ItemUomConefficient"].Value.ToString();
  1301. txt_WEIGHTUNIT.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
  1302. txt_WEIGHTUNIT1.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
  1303. txt_WEIGHTUNIT2.Text = uge.Cells["WEIGHTUNIT"].Value.ToString();
  1304. txt_ItemUom.Text = uge.Cells["ItemUom"].Value.ToString();
  1305. txt_deliveryLocation.Text = uge.Cells["deliveryLocation"].Value.ToString();
  1306. deliveryLocationCode = uge.Cells["deliveryLocationCode"].Value.ToString();
  1307. txt_MRLINEID.Text = strMrLineId;
  1308. txt_Remark.Text = uge.Cells["Remark"].Value.ToString();//备注
  1309. txt_ItemCode.Text = uge.Cells["ItemCode"].Value.ToString();//物料编码
  1310. PurmatclassEntity matclass1 = this.execute<PurmatclassEntity>("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { txt_ItemCode.Text });
  1311. if (matclass1 != null)
  1312. {
  1313. init_itemAutitTypeId = matclass1.TenantId;
  1314. txt_itemAuditType.Text = matclass1.TenantName;
  1315. }
  1316. txt_ItemName.Text = uge.Cells["ItemName"].Value.ToString();//物料名称
  1317. txt_MRLINEID.Text = uge.Cells["MRLINEID"].Value.ToString();//申请单行号
  1318. txt_item_Attr.Text = uge.Cells["itemAttr"].Value.ToString();//属性名称
  1319. txt_BUGPRICE.Text = uge.Cells["BUGPRICE"].Value.ToString();
  1320. txt_BUDGETAMT.Text = uge.Cells["BUDGETAMT"].Value.ToString();
  1321. txt_QTY.Value = uge.Cells["QTY"].Value.ToString();
  1322. txt_LastDeliveryDate.Text = uge.Cells["LastDeliveryDate"].Value.ToString();
  1323. //2016年2月28日新增字段leitao
  1324. txt_itemStandardsCode.Text = uge.Cells["itemStandardsCode"].Value.ToString();//采购标准值
  1325. txt_inStockQty.Text = "10000";//在库库存
  1326. txt_pipeLineStock.Text = "100";//在途库存
  1327. getBudget(strMrLineId);//剩余预算
  1328. init_itemAttrId = ppd.ItemAttrId;//属性编码
  1329. init_itemStandardsId = ppd.ItemStandardsId;//采购标准编码
  1330. init_itemUomId = ppd.ItemUomId;//单位换算编码
  1331. init_auditFlag = ppd.AuditFlag;//审批标识
  1332. if (ppd.DeliveryLocationFlag == "1")//JIT标识
  1333. {
  1334. Ck_IsJIT.Checked = true;
  1335. }
  1336. else
  1337. {
  1338. Ck_IsJIT.Checked = false;
  1339. }
  1340. init_itemUnique = ppd.ItemUnique;
  1341. }
  1342. private void ultraTextEditor5_MouseClick(object sender, MouseEventArgs e)
  1343. {
  1344. }
  1345. /// <summary>
  1346. /// 部门信息弹出事件
  1347. /// </summary>
  1348. /// <param name="sender"></param>
  1349. /// <param name="e"></param>
  1350. private void textBox1_MouseClick(object sender, MouseEventArgs e)//部门信息弹出
  1351. {
  1352. frmdepartment fdt = new frmdepartment(ob);
  1353. fdt.ShowDialog();
  1354. if (fdt.BuyerUnitDesc == null)
  1355. return;
  1356. txt_REQORGNAME.Text = fdt.BuyerUnitDesc;
  1357. }
  1358. /// <summary>
  1359. /// 需求列表和退回需求行切换
  1360. /// </summary>
  1361. /// <param name="sender"></param>
  1362. /// <param name="e"></param>
  1363. private void ultraTabControl2_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)//需求列表和退回需求行切换
  1364. {
  1365. // 切换到需求列表
  1366. if(ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0])
  1367. {
  1368. clearkongjian();
  1369. ultraTabControl1.Tabs[0].Visible = true;
  1370. txt_Status.Enabled = true;
  1371. cop_UrgencyType.Enabled = true;
  1372. ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
  1373. this.ToolBarItemEnable(this, "Add", true);
  1374. this.ToolBarItemEnable(this, "Process", true);
  1375. this.ToolBarItemEnable(this, "Revocation", true);
  1376. txt_ItemName.Enabled = true;
  1377. }
  1378. //切换到退回需求计划
  1379. if(ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1])
  1380. {
  1381. clearkongjian();
  1382. ultraTabControl1.SelectedTab=ultraTabControl1.Tabs[1];
  1383. ultraTabControl1.Tabs[0].Visible=false;
  1384. txt_Status.Enabled = false;
  1385. cop_UrgencyType.Enabled = false;
  1386. this.ToolBarItemEnable(this, "Add", false);
  1387. this.ToolBarItemEnable(this, "Process", false);
  1388. this.ToolBarItemEnable(this, "Revocation", false);
  1389. txt_ItemName.Enabled = false;
  1390. }
  1391. }
  1392. /// <summary>
  1393. /// 库存数量校验
  1394. /// </summary>
  1395. /// <param name="sender"></param>
  1396. /// <param name="e"></param>
  1397. private void ultraTextEditor6_KeyPress(object sender, KeyPressEventArgs e)//库存数量校验
  1398. {
  1399. if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
  1400. {
  1401. e.Handled = true;
  1402. }
  1403. }
  1404. /// <summary>
  1405. /// 物料弹窗
  1406. /// </summary>
  1407. /// <param name="sender"></param>
  1408. /// <param name="e"></param>
  1409. private void txt_ItemName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)//物料弹窗
  1410. {
  1411. FrmPurPlanMat mat = new FrmPurPlanMat(this.ob, init_itemUnique);
  1412. mat.ShowDialog();
  1413. if (mat.getItemCode() == null)
  1414. return;
  1415. txt_ItemCode.Value = mat.getItemCode().ToString();
  1416. txt_ItemName.Value = mat.getItemName().ToString();
  1417. txt_item_Attr.Text = mat.ItemAttr;//属性名称
  1418. PRICE_TYPE = mat.getPriceType().ToString();
  1419. txt_BUGPRICE.Value = mat.getBugPrice().ToString();
  1420. //if (mat.getItemUseUom().ToString() == "是" || mat.getItemUseUom().ToString()=="1")
  1421. //{
  1422. txt_ItemUomConefficient.Text = mat.getItemUomConefficient().ToString().Trim();
  1423. txt_WEIGHTUNIT.Text = mat.getWeightUnit().ToString();
  1424. txt_WEIGHTUNIT1.Text = mat.getWeightUnit().ToString();
  1425. txt_WEIGHTUNIT2.Text = mat.getWeightUnit().ToString();
  1426. txt_ItemUom.Text = mat.UomName;
  1427. txt_QTY.Value = 0;
  1428. ultraTextEditor6.Text = "";
  1429. txt_BUDGETAMT.Text = "";
  1430. txt_Remark.Text = "";
  1431. //2016年2月28新增leitao
  1432. init_itemAttrId = mat.ItemAttrId;//属性编码
  1433. init_itemStandardsId = mat.ItemStandardsId;//采购标准编码
  1434. init_itemUomId = mat.ItemUomId;//单位换算编码
  1435. init_auditFlag = "0";//审批标识
  1436. init_itemUnique = mat.ItemUnique;
  1437. txt_itemStandardsCode.Text = mat.StandardsCode;
  1438. init_itemAutitTypeId = mat.TenantId;
  1439. txt_itemAuditType.Text = mat.TenantName;
  1440. //加载可用库存数量
  1441. getInStockQty(mat.ItemUnique);
  1442. //加载可用在途库存数量
  1443. getPipeLineStock(mat.ItemUnique);
  1444. //确定是否预算控制
  1445. getBugCtrl(mat.getItemCode().Trim(), mat.IsBudgetCtrl);
  1446. }
  1447. /// <summary>
  1448. /// 机构弹窗
  1449. /// </summary>
  1450. /// <param name="sender"></param>
  1451. /// <param name="e"></param>
  1452. private void txt_REQORGNAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)//机构弹窗
  1453. {
  1454. frmdepartment fdt = new frmdepartment(ob);
  1455. fdt.ShowDialog();
  1456. if (fdt.BuyerUnitDesc == null)
  1457. return;
  1458. txt_REQORGNAME.Text = fdt.BuyerUnitDesc;
  1459. }
  1460. /// <summary>
  1461. /// 交付地点弹窗
  1462. /// </summary>
  1463. /// <param name="sender"></param>
  1464. /// <param name="e"></param>
  1465. private void txt_deliveryLocation_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)// 交付地点弹窗
  1466. {
  1467. frmPopActualSeat Dz = new frmPopActualSeat(this.ob,"1");
  1468. //FrmPop_upDeliveryLocation Dz = new FrmPop_upDeliveryLocation(this.ob);
  1469. Dz.ShowDialog();
  1470. if (Dz.DeliveryLocationCode == null)
  1471. {
  1472. return;
  1473. }
  1474. txt_deliveryLocation.Text = Dz.DeliveryLocation;
  1475. deliveryLocationCode = Dz.DeliveryLocationCode;
  1476. //txt_URGENCYTYPE.SelectAll();
  1477. }
  1478. /// <summary>
  1479. /// 查询预算情况
  1480. /// </summary>
  1481. /// <param name="sender"></param>
  1482. /// <param name="e"></param>
  1483. private void txt_orgBudget_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询预算情况
  1484. {
  1485. frmPopOrgBudgetDetail frm = new frmPopOrgBudgetDetail(this.ob);
  1486. frm.ShowDialog();
  1487. }
  1488. /// <summary>
  1489. /// 查询在库存库存
  1490. /// </summary>
  1491. /// <param name="sender"></param>
  1492. /// <param name="e"></param>
  1493. private void txt_inStockQty_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在库存库存
  1494. {
  1495. string TabShow = "0";//tab默认为在库库存
  1496. if (String.IsNullOrEmpty(init_itemUnique))
  1497. {
  1498. MessageUtil.ShowTips("未选择物料!");
  1499. return;
  1500. }
  1501. frmPopInStockQtyDetail frm = new frmPopInStockQtyDetail(this.ob,init_itemUnique,TabShow);
  1502. frm.ShowDialog();
  1503. }
  1504. /// <summary>
  1505. /// 查询在途库存
  1506. /// </summary>
  1507. /// <param name="sender"></param>
  1508. /// <param name="e"></param>
  1509. private void txt_pipeLineStock_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在途库存
  1510. {
  1511. string TabShow = "1";//tab默认为在途库存
  1512. if (String.IsNullOrEmpty(init_itemUnique))
  1513. {
  1514. MessageUtil.ShowTips("未选择物料!");
  1515. return;
  1516. }
  1517. frmPopInStockQtyDetail frm = new frmPopInStockQtyDetail(this.ob, init_itemUnique,TabShow);
  1518. frm.ShowDialog();
  1519. }
  1520. /// <summary>
  1521. /// 是否按照时间查询
  1522. /// </summary>
  1523. /// <param name="sender"></param>
  1524. /// <param name="e"></param>
  1525. private void ck_ctime_CheckedChanged(object sender, EventArgs e)// 是否按照时间查询
  1526. {
  1527. if (ck_ctime.Checked == false)
  1528. {
  1529. txtCreateTimeEnd.Enabled = false;
  1530. txtCreateTimeStart.Enabled = false;
  1531. }
  1532. else
  1533. {
  1534. txtCreateTimeEnd.Enabled = true;
  1535. txtCreateTimeStart.Enabled = true;
  1536. }
  1537. }
  1538. /// <summary>
  1539. /// 紧急采购允许输入月份
  1540. /// </summary>
  1541. /// <param name="sender"></param>
  1542. /// <param name="e"></param>
  1543. private void txt_URGENCYTYPE_ValueChanged(object sender, EventArgs e)// 紧急采购允许输入月份
  1544. {
  1545. if (txt_URGENCYTYPE.SelectedIndex == 1)
  1546. {
  1547. txt_MRPERIODEND.Enabled = true;
  1548. }
  1549. else
  1550. {
  1551. txt_MRPERIODEND.Enabled = false;
  1552. txt_MRPERIODEND.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  1553. }
  1554. }
  1555. #endregion
  1556. #region 公共方法
  1557. /// <summary>
  1558. /// 控件清空tab2
  1559. /// </summary>
  1560. /// <param name="sender"></param>
  1561. /// <param name="e"></param>
  1562. private void clearkongjian()//tab2控件值清空
  1563. {
  1564. txt_item_Attr.Text = "";
  1565. txt_MRLINEID.Text = "";
  1566. txt_Remark.Text = "";
  1567. txt_ItemCode.Text = "";
  1568. txt_ItemName.Text = "";
  1569. txt_MRLINEID.Text = "";
  1570. txt_BUGPRICE.Text = "";
  1571. txt_BUDGETAMT.Text = "";
  1572. txt_QTY.Value = 0;
  1573. ultraTextEditor6.Text = "";
  1574. txt_ItemUom.Text = "";
  1575. txt_WEIGHTUNIT.Text = "";
  1576. txt_WEIGHTUNIT1.Text = "";
  1577. txt_WEIGHTUNIT2.Text = "";
  1578. txt_ItemUomConefficient.Text = "";
  1579. txt_inStockQty.Text = "-";
  1580. txt_pipeLineStock.Text= "-";
  1581. //2016.2.28新增leitao
  1582. txt_inStockQty.Text = "";
  1583. txt_itemStandardsCode.Text = "";
  1584. txt_pipeLineStock.Text = "";
  1585. CK_isBugCtrl.Checked = false;
  1586. getBudget("");
  1587. init_itemAttrId = "";//属性编码
  1588. init_itemStandardsId = "";//采购标准编码
  1589. init_itemUomId = "";//单位换算编码
  1590. init_auditFlag = "";//审批标识
  1591. //init_deliveryLocationFlag = "";//JIT标识
  1592. init_itemUnique = "";
  1593. init_itemAutitTypeId = "";
  1594. txt_itemAuditType.Text = "";
  1595. //Ck_IsJIT.Checked = false;
  1596. //deliveryLocationCode = "";//地点编码
  1597. txt_tipsForDate.Visible = false;
  1598. txt_tipsForBudget.Visible = false;
  1599. txt_orgBudget.Appearance.ForeColor = Color.Black;
  1600. txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString();
  1601. }
  1602. /// <summary>
  1603. /// 控件清空1
  1604. /// </summary>
  1605. /// <param name="sender"></param>
  1606. /// <param name="e"></param>
  1607. private void clearkongjian1()//tab1控件值清空
  1608. {
  1609. txt_RequeType.SelectedIndex = 0;
  1610. txt_MRID.Text = "";
  1611. txt_URGENCYTYPE.SelectedIndex = 0;
  1612. txt_auditType.SelectedIndex = 0;
  1613. txt_MRPERIODEND.Enabled = false;
  1614. txt_REQORGNAME.Text = CoreFS.SA06.CoreUserInfo.UserInfo.GetDepartment();
  1615. if (DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")))
  1616. {
  1617. txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM"));
  1618. }
  1619. else
  1620. {
  1621. txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  1622. }
  1623. }
  1624. /// <summary>
  1625. /// 获取需求计划行编码
  1626. /// </summary>
  1627. /// <param name="str"></param>
  1628. /// <returns></returns>
  1629. public string getCodeId(string str)//获取需求计划行编码
  1630. {
  1631. String YY = ultraGrid1.ActiveRow.Cells["mrId"].Value.ToString();
  1632. RequirePlanD rpd = new RequirePlanD();
  1633. rpd.MrLineId = YY;
  1634. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd });
  1635. string strChild = "";
  1636. int intChild = dt1.Rows.Count;
  1637. intChild++;
  1638. strChild = intChild.ToString();
  1639. while (strChild.Length < 3)
  1640. {
  1641. strChild = "0" + strChild;
  1642. }
  1643. return str + "-" + strChild;
  1644. }
  1645. /// <summary>
  1646. /// JIT选择事件
  1647. /// </summary>
  1648. /// <param name="sender"></param>
  1649. /// <param name="e"></param>
  1650. private void Ck_IsJIT_CheckedChanged(object sender, EventArgs e)// JIT选择事件
  1651. {
  1652. if (Ck_IsJIT.Checked)
  1653. {
  1654. txt_deliveryLocation.Enabled = true;
  1655. }
  1656. else
  1657. {
  1658. txt_deliveryLocation.Enabled = false;
  1659. }
  1660. }
  1661. /// <summary>
  1662. /// 剩余预算计算
  1663. /// </summary>
  1664. private void getBudget(String mrLIneId)//计算剩余预算
  1665. {
  1666. //计算预算
  1667. String strorgId=UserInfo.GetDeptid();
  1668. String stryear=DateTime.Now.Year.ToString();
  1669. String strmouth = DateTime.Now.Month.ToString();
  1670. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ConfigureOrgBudgetService", "doQueryBudgetRemain", new object[] { strorgId, stryear, strmouth, mrLIneId});
  1671. if (re.Resultcode != 0)
  1672. {
  1673. txt_orgBudget.Value = 0;
  1674. return;
  1675. }
  1676. else
  1677. {
  1678. txt_orgBudget.Value = Convert.ToDouble(re.Resultmsg);
  1679. }
  1680. }
  1681. /// <summary>
  1682. /// 可用在途库存
  1683. /// </summary>
  1684. /// <param name="itemUniqueNew"></param>
  1685. /// <param name="qty"></param>
  1686. private void getPipeLineStock(String strItemUnique)//可用在途库存
  1687. {
  1688. if (String.IsNullOrEmpty(strItemUnique))
  1689. {
  1690. txt_pipeLineStock.Text = "-";
  1691. return;
  1692. }
  1693. OrderC orderc = new OrderC();
  1694. orderc.ItemUnique = strItemUnique;
  1695. orderc.Validflag = "1";
  1696. orderc.DeleteName = "1";//仅查询在途库存大于0的
  1697. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderCService", "getPipeLineStockQty", new object[] { orderc });
  1698. if (re.Resultcode != 0)
  1699. {
  1700. txt_pipeLineStock.Text = "-";
  1701. return;
  1702. }
  1703. else
  1704. {
  1705. txt_pipeLineStock.Text = re.Resultmsg;
  1706. }
  1707. }
  1708. /// <summary>
  1709. /// 可用在途库存
  1710. /// </summary>
  1711. /// <param name="p"></param>
  1712. private void getInStockQty(String strItemUnique)//可用在途库存
  1713. {
  1714. if (String.IsNullOrEmpty(strItemUnique))
  1715. {
  1716. txt_inStockQty.Text = "-";
  1717. return;
  1718. }
  1719. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "getInStockQty", new object[] { strItemUnique });
  1720. if (re.Resultcode != 0)
  1721. {
  1722. txt_inStockQty.Text = "-";
  1723. return;
  1724. }
  1725. else
  1726. {
  1727. txt_inStockQty.Text = re.Resultmsg;
  1728. }
  1729. }
  1730. /// <summary>
  1731. /// 查询物料是否预算控制
  1732. /// </summary>
  1733. /// <param name="p1"></param>
  1734. /// <param name="p2">是否预算控制1:控制,0不控制,2未知</param>
  1735. private void getBugCtrl(string itemCode, string p2)
  1736. {
  1737. if (p2 == "0")
  1738. {
  1739. CK_isBugCtrl.Checked = false;
  1740. }
  1741. else if (p2 == "1")
  1742. {
  1743. CK_isBugCtrl.Checked = true;
  1744. }
  1745. else
  1746. {
  1747. if (String.IsNullOrEmpty(itemCode))
  1748. {
  1749. MessageUtil.ShowTips("物料编码为空,无法判断该物料是否为预算控制物料");
  1750. return;
  1751. }
  1752. MatEntity mAT = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { itemCode });
  1753. if (mAT == null)
  1754. {
  1755. MessageUtil.ShowTips("物料【" + itemCode + "】不存在,请确定");
  1756. return;
  1757. }
  1758. if (mAT.IsBudgetCtrl == "1")
  1759. {
  1760. CK_isBugCtrl.Checked = true;
  1761. }
  1762. else
  1763. {
  1764. CK_isBugCtrl.Checked = false;
  1765. }
  1766. }
  1767. }
  1768. /// <summary>
  1769. /// 需求行数据校验
  1770. /// </summary>
  1771. /// <returns></returns>
  1772. private bool testReqC()// 需求行数据校验
  1773. {
  1774. if (txt_ItemCode.Text.ToString().Trim()=="")
  1775. {
  1776. MessageUtil.ShowWarning("物料编码不能为空!");
  1777. return false;
  1778. }
  1779. if (txt_QTY.Value == null)
  1780. {
  1781. MessageUtil.ShowWarning("需求数量不能为空!");
  1782. return false;
  1783. }
  1784. if (Convert.ToDouble(txt_QTY.Value) == 0)
  1785. {
  1786. MessageUtil.ShowWarning("需求数量不能为0");
  1787. return false;
  1788. }
  1789. if (txt_tipsForBudget.Visible == true)
  1790. {
  1791. MessageUtil.ShowTips("超出预算,请确定,或请刷新页面再操作!");
  1792. txt_QTY.Focus();
  1793. return false;
  1794. }
  1795. if (txt_LastDeliveryDate.Text == "" || txt_tipsForDate.Visible == true)
  1796. {
  1797. MessageUtil.ShowTips("请输入有效的到货时间!");
  1798. txt_LastDeliveryDate.Focus();
  1799. return false;
  1800. }
  1801. if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0] && strCoustomInfo != "2")
  1802. {
  1803. string strtenantId = ultraGrid1.ActiveRow.GetCellValue("tenantId").ToString();
  1804. if (strtenantId != init_itemAutitTypeId)
  1805. {
  1806. MessageUtil.ShowTips("该物料审批流程和需求计划头流程不一致!");
  1807. txt_itemAuditType.Focus();
  1808. return false;
  1809. }
  1810. }
  1811. return true;
  1812. }
  1813. /// <summary>
  1814. /// 需求头信息校验
  1815. /// </summary>
  1816. /// <returns></returns>
  1817. private bool testReqM()// 需求头信息校验
  1818. {
  1819. if (txt_MRPERIODEND.Text == "")
  1820. {
  1821. MessageUtil.ShowTips("计划月份不能为空!");
  1822. txt_MRPERIODEND.Focus();
  1823. return false;
  1824. }
  1825. if (txt_MRPERIODEND.Enabled==false&&(DateTime.Now > DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26"))))
  1826. {
  1827. if (MessageUtil.ShowYesNoAndQuestion("需求提报截止日期为每月25号,若提交将默认为下月需求计划。确定新增?") != DialogResult.Yes)
  1828. {
  1829. txt_MRPERIODEND.Focus();
  1830. return false;
  1831. }
  1832. }
  1833. if (txt_RequeType.Value == null)
  1834. {
  1835. MessageUtil.ShowTips("请选择需求计划类型!");
  1836. txt_RequeType.Focus();
  1837. return false;
  1838. }
  1839. if (txt_URGENCYTYPE.SelectedIndex == -1)
  1840. {
  1841. MessageUtil.ShowTips("请选择紧急程度类型!");
  1842. txt_URGENCYTYPE.Focus();
  1843. return false;
  1844. }
  1845. if (strCoustomInfo != "2")
  1846. {
  1847. if (txt_auditType.SelectedIndex == -1)
  1848. {
  1849. MessageUtil.ShowTips("请选择审批流程类型!");
  1850. txt_auditType.Focus();
  1851. return false;
  1852. }
  1853. }
  1854. return true;
  1855. }
  1856. /// <summary>
  1857. /// 验证是否有权力操作行
  1858. /// </summary>
  1859. /// <param name="strMrLineId"></param>
  1860. /// <param name="tips"></param>
  1861. /// <returns></returns>
  1862. private Boolean testReqCStatus(String strMrLineId, int tips)// 验证是否有权力操作行
  1863. {
  1864. RequirePlanD pd = this.execute<RequirePlanD>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId });
  1865. if (pd.CreateUserid != UserInfo.GetUserID())
  1866. {
  1867. MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划行");
  1868. return false;
  1869. }
  1870. //是否待提报是否有权力进行删改
  1871. if (tips == 1)
  1872. {
  1873. //行计划为未接收和已退回下是才能修改和删除
  1874. //if (!(pd.FlagGeneratedPurPlan == "1") && !(pd.FlagGeneratedPurPlan == "3"))
  1875. //{
  1876. // MessageUtil.ShowTips("行计划为“未接收”和“已退回”下才能删改,或请刷新再操作");
  1877. // return;
  1878. //}
  1879. //验证是否有权力操作头
  1880. if (testReqMStatus(pd.MrId, 1) == false)
  1881. {
  1882. return false;
  1883. }
  1884. if (!(pd.FlagGeneratedPurPlan == "1"))
  1885. {
  1886. MessageUtil.ShowTips("行计划为“未接收”下才能删改,或请刷新再操作");
  1887. return false;
  1888. }
  1889. }
  1890. //判断退回需求行是否可以提报和删改
  1891. else if (tips == 2)
  1892. {
  1893. if (pd.FlagGeneratedPurPlan != "3")
  1894. {
  1895. MessageUtil.ShowTips("行计划为非“已退回”状态,无权限删改或提报,或请刷新再操作");
  1896. return false;
  1897. }
  1898. }
  1899. else
  1900. {
  1901. MessageUtil.ShowTips("未知参数,无法验证行信息有效性");
  1902. return false;
  1903. }
  1904. return true;
  1905. }
  1906. /// <summary>
  1907. /// 验证是否有权力操作头
  1908. /// </summary>
  1909. /// <param name="mrId"></param>
  1910. /// <param name="tips"></param>
  1911. /// <returns></returns>
  1912. private Boolean testReqMStatus(String mrId, int tips)// 验证是否有权力操作头
  1913. {
  1914. if (strCoustomInfo != "1" && strCoustomInfo != "2" && strCoustomInfo != "3")
  1915. {
  1916. MessageUtil.ShowTips("界面CoustomInfo参数配置错误,1:生产厂,2:供应部,3:科室厂区");
  1917. return false;
  1918. }
  1919. RequirePlanM pm = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
  1920. if (pm.CreateUserid != UserInfo.GetUserID())
  1921. {
  1922. MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划");
  1923. return false;
  1924. }
  1925. //判断是否有权力进行增删改
  1926. if (tips == 1)
  1927. {
  1928. //头是否处于可删该的状态
  1929. if (pm.Status == "-1"||pm.Status == "0" || pm.Status == "2" || pm.Status == "3")
  1930. {
  1931. MessageUtil.ShowTips("需求计划头【" + mrId + "】不在“待提交”、“待提报”和“审批不通过”状态,暂无权限进行增删改,或请刷新后再操作!");
  1932. return false;
  1933. }
  1934. }
  1935. //判断是否有权力进行修改
  1936. else if (tips == 4)
  1937. {
  1938. //头是否处于可删该的状态
  1939. if (pm.Status == "-1" || pm.Status == "0" || pm.Status == "2" || pm.Status == "3")
  1940. {
  1941. MessageUtil.ShowTips("需求计划头【" + mrId + "】不在“待提交”、“待提报”和“审批不通过”状态,暂无权限进行增删改,或请刷新后再操作!");
  1942. return false;
  1943. }
  1944. //判断是流程是否一致
  1945. if (strCoustomInfo != "2")
  1946. {
  1947. String itemAutitTypeId = txt_auditType.Value.ToString().Trim();
  1948. RequirePlanD testpd = new RequirePlanD();
  1949. testpd.MrId = mrId;
  1950. testpd.Validflag = "1";
  1951. List<RequirePlanD> dtPd = this.execute<List<RequirePlanD>>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "find", new object[] { testpd, 0, 0 });
  1952. if (dtPd.Count > 0)
  1953. {
  1954. foreach (RequirePlanD rpd in dtPd)
  1955. {
  1956. String strItemCode = rpd.ItemCode;
  1957. PurmatclassEntity matclass1 = this.execute<PurmatclassEntity>("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { strItemCode });
  1958. if (matclass1 != null)
  1959. {
  1960. if (matclass1.TenantId != itemAutitTypeId)
  1961. {
  1962. MessageUtil.ShowTips("和该需求头下物料:" + strItemCode + "的流程不一致,请确定!");
  1963. txt_auditType.Focus();
  1964. return false;
  1965. }
  1966. }
  1967. }
  1968. }
  1969. }
  1970. }
  1971. //判断是否可以提报
  1972. else if (tips == 2)
  1973. {
  1974. if (!(pm.Status == "1") && !(pm.Status == "4") && !(pm.Status == "-2"))
  1975. {
  1976. MessageUtil.ShowTips("需求计划头【" + mrId + "】只能在“待提交”、“待提报”和“审批不通过”状态下才有权限进行提报,或请刷新后再操作!");
  1977. return false;
  1978. }
  1979. //判断是否有行信息
  1980. RequirePlanD testpd =new RequirePlanD();
  1981. testpd.MrId=mrId;
  1982. testpd.Validflag="1";
  1983. DataTable dtPd= this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "find", new object[] { testpd,0,0 });
  1984. if (dtPd.Rows.Count<=0)
  1985. {
  1986. MessageUtil.ShowWarning("需求计划头【" + mrId + "】无需求计划行,请添加物料后再提报!");
  1987. return false;
  1988. }
  1989. }
  1990. //是否有权利撤回
  1991. else if (tips == 3)
  1992. {
  1993. //头是否处于可撤回状态
  1994. if (strCoustomInfo != "2")
  1995. {
  1996. if (!(pm.Status == "2") && !(pm.Status == "-1"))
  1997. {
  1998. MessageUtil.ShowTips("需求计划头【" + mrId + "】当前状态不能撤销,无权限,或请刷新后再操作!");
  1999. return false;
  2000. }
  2001. }
  2002. else
  2003. {
  2004. if (!(pm.Status == "3"))
  2005. {
  2006. MessageUtil.ShowTips("需求计划头【" + mrId + "】当前状态不能撤销,无权限,或请刷新后再操作!");
  2007. return false;
  2008. }
  2009. }
  2010. }
  2011. else
  2012. {
  2013. MessageUtil.ShowTips("未知参数,无法验证头表有效性");
  2014. return false;
  2015. }
  2016. return true;
  2017. }
  2018. #endregion
  2019. }
  2020. }