FrmPurRequirePlan.cs 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409
  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 FrmPurRequirePlan : FrmPmsBase
  27. {
  28. //初始化数据
  29. string deliveryLocationCode = "";//地点编码
  30. string strCoustomInfo = "";
  31. public FrmPurRequirePlan()
  32. {
  33. InitializeComponent();
  34. this.IsLoadUserView = true;
  35. }
  36. private void FrmPurRequirePlan_Load(object sender, EventArgs e)//Load
  37. {
  38. txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString();
  39. strCoustomInfo=this.CustomInfo == null ? "" : this.CustomInfo.ToString();
  40. //初始化1查询区域信息
  41. ck_ctime.Checked = false;
  42. txtCreateTimeStart.Value = DateTime.Now.AddMonths(-2);
  43. txtCreateTimeEnd.Value = DateTime.Now.AddDays(2);
  44. txtCreateTimeStart.Enabled = false;
  45. txtCreateTimeEnd.Enabled = false;
  46. ck_Mtime.Checked = true;
  47. cop_planMouthStart.Value = DateTime.Now.AddMonths(-1);
  48. cop_planMouthEnd.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Now.AddMonths(1): DateTime.Now.AddMonths(2);
  49. cop_UrgencyType.SelectedIndex = 0;
  50. ck_isAlldepart.Checked=true;
  51. //加载计划类型数据
  52. DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob);
  53. if (strCoustomInfo == "1")//生产厂
  54. {
  55. txt_Status.SelectedIndex = 4;
  56. }
  57. else if (strCoustomInfo == "2")//供应部
  58. {
  59. this.ToolBarItemEnable(this, "DoReceive", false);
  60. this.ToolBarItemEnable(this, "Process", false);
  61. txt_Status.SelectedIndex = 4;
  62. }
  63. else//厂区
  64. {
  65. this.ToolBarItemEnable(this, "DoReceive", false);
  66. this.ToolBarItemEnable(this, "Process", false);
  67. txt_Status.SelectedIndex = 1;
  68. }
  69. //初始化2:GRID
  70. ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  71. GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { "CHK", "qty","remark"});
  72. //初始化3:行编辑区
  73. txt_tipsForBudget.Visible = false;
  74. txt_tipsForDeliveryTime.Visible = false;
  75. Ck_IsJIT.Checked = true;
  76. //txt_deliveryLocation.Enabled = false;
  77. }
  78. #region toolbar工具栏事件
  79. /// <summary>
  80. /// toolbar
  81. /// </summary>
  82. /// <param name="sender"></param>
  83. /// <param name="ToolbarKey"></param>
  84. public override void ToolBar_Click(object sender, string ToolbarKey)//菜单toolbar按钮
  85. {
  86. switch (ToolbarKey)
  87. {
  88. case "Query":
  89. GetPUR_REQUIRE_PLAN();
  90. break;
  91. case "Add":
  92. AddPUR_REQUIRE_PLAN();
  93. break;
  94. case "Delete":
  95. DelPUR_REQUIRE_PLAN();
  96. break;
  97. case "Submittal":
  98. SubPUR_REQUIRE_PLAN();
  99. break;
  100. case "Revocation":
  101. RevPUR_REQUIRE_PLAN();
  102. break;
  103. case "DoReceive":
  104. ReceivePUR_REQUIRE_PLAN();
  105. break;
  106. case "Process":
  107. Process();
  108. break;
  109. case "doExcel":
  110. doExcel();
  111. break;
  112. case "doCopy":
  113. doCopy();
  114. break;
  115. }
  116. }
  117. /// <summary>
  118. /// 查询
  119. /// </summary>
  120. private void GetPUR_REQUIRE_PLAN()//刷新
  121. {
  122. dataTable1.Clear();
  123. dataTable2.Clear();
  124. message.Clear();
  125. clearkongjian();
  126. try
  127. {
  128. this.Cursor = Cursors.WaitCursor;
  129. RequirePlanM RqPM = new RequirePlanM();
  130. if (txt_Status.Value != null)
  131. {
  132. RqPM.Status = txt_Status.Value.ToString();
  133. }
  134. if (ultraTextEditor1.Text != null)
  135. {
  136. RqPM.MrId = ultraTextEditor1.Text;
  137. }
  138. if (cop_UrgencyType.Value != null)
  139. {
  140. RqPM.UrgencyType = cop_UrgencyType.Value.ToString();
  141. }
  142. if (ck_ctime.Checked == true)
  143. {
  144. if (txtCreateTimeStart.Text != "")
  145. {
  146. RqPM.CreateTime = Convert.ToDateTime(txtCreateTimeStart.Value);
  147. }
  148. if (txtCreateTimeEnd.Text != "")
  149. {
  150. RqPM.DeleteTime = Convert.ToDateTime(txtCreateTimeEnd.Value);
  151. }
  152. }
  153. //计划时间
  154. if (ck_Mtime.Checked == true)
  155. {
  156. if (cop_planMouthStart.Text != "")
  157. {
  158. DateTime Start1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthStart.Value).ToString("yyyy/MM"));
  159. RqPM.MrPeriodStart = Start1;
  160. }
  161. if (cop_planMouthEnd.Text != "")
  162. {
  163. DateTime End1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthEnd.Value).ToString("yyyy/MM"));
  164. RqPM.MrPeriodEnd = End1;
  165. }
  166. }
  167. //生成厂
  168. if (strCoustomInfo == "1")
  169. {
  170. RqPM.DeleteName = "1";
  171. }
  172. //供应部
  173. else if (strCoustomInfo == "2")
  174. {
  175. RqPM.DeleteName = "0";
  176. }
  177. else
  178. {
  179. RqPM.DeleteName = "3";
  180. }
  181. RqPM.Validflag = "1";
  182. RqPM.ValidDataPurviewIds = this.ValidDataPurviewIds;
  183. RqPM.OperatorUserId = UserInfo.GetUserID();
  184. RqPM.BpmUserId = UserInfo.GetUserID();
  185. string strDataFlag = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getRoleDataFlag", new object[] { UserInfo.GetUserID(), "Pur.require_plan.FrmPurRequirePlan" });
  186. if (strDataFlag == "0")//没有数据权限
  187. {
  188. if (ck_isAlldepart.Checked)
  189. {
  190. RqPM.CreateUserid = this.UserInfo.GetUserID();
  191. }
  192. }
  193. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_status", new object[] { RqPM });
  194. foreach (DataRow row in dt.Rows)
  195. {
  196. row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM");
  197. }
  198. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  199. GridHelper.RefreshAndAutoSize(ultraGrid1);
  200. //查询可用定额
  201. //getBudget();
  202. }
  203. catch (Exception ex)
  204. {
  205. MessageUtil.ShowTips("加载数据失败:" + ex);
  206. }
  207. finally
  208. {
  209. this.Cursor = Cursors.Default;
  210. }
  211. }
  212. /// <summary>
  213. /// 撤销提报
  214. /// </summary>
  215. private void RevPUR_REQUIRE_PLAN()//提报撤销
  216. {
  217. UltraGridRow uge = ultraGrid1.ActiveRow;
  218. if (uge == null)
  219. {
  220. MessageUtil.ShowTips("请选择可操作的需求计划头!");
  221. return;
  222. }
  223. String mrId = uge.Cells["MrId"].Value.ToString();
  224. if ( mrId == "")
  225. {
  226. MessageUtil.ShowTips("请选择可操作的需求计划头");
  227. return;
  228. }
  229. //头是否处于可撤回状态
  230. if (testReqMStatus(mrId, 3) == false)
  231. {
  232. return;
  233. }
  234. ArrayList list = new ArrayList();
  235. RequirePlanM ReqM = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
  236. if (strCoustomInfo != "2")
  237. {
  238. if (ReqM.Status == "-1")
  239. {
  240. ReqM.Status = "-2";
  241. }
  242. else
  243. {
  244. ReqM.Status = "1";
  245. }
  246. }
  247. else//供应部直接撤回(直接有已审批3-》1)
  248. {
  249. ReqM.Status = "31";
  250. }
  251. ReqM.UpdateUserid = UserInfo.GetUserID();
  252. if (MessageUtil.ShowYesNoAndQuestion("确定撤回该需求计划头?") == DialogResult.No)
  253. {
  254. return;
  255. }
  256. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "submit", new object[] { ReqM,strCoustomInfo});
  257. if (rt.Resultcode != 0)
  258. {
  259. MessageUtil.ShowTips("撤回失败!" + rt.Resultmsg);
  260. return;
  261. }
  262. MessageUtil.ShowTips("撤回成功!");
  263. GetPUR_REQUIRE_PLAN();
  264. comm.doActiveSelRow(ultraGrid1, "MrId", ReqM.MrId);
  265. }
  266. /// <summary>
  267. /// 复制需求行
  268. /// </summary>
  269. private void doCopy()
  270. {
  271. UltraGridRow uge = ultraGrid1.ActiveRow;
  272. if (uge == null)
  273. {
  274. MessageUtil.ShowTips("请选择可操作的需求计划头!");
  275. return;
  276. }
  277. String mrId = uge.Cells["MrId"].Value.ToString();
  278. if (mrId == "")
  279. {
  280. MessageUtil.ShowTips("请选择可操作的需求计划头");
  281. return;
  282. }
  283. try
  284. {
  285. frmPurRequirePlanMAdd frm = new frmPurRequirePlanMAdd(this.ob, strCoustomInfo, mrId);
  286. frm.Text = "复制需求计划[" + mrId + "]";
  287. frm.ShowDialog();
  288. if (frm.tips == "1")
  289. {
  290. string StrMrId = frm.requirePlanMId;
  291. GetPUR_REQUIRE_PLAN();
  292. comm.doActiveSelRow(ultraGrid1, "MrId", StrMrId);
  293. }
  294. }
  295. catch (Exception e)
  296. {
  297. MessageUtil.ShowTips("复制失败!" + e);
  298. return;
  299. }
  300. }
  301. /// <summary>
  302. /// 提报
  303. /// </summary>
  304. private void SubPUR_REQUIRE_PLAN()//提报需求
  305. {
  306. UltraGridRow uge = ultraGrid1.ActiveRow;
  307. if (uge == null)
  308. {
  309. MessageUtil.ShowTips("请选择需操作的需求计划头!");
  310. return;
  311. }
  312. String mrId = uge.Cells["MrId"].Value.ToString().Trim();
  313. if (mrId == "")
  314. {
  315. MessageUtil.ShowTips("请选择需操作的需求计划头!");
  316. return;
  317. }
  318. //验证是否可以提报
  319. if (testReqMStatus(mrId, 2) == false)
  320. {
  321. return;
  322. }
  323. RequirePlanM ReqM = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
  324. if (strCoustomInfo != "2")
  325. {
  326. if (ReqM.Status == "-2")
  327. {
  328. ReqM.Status = "-1";//子计划提交
  329. }
  330. else
  331. {
  332. ReqM.Status = "2";//主计划提报
  333. }
  334. }
  335. else
  336. {
  337. ReqM.Status = "13";//供应部默认直接审批并接受(由1知道到3)
  338. }
  339. ReqM.UpdateUserid = UserInfo.GetUserID();
  340. if (MessageUtil.ShowYesNoAndQuestion("确定提报该需求计划头?") == DialogResult.No)
  341. {
  342. return;
  343. }
  344. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "submit", new object[] { ReqM,strCoustomInfo});
  345. if (rt.Resultcode != 0)
  346. {
  347. MessageUtil.ShowTips("提报失败!" + rt.Resultmsg);
  348. return;
  349. }
  350. MessageUtil.ShowTips("提报成功!");
  351. GetPUR_REQUIRE_PLAN();
  352. comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
  353. }
  354. /// <summary>
  355. /// 删除需求
  356. /// </summary>
  357. private void DelPUR_REQUIRE_PLAN()//删除需求
  358. {
  359. UltraGridRow uge = ultraGrid1.ActiveRow;
  360. if (uge == null)
  361. {
  362. MessageUtil.ShowTips("请选择需要操作的需求计划头!");
  363. return;
  364. }
  365. String mrId=uge.Cells["MrId"].Value.ToString().Trim();
  366. if (String.IsNullOrEmpty(mrId))
  367. {
  368. MessageUtil.ShowTips("该需求计划头号为空!");
  369. return;
  370. }
  371. //删除头
  372. //验证是否有权利删除头
  373. if (testReqMStatus(mrId,1) == false)
  374. {
  375. return;
  376. }
  377. ArrayList list = new ArrayList();
  378. RequirePlanM ReqM = new RequirePlanM();
  379. ReqM.MrId = mrId;
  380. ReqM.Validflag = "0";
  381. ReqM.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  382. ReqM.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  383. ReqM.DeleteTime = DateTime.Now;
  384. list.Add(ReqM);
  385. if (MessageUtil.ShowYesNoAndQuestion("确定删除该需求计划,若确定删除将同时删除该需求计划头下的行?") == DialogResult.No)
  386. {
  387. return;
  388. }
  389. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doDeleteM_batch", new object[] { list, strCoustomInfo });
  390. if (rt.Resultcode != 0)
  391. {
  392. MessageUtil.ShowTips("删除失败!" + rt.Resultmsg);
  393. return;
  394. }
  395. MessageUtil.ShowTips("删除成功!");
  396. GetPUR_REQUIRE_PLAN();
  397. }
  398. /// <summary>
  399. /// 新增
  400. /// </summary>
  401. private void AddPUR_REQUIRE_PLAN()//新增需求
  402. {
  403. try
  404. {
  405. frmPurRequirePlanMAdd frm = new frmPurRequirePlanMAdd(this.ob, strCoustomInfo);
  406. frm.ShowDialog();
  407. if(frm.tips=="1")
  408. {
  409. string StrMrId =frm.requirePlanMId;
  410. GetPUR_REQUIRE_PLAN();
  411. comm.doActiveSelRow(ultraGrid1, "MrId", StrMrId);
  412. }
  413. }
  414. catch (Exception e)
  415. {
  416. MessageUtil.ShowTips("新增失败!" + e);
  417. return;
  418. }
  419. }
  420. /// <summary>
  421. /// 导出Excel
  422. /// </summary>
  423. private void doExcel()// 导出Excel
  424. {
  425. try
  426. {
  427. this.Cursor = Cursors.Default;
  428. if (ultraGrid1.ActiveRow == null)
  429. {
  430. MessageUtil.ShowTips("请选择需导出明细的汇总需求计划!");
  431. return;
  432. }
  433. //获取导出的采购计划行表
  434. ArrayList alUltraGrid = new ArrayList();
  435. alUltraGrid.Add(ultraGrid2);
  436. ArrayList alSheeft = new ArrayList();
  437. alSheeft.Add("物料明细");
  438. if (ultraGrid2.Rows.Count > 0)
  439. {
  440. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "需求计划[" + ultraGrid1.ActiveRow.GetCellValue("mrId") + "]明细表");//导出excel
  441. }
  442. else
  443. {
  444. MessageUtil.ShowTips("需求计划:" + ultraGrid1.ActiveRow.GetCellValue("mrId") + "无可导出明细!");
  445. }
  446. }
  447. catch (Exception e)
  448. {
  449. MessageUtil.ShowTips("导出失败" + e.Message);
  450. }
  451. finally
  452. {
  453. this.Cursor = Cursors.Default;
  454. }
  455. }
  456. /// <summary>
  457. /// 需求计划接收准备汇总
  458. /// </summary>
  459. private void ReceivePUR_REQUIRE_PLAN()//分厂编制需求
  460. {
  461. string[] strViews=this.ValidDataPurviewIds;
  462. FrmPurRequirePlanReceive2 frm = new FrmPurRequirePlanReceive2(this.ob, strViews,strCoustomInfo);
  463. frm.ShowDialog();
  464. if (frm.tips == "1")
  465. {
  466. GetPUR_REQUIRE_PLAN();
  467. }
  468. }
  469. /// <summary>
  470. /// 查看流程详情
  471. /// </summary>
  472. private void Process()//查看流程详情
  473. {
  474. UltraGridRow uge = ultraGrid1.ActiveRow;
  475. if (uge == null)
  476. {
  477. MessageUtil.ShowWarning("请选择一条记录");
  478. return;
  479. }
  480. string mrId = uge.Cells["mrId"].Value.ToString();
  481. //if (testReqMStatus(mrId, 6) == false)
  482. //{
  483. // return;
  484. //}
  485. ProcInstDetail detail = new ProcInstDetail(BpmFlowConstants.PROCDEF_PUR_REQUIREPLAN_AUDIT, mrId);
  486. detail.ShowDialog();
  487. }
  488. #endregion
  489. #region 界面事件
  490. /// <summary>
  491. /// 要求交期验证
  492. /// </summary>
  493. /// <param name="sender"></param>
  494. /// <param name="e"></param>
  495. private void txt_LastDeliveryDate_ValueChanged(object sender, EventArgs e)// 要求交期验证
  496. {
  497. if (txt_LastDeliveryDate.Text == "")
  498. {
  499. txt_tipsForDeliveryTime.Visible = true;
  500. }
  501. else
  502. {
  503. if (Convert.ToDateTime(txt_LastDeliveryDate.Value) < DateTime.Now.AddDays(10))
  504. {
  505. txt_tipsForDeliveryTime.Visible = true;
  506. }
  507. else
  508. {
  509. txt_tipsForDeliveryTime.Visible = false;
  510. }
  511. }
  512. }
  513. /// <summary>
  514. /// 查询预算情况
  515. /// </summary>
  516. /// <param name="sender"></param>
  517. /// <param name="e"></param>
  518. private void txt_orgBudget_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询预算情况
  519. {
  520. DateTime dt = new DateTime();
  521. String orgId = "";
  522. if (ultraGrid1.ActiveRow == null)
  523. {
  524. dt = DateTime.Now.AddMonths(1);
  525. orgId = UserInfo.GetDeptid();
  526. }
  527. else
  528. {
  529. UltraGridRow uge = ultraGrid1.ActiveRow;
  530. String YY = uge.Cells["mrId"].Value.ToString();
  531. if (String.IsNullOrEmpty(YY))
  532. {
  533. return;
  534. }
  535. RequirePlanM pd = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { YY });
  536. dt=(DateTime)pd.MrPeriodEnd;
  537. orgId = pd.ReqOrgId;
  538. }
  539. frmPopOrgBudgetDetail frm = new frmPopOrgBudgetDetail(this.ob, dt, orgId);
  540. frm.ShowDialog();
  541. }
  542. /// <summary>
  543. /// 查询在库存库存
  544. /// </summary>
  545. /// <param name="sender"></param>
  546. /// <param name="e"></param>
  547. private void txt_inStockQty_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在库存库存
  548. {
  549. string TabShow = "0";//tab默认为在库库存
  550. UltraGridRow uge = ultraGrid2.ActiveRow;
  551. if (uge == null)
  552. return;
  553. String init_itemUnique = uge.Cells["itemUnique"].Value.ToString();
  554. if (String.IsNullOrEmpty(init_itemUnique))
  555. {
  556. MessageUtil.ShowTips("未选择物料!");
  557. return;
  558. }
  559. frmPopInStockQtyDetail frm = new frmPopInStockQtyDetail(this.ob, init_itemUnique, TabShow);
  560. frm.ShowDialog();
  561. }
  562. /// <summary>
  563. /// 查询在途库存
  564. /// </summary>
  565. /// <param name="sender"></param>
  566. /// <param name="e"></param>
  567. private void txt_pipeLineStock_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在途库存
  568. {
  569. }
  570. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  571. {
  572. if (e.Row.Cells["status"].Value.ToString().StartsWith("审批不通过"))
  573. {
  574. e.Row.Appearance.ForeColor = Color.Red;
  575. }
  576. else
  577. {
  578. e.Row.Appearance.ForeColor = Color.Black;
  579. }
  580. }
  581. private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
  582. {
  583. if (e.Row.Cells["flagGeneratedPurPlan"].Value.ToString().StartsWith("已退回") || e.Row.Cells["flagGeneratedPurPlan"].Value.ToString().StartsWith("已删除"))
  584. {
  585. e.Row.Appearance.ForeColor = Color.Red;
  586. }
  587. else
  588. {
  589. e.Row.Appearance.ForeColor = Color.Black;
  590. }
  591. }
  592. /// <summary>
  593. /// 是否按照时间查询
  594. /// </summary>
  595. /// <param name="sender"></param>
  596. /// <param name="e"></param>
  597. private void ck_ctime_CheckedChanged(object sender, EventArgs e)// 是否按照时间查询
  598. {
  599. if (ck_ctime.Checked == false)
  600. {
  601. txtCreateTimeEnd.Enabled = false;
  602. txtCreateTimeStart.Enabled = false;
  603. }
  604. else
  605. {
  606. txtCreateTimeEnd.Enabled = true;
  607. txtCreateTimeStart.Enabled = true;
  608. }
  609. }
  610. /// <summary>
  611. /// 是否按照计划月份查询
  612. /// </summary>
  613. /// <param name="sender"></param>
  614. /// <param name="e"></param>
  615. private void ck_Mtime_CheckedChanged(object sender, EventArgs e)
  616. {
  617. cop_planMouthStart.Enabled = ck_Mtime.Checked;
  618. cop_planMouthEnd.Enabled = ck_Mtime.Checked;
  619. }
  620. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  621. {
  622. dataTable2.Clear();
  623. message.Clear();
  624. clearkongjian();
  625. if (ultraGrid1.ActiveRow == null)
  626. {
  627. return;
  628. }
  629. UltraGridRow uge = ultraGrid1.ActiveRow;
  630. String YY = uge.Cells["mrId"].Value.ToString();
  631. if (String.IsNullOrEmpty(YY))
  632. {
  633. return;
  634. }
  635. RequirePlanM pd = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { YY });
  636. getBudget((DateTime)pd.MrPeriodEnd, pd.ReqOrgId);
  637. RequirePlanD rpd = new RequirePlanD();
  638. rpd.Validflag = "1";
  639. rpd.MrId = YY;
  640. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd });
  641. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  642. foreach (UltraGridRow ugr in ultraGrid2.Rows)
  643. {
  644. if (!String.IsNullOrEmpty(ugr.Cells["refuseReason"].Value.ToString().Trim()))
  645. {
  646. ugr.CellAppearance.ForeColor = System.Drawing.Color.FromArgb(255, 128, 0);
  647. }
  648. else
  649. {
  650. //ugr.CellAppearance.ForeColor = Color.Black;
  651. }
  652. }
  653. GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new UltraGridColumn[] { ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"], ultraGrid2.DisplayLayout.Bands[0].Columns["remark"] });
  654. //加载评审意见
  655. getOrderReview(YY);
  656. }
  657. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  658. {
  659. UltraGridRow uge = ultraGrid2.ActiveRow;
  660. if (uge == null)
  661. return;
  662. String strMrLineId = uge.Cells["MRLINEID"].Value.ToString();
  663. RequirePlanD ppd = this.execute<RequirePlanD>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId });
  664. //加载可用库存数量
  665. getInStockQty(ppd.ItemUnique);
  666. }
  667. #endregion
  668. #region 行按钮
  669. /// <summary>
  670. ///删除需求行
  671. /// </summary>
  672. /// <param name="sender"></param>
  673. /// <param name="e"></param>
  674. private void btn_delete_Click(object sender, EventArgs e)
  675. {
  676. UltraGridRow uge = ultraGrid1.ActiveRow;
  677. if (uge == null)
  678. {
  679. MessageUtil.ShowTips("请选择需要操作的需求计划头!");
  680. return;
  681. }
  682. String mrId = uge.Cells["MrId"].Value.ToString().Trim();
  683. //验证头状态
  684. if (testReqMStatus(mrId, 1) == false)
  685. {
  686. return;
  687. }
  688. if (String.IsNullOrEmpty(mrId))
  689. {
  690. MessageUtil.ShowTips("该需求计划头号为空!");
  691. return;
  692. }
  693. ultraGrid2.UpdateData();
  694. List<RequirePlanD> list = new List<RequirePlanD>();
  695. foreach (UltraGridRow row in ultraGrid2.Rows)
  696. {
  697. if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
  698. {
  699. string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim();
  700. if (String.IsNullOrEmpty(strMrLineId))
  701. {
  702. MessageUtil.ShowTips("未获取第"+row.Index+"个的需求计划行号!");
  703. return;
  704. }
  705. //验证是否有权利删改行
  706. if (testReqCStatus(strMrLineId, 1) == false)
  707. {
  708. return;
  709. }
  710. RequirePlanD ReqD = new RequirePlanD();
  711. //ReqD.MrId = mrId;
  712. ReqD.MrLineId = strMrLineId;
  713. ReqD.Validflag = "0";
  714. ReqD.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  715. ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  716. ReqD.DeleteTime = DateTime.Now;
  717. list.Add(ReqD);
  718. }
  719. }
  720. if (list.Count <= 0)
  721. {
  722. MessageUtil.ShowTips("未选择需求计划行");
  723. return;
  724. }
  725. if (MessageUtil.ShowYesNoAndQuestion("是否确定删除需求计划行?") != DialogResult.Yes)
  726. {
  727. return;
  728. }
  729. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doDelete_batch", new object[] { list});
  730. if (rt.Resultcode != 0)
  731. {
  732. MessageUtil.ShowTips("删除失败!" + rt.Resultmsg);
  733. return;
  734. }
  735. Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("删除成功!");
  736. GetPUR_REQUIRE_PLAN();
  737. comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
  738. String YY = mrId;
  739. RequirePlanD rpd1 = new RequirePlanD();
  740. rpd1.MrLineId = YY;
  741. rpd1.Validflag = "1";
  742. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
  743. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  744. }
  745. /// <summary>
  746. /// 保存需求行
  747. /// </summary>
  748. /// <param name="sender"></param>
  749. /// <param name="e"></param>
  750. private void btn_doSave_Click(object sender, EventArgs e)
  751. {
  752. if (testReqC() == false)
  753. {
  754. return;
  755. }
  756. UltraGridRow uge = ultraGrid1.ActiveRow;
  757. if (uge == null)
  758. {
  759. MessageUtil.ShowTips("请选择需求计划头!");
  760. return;
  761. }
  762. String mrId = uge.Cells["MrId"].Value.ToString().Trim();
  763. //验证头状态
  764. if (String.IsNullOrEmpty(mrId))
  765. {
  766. MessageUtil.ShowTips("该需求计划头号为空!");
  767. return;
  768. }
  769. List<RequirePlanD> list = new List<RequirePlanD>();
  770. ultraGrid2.UpdateData();
  771. foreach (UltraGridRow row in ultraGrid2.Rows)
  772. {
  773. if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
  774. {
  775. RequirePlanD ReqD = new RequirePlanD();
  776. string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim();
  777. string strmatCode = row.Cells["itemCode"].Value.ToString().Trim();
  778. if (String.IsNullOrEmpty(strMrLineId))
  779. {
  780. MessageUtil.ShowTips("未获取第" + row.Index + "个的需求计划行号!");
  781. return;
  782. }
  783. if (String.IsNullOrEmpty(strmatCode))
  784. {
  785. MessageUtil.ShowTips("未获取第" + row.Index + "个的物料编码!");
  786. return;
  787. }
  788. //验证是否有权利删改行
  789. if (testReqCStatus(strMrLineId, 1) == false)
  790. {
  791. return;
  792. }
  793. //校验数据
  794. double qty = Convert.ToDouble(row.GetCellValue("qty"));
  795. ReqD.DeliveryLocationFlag = Ck_IsJIT.Checked ? "1" : "0";
  796. ReqD.DeliveryLocation = txt_deliveryLocation.Text;
  797. ReqD.DeliveryLocationCode = deliveryLocationCode;
  798. if (ReqD.DeliveryLocationCode == "")
  799. {
  800. MessageUtil.ShowTips("送货的地址信息不能为空");
  801. txt_deliveryLocation.Focus();
  802. return;
  803. }
  804. ReqD.Remark = row.GetCellValue("remark") == null ? "" : row.GetCellValue("remark").ToString().Trim();
  805. ReqD.ItemCode = strmatCode;
  806. ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
  807. ReqD.Qty = qty;
  808. ReqD.MrLineId = strMrLineId;
  809. ReqD.Validflag = "1";
  810. ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetDeptid();
  811. ReqD.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  812. ReqD.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  813. ReqD.UpdateTime = DateTime.Now;
  814. list.Add(ReqD);
  815. }
  816. }
  817. if (list.Count <= 0)
  818. {
  819. MessageUtil.ShowTips("未选择需求计划行");
  820. return;
  821. }
  822. if (MessageUtil.ShowYesNoAndQuestion("确定修改上述需求计划行?") != DialogResult.Yes)
  823. {
  824. return;
  825. }
  826. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_batch", new object[] { list });
  827. if (rt.Resultcode != 0)
  828. {
  829. MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
  830. return;
  831. }
  832. Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("操作成功!");
  833. GetPUR_REQUIRE_PLAN();
  834. comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
  835. RequirePlanD rpd1 = new RequirePlanD();
  836. rpd1.MrLineId = mrId;
  837. rpd1.Validflag = "1";
  838. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
  839. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  840. }
  841. //批量新增物料
  842. private void btn_addItem_Click(object sender, EventArgs e)
  843. {
  844. //校验行数据
  845. if (testReqC() == false)
  846. {
  847. return;
  848. }
  849. List<RequirePlanD> list = new List<RequirePlanD>();
  850. if (ultraGrid1.ActiveRow == null)
  851. {
  852. MessageUtil.ShowTips("请选择需求计划头进行物料添加");
  853. return;
  854. }
  855. UltraGridRow uge = ultraGrid1.ActiveRow;
  856. String mrId = uge.Cells["mrId"].Value.ToString();
  857. //验证头状态
  858. if (testReqMStatus(mrId, 1) == false)
  859. {
  860. return;
  861. }
  862. RequirePlanM pm = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
  863. String strtenantId = pm.TenantId;
  864. FrmPurPlanMatNew mat = new FrmPurPlanMatNew(this.ob);
  865. mat.ShowDialog();
  866. if (mat.list==null||mat.list.Count <= 0)
  867. {
  868. return;
  869. }
  870. foreach (RequirePlanD pd in mat.list)
  871. {
  872. if (strtenantId != pd.DeleteUserid&&strCoustomInfo!="2")
  873. {
  874. if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + " 审批流程:" + pd.DeleteName + "和需求头审批流程:" + pm.TenantName + "不一致,是否忽略该物料继续?") != DialogResult.Yes)
  875. {
  876. return;
  877. }
  878. else
  879. {
  880. continue;
  881. }
  882. }
  883. pd.MrId = mrId;
  884. pd.DeliveryLocationFlag = Ck_IsJIT.Checked?"1":"0";
  885. pd.DeliveryLocation = txt_deliveryLocation.Text;
  886. pd.DeliveryLocationCode = deliveryLocationCode;
  887. if (pd.DeliveryLocationCode == "")
  888. {
  889. MessageUtil.ShowTips("送货的地址信息不能为空");
  890. txt_deliveryLocation.Focus();
  891. return;
  892. }
  893. pd.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value);
  894. RequirePlanD ReqD = new RequirePlanD();
  895. ReqD.ItemUnique = pd.ItemUnique;
  896. ReqD.DeliveryLocationFlag = pd.DeliveryLocationFlag;
  897. ReqD.DeliveryLocationCode = pd.DeliveryLocationCode;
  898. ReqD.MrId = mrId;
  899. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD });
  900. if (dt2.Rows.Count > 0)
  901. {
  902. MessageUtil.ShowWarning("已存在相同需求计划行【" + dt2.Rows[0]["MrLineId"].ToString() + "】");
  903. return;
  904. }
  905. if (pd.Qty == null || Convert.ToDouble(pd.Qty)<=0)
  906. {
  907. if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + "未填写需求量,是否忽略该物料继续添加?") != DialogResult.Yes)
  908. {
  909. return;
  910. }
  911. else {
  912. continue;
  913. }
  914. }
  915. pd.BudgetAmt = pd.BugPrice * pd.Qty*pd.ItemUomConefficient;
  916. pd.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  917. pd.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  918. pd.CreateTime = DateTime.Now;
  919. pd.Validflag = "1";
  920. pd.FlagGeneratedPurPlan = "1";//默认未接受
  921. pd.AuditFlag = "";
  922. pd.DeleteUserid = UserInfo.GetDeptid();//部门ID
  923. if (String.IsNullOrEmpty(pd.ItemUom) || String.IsNullOrEmpty(pd.ItemUnique) || String.IsNullOrEmpty(pd.ItemUomId))
  924. {
  925. if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + "未获取到采购单位,是否忽略该物料继续添加?") != DialogResult.Yes)
  926. {
  927. return;
  928. }
  929. else
  930. {
  931. continue;
  932. }
  933. }
  934. list.Add(pd);
  935. }
  936. if (list.Count <= 0)
  937. {
  938. MessageUtil.ShowTips("未发现可新增物料");
  939. return;
  940. }
  941. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doInsert_D_batch", new object[] { list });
  942. if (rt.Resultcode != 0)
  943. {
  944. MessageUtil.ShowTips("新增行失败!" + rt.Resultmsg);
  945. return;
  946. }
  947. MessageUtil.ShowTips("新增行成功!");
  948. GetPUR_REQUIRE_PLAN();
  949. comm.doActiveSelRow(ultraGrid1, "MrId", mrId);
  950. String YY = mrId;
  951. RequirePlanD rpd1 = new RequirePlanD();
  952. rpd1.MrLineId = YY;
  953. rpd1.Validflag = "1";
  954. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
  955. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  956. comm.doActiveSelRow(ultraGrid2, "MrLineId", rt.Resultmsg);
  957. clearkongjian();
  958. }
  959. /// <summary>
  960. /// 退回需求行重新提报
  961. /// </summary>
  962. /// <param name="sender"></param>
  963. /// <param name="e"></param>
  964. private void btn_back_re_Click(object sender, EventArgs e)
  965. {
  966. if (ultraGrid1.ActiveRow == null)
  967. {
  968. return;
  969. }
  970. UltraGridRow uge = ultraGrid1.ActiveRow;
  971. String YY = uge.Cells["mrId"].Value.ToString();
  972. if (String.IsNullOrEmpty(YY))
  973. {
  974. return;
  975. }
  976. List<RequirePlanD> list = new List<RequirePlanD>();
  977. ultraGrid2.UpdateData();
  978. foreach (UltraGridRow row in ultraGrid2.Rows)
  979. {
  980. if (Convert.ToBoolean(row.GetCellValue("CHK")) == true)
  981. {
  982. RequirePlanD ReqD = new RequirePlanD();
  983. string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim();
  984. if (String.IsNullOrEmpty(strMrLineId))
  985. {
  986. MessageUtil.ShowTips("未获取第" + row.Index + "个的需求计划行号!");
  987. return;
  988. }
  989. //验证是否有权利删改行
  990. if (testReqCStatus(strMrLineId, 2) == false)
  991. {
  992. return;
  993. }
  994. ReqD.MrLineId = strMrLineId;
  995. ReqD.FlagGeneratedPurPlan = "2";
  996. list.Add(ReqD);
  997. }
  998. }
  999. if (list.Count <= 0)
  1000. {
  1001. MessageUtil.ShowTips("未选择需求计划行");
  1002. return;
  1003. }
  1004. if (MessageUtil.ShowYesNoAndQuestion("确定直接提报上述需求计划行?") != DialogResult.Yes)
  1005. {
  1006. return;
  1007. }
  1008. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doBack_batch", new object[] { list });
  1009. if (rt.Resultcode != 0)
  1010. {
  1011. MessageUtil.ShowTips("操作失败!" + rt.Resultmsg);
  1012. return;
  1013. }
  1014. Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("操作成功!");
  1015. GetPUR_REQUIRE_PLAN();
  1016. comm.doActiveSelRow(ultraGrid1, "MrId", YY);
  1017. RequirePlanD rpd1 = new RequirePlanD();
  1018. rpd1.MrLineId = YY;
  1019. rpd1.Validflag = "1";
  1020. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 });
  1021. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  1022. }
  1023. #endregion
  1024. #region 行编辑区控制
  1025. /// <summary>
  1026. /// JIT选择事件
  1027. /// </summary>
  1028. /// <param name="sender"></param>
  1029. /// <param name="e"></param>
  1030. private void Ck_IsJIT_CheckedChanged(object sender, EventArgs e)// JIT选择事件
  1031. {
  1032. //if (Ck_IsJIT.Checked)
  1033. //{
  1034. // txt_deliveryLocation.Enabled = true;
  1035. //}
  1036. //else
  1037. //{
  1038. // txt_deliveryLocation.Enabled = false;
  1039. //}
  1040. txt_deliveryLocation.Clear();
  1041. }
  1042. //编辑区地址选择
  1043. private void txt_deliveryLocation_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1044. {
  1045. String strd = Ck_IsJIT.Checked?"1":"0";//是否全部地址
  1046. String str2 =Ck_IsJIT.Checked? "1":"0";//是否为JIT地址
  1047. if (strCoustomInfo == "2")
  1048. {
  1049. strd = "0";
  1050. }
  1051. FrmPop_upDeliveryLocation Dz = new FrmPop_upDeliveryLocation(this.ob, strd, str2);
  1052. Dz.ShowDialog();
  1053. if (Dz.tips != "1")
  1054. {
  1055. return;
  1056. }
  1057. txt_deliveryLocation.Text = Dz.DeliveryLocation;
  1058. deliveryLocationCode = Dz.DeliveryLocationCode;
  1059. }
  1060. #endregion
  1061. #region 公共函数
  1062. /// <summary>
  1063. /// 需求行数据校验
  1064. /// </summary>
  1065. /// <returns></returns>
  1066. private bool testReqC()// 需求行数据校验
  1067. {
  1068. //if (UserInfo.GetUserID() != "tianf")
  1069. //{
  1070. // if (txt_tipsForBudget.Visible == true || Convert.ToDouble(txt_orgBudget.Value) <= 0)
  1071. // {
  1072. // MessageUtil.ShowTips("请选择头信息或者已超出预算,请确定,或请刷新页面再操作!");
  1073. // txt_orgBudget.Focus();
  1074. // return false;
  1075. // }
  1076. //}
  1077. if (txt_tipsForBudget.Visible == true || Convert.ToDouble(txt_orgBudget.Value) <= 0)
  1078. {
  1079. MessageUtil.ShowTips("请选择头信息或者已超出预算,请确定,或请刷新页面再操作!");
  1080. txt_orgBudget.Focus();
  1081. return false;
  1082. }
  1083. if (txt_LastDeliveryDate.Text == "" || txt_tipsForDeliveryTime.Visible == true || Convert.ToDateTime(txt_LastDeliveryDate.Value) < DateTime.Now.AddDays(10))
  1084. {
  1085. MessageUtil.ShowTips("请输入有效的到货时间,并保证交货周期10天以上!");
  1086. txt_LastDeliveryDate.Focus();
  1087. return false;
  1088. }
  1089. if (deliveryLocationCode == ""||txt_deliveryLocation.Text.Trim()=="")
  1090. {
  1091. MessageUtil.ShowTips("请选择若JIT物料请选择JIT交付地址,非JIT物料请选择非JIT交付地址(若无可用交付地址,请联系供应部维护)");
  1092. txt_deliveryLocation.Focus();
  1093. return false;
  1094. }
  1095. return true;
  1096. }
  1097. /// <summary>
  1098. /// 控件清空tab2
  1099. /// </summary>
  1100. /// <param name="sender"></param>
  1101. /// <param name="e"></param>
  1102. private void clearkongjian()//tab2控件值清空
  1103. {
  1104. txt_inStockQty.Text = "";
  1105. txt_tipsForDeliveryTime.Visible = false;
  1106. txt_tipsForBudget.Visible = false;
  1107. //txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString();
  1108. }
  1109. /// <summary>
  1110. /// 获取评审意见
  1111. /// </summary>
  1112. /// <param name="strOrderId"></param>
  1113. private void getOrderReview(string strOrderId)
  1114. {
  1115. DataTable dt11 = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderMService", "getReviewMsg", new object[] { strOrderId });
  1116. GridHelper.CopyDataToDatatable(dt11, dataTable7, true);
  1117. GridHelper.RefreshAndAutoSize(ultraGrid3);
  1118. }
  1119. #endregion
  1120. #region 公共方法
  1121. /// <summary>
  1122. /// 剩余预算计算
  1123. /// </summary>
  1124. private void getBudget(DateTime dt, string orgId)//计算剩余预算
  1125. {
  1126. //计算预算
  1127. String strorgId = orgId;
  1128. String stryear = dt.Year.ToString();
  1129. String strmouth = dt.Month.ToString();
  1130. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ConfigureOrgBudgetService", "doQueryBudgetRemain", new object[] { strorgId, stryear, strmouth, "" });
  1131. if (re.Resultcode != 0)
  1132. {
  1133. txt_orgBudget.Value = null;
  1134. return;
  1135. }
  1136. else
  1137. {
  1138. txt_orgBudget.Value = Convert.ToDouble(re.Resultmsg);
  1139. }
  1140. }
  1141. /// <summary>
  1142. /// 可用在途库存
  1143. /// </summary>
  1144. /// <param name="p"></param>
  1145. private void getInStockQty(String strItemUnique)//可用在途库存
  1146. {
  1147. if (String.IsNullOrEmpty(strItemUnique))
  1148. {
  1149. txt_inStockQty.Value = null;
  1150. return;
  1151. }
  1152. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "getInStockQty", new object[] { strItemUnique });
  1153. if (re.Resultcode != 0)
  1154. {
  1155. txt_inStockQty.Value = null;
  1156. return;
  1157. }
  1158. else
  1159. {
  1160. txt_inStockQty.Value = Convert.ToDouble(re.Resultmsg);
  1161. }
  1162. }
  1163. /// <summary>
  1164. /// 验证是否有权力操作行
  1165. /// </summary>
  1166. /// <param name="strMrLineId"></param>
  1167. /// <param name="tips"></param>
  1168. /// <returns></returns>
  1169. private Boolean testReqCStatus(String strMrLineId, int tips)// 验证是否有权力操作行
  1170. {
  1171. RequirePlanD pd = this.execute<RequirePlanD>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId });
  1172. if (pd.CreateUserid != UserInfo.GetUserID())
  1173. {
  1174. MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划行");
  1175. return false;
  1176. }
  1177. //是否待提报是否有权力进行删改
  1178. if (tips == 1)
  1179. {
  1180. //行计划为未接收和已退回下是才能修改和删除
  1181. //if (!(pd.FlagGeneratedPurPlan == "1") && !(pd.FlagGeneratedPurPlan == "3"))
  1182. //{
  1183. // MessageUtil.ShowTips("行计划为“未接收”和“已退回”下才能删改,或请刷新再操作");
  1184. // return;
  1185. //}
  1186. //验证是否有权力操作头
  1187. if (pd.FlagGeneratedPurPlan != "3")
  1188. {
  1189. if (testReqMStatus(pd.MrId, 1) == false)
  1190. {
  1191. return false;
  1192. }
  1193. if (!(pd.FlagGeneratedPurPlan == "1"))
  1194. {
  1195. MessageUtil.ShowTips("行计划为“未接收”和“已退回”下才能删改,或请刷新再操作");
  1196. return false;
  1197. }
  1198. }
  1199. }
  1200. //判断退回需求行是否可以提报和删改
  1201. else if (tips == 2)
  1202. {
  1203. if (pd.FlagGeneratedPurPlan != "3")
  1204. {
  1205. MessageUtil.ShowTips("行计划为非“已退回”状态,无法直接提报,或请刷新再操作");
  1206. return false;
  1207. }
  1208. if (pd.IsAllowReturn != "1")
  1209. {
  1210. MessageUtil.ShowTips("不允许修改返回给供应部计划员,请确定");
  1211. return false;
  1212. }
  1213. }
  1214. else
  1215. {
  1216. MessageUtil.ShowTips("未知参数,无法验证行信息有效性");
  1217. return false;
  1218. }
  1219. return true;
  1220. }
  1221. /// <summary>
  1222. /// 验证是否有权力操作头
  1223. /// </summary>
  1224. /// <param name="mrId"></param>
  1225. /// <param name="tips"></param>
  1226. /// <returns></returns>
  1227. private Boolean testReqMStatus(String mrId, int tips)// 验证是否有权力操作头
  1228. {
  1229. if (strCoustomInfo != "1" && strCoustomInfo != "2" && strCoustomInfo != "3")
  1230. {
  1231. MessageUtil.ShowTips("界面CoustomInfo参数配置错误,1:生产厂,2:供应部,3:科室厂区");
  1232. return false;
  1233. }
  1234. RequirePlanM pm = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId });
  1235. if (pm.CreateUserid != UserInfo.GetUserID())
  1236. {
  1237. MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划");
  1238. return false;
  1239. }
  1240. //判断是否有权力进行增删改
  1241. if (tips == 1)
  1242. {
  1243. //头是否处于可删该的状态
  1244. if (pm.Status == "-1" || pm.Status == "0" || pm.Status == "2" || pm.Status == "3")
  1245. {
  1246. MessageUtil.ShowTips("需求计划头【" + mrId + "】不在“待提交”、“待提报”和“审批不通过”状态,暂无权限进行增删改,或请刷新后再操作!");
  1247. return false;
  1248. }
  1249. }
  1250. //判断是否有权力进行修改
  1251. else if (tips == 4)
  1252. {
  1253. //头是否处于可删该的状态
  1254. if (pm.Status == "-1" || pm.Status == "0" || pm.Status == "2" || pm.Status == "3")
  1255. {
  1256. MessageUtil.ShowTips("需求计划头【" + mrId + "】不在“待提交”、“待提报”和“审批不通过”状态,暂无权限进行增删改,或请刷新后再操作!");
  1257. return false;
  1258. }
  1259. //判断是流程是否一致
  1260. if (strCoustomInfo != "2")
  1261. {
  1262. String itemAutitTypeId = pm.TenantId;
  1263. RequirePlanD testpd = new RequirePlanD();
  1264. testpd.MrId = mrId;
  1265. testpd.Validflag = "1";
  1266. List<RequirePlanD> dtPd = this.execute<List<RequirePlanD>>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "find", new object[] { testpd, 0, 0 });
  1267. if (dtPd.Count > 0)
  1268. {
  1269. foreach (RequirePlanD rpd in dtPd)
  1270. {
  1271. String strItemCode = rpd.ItemCode;
  1272. PurmatclassEntity matclass1 = this.execute<PurmatclassEntity>("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { strItemCode });
  1273. if (matclass1 != null)
  1274. {
  1275. if (matclass1.TenantId != itemAutitTypeId)
  1276. {
  1277. MessageUtil.ShowTips("物料:" + strItemCode + "的审批流程流程:" + matclass1.TenantName + "和需求计划头的审批流程:" + pm.TenantName + "不一致,请确定!");
  1278. return false;
  1279. }
  1280. }
  1281. }
  1282. }
  1283. }
  1284. }
  1285. //判断是否可以提报
  1286. else if (tips == 2)
  1287. {
  1288. if (!(pm.Status == "1") && !(pm.Status == "4") && !(pm.Status == "-2"))
  1289. {
  1290. MessageUtil.ShowTips("需求计划头【" + mrId + "】只能在“待提交”、“待提报”和“审批不通过”状态下才有权限进行提报,或请刷新后再操作!");
  1291. return false;
  1292. }
  1293. //判断是否有行信息
  1294. RequirePlanD testpd = new RequirePlanD();
  1295. testpd.MrId = mrId;
  1296. testpd.Validflag = "1";
  1297. DataTable dtPd = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "find", new object[] { testpd, 0, 0 });
  1298. if (dtPd.Rows.Count <= 0)
  1299. {
  1300. MessageUtil.ShowWarning("需求计划头【" + mrId + "】无需求计划行,请添加物料后再提报!");
  1301. return false;
  1302. }
  1303. }
  1304. //是否有权利撤回
  1305. else if (tips == 3)
  1306. {
  1307. //头是否处于可撤回状态
  1308. if (strCoustomInfo != "2")
  1309. {
  1310. if (!(pm.Status == "2") && !(pm.Status == "-1"))
  1311. {
  1312. MessageUtil.ShowTips("需求计划头【" + mrId + "】当前状态不能撤销,无权限,或请刷新后再操作!");
  1313. return false;
  1314. }
  1315. }
  1316. else
  1317. {
  1318. if (!(pm.Status == "3"))
  1319. {
  1320. MessageUtil.ShowTips("需求计划头【" + mrId + "】当前状态不能撤销,无权限,或请刷新后再操作!");
  1321. return false;
  1322. }
  1323. }
  1324. }
  1325. //是否可以查看流程
  1326. else if (tips == 6)
  1327. {
  1328. //头是否处于查看流程
  1329. if (strCoustomInfo == "1")
  1330. {
  1331. if (pm.Status != "2" && pm.Status != "3" && pm.Status != "4")
  1332. {
  1333. MessageUtil.ShowTips("请先提报需求计划【" + mrId + "】!");
  1334. return false;
  1335. }
  1336. }
  1337. else
  1338. {
  1339. MessageUtil.ShowTips("无流程信息");
  1340. return false;
  1341. }
  1342. }
  1343. else
  1344. {
  1345. MessageUtil.ShowTips("未知参数,无法验证头表有效性");
  1346. return false;
  1347. }
  1348. return true;
  1349. }
  1350. #endregion
  1351. }
  1352. }