PurExcDeliveryNoticeOk.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Core.Mes.Client.Comm.Control;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Pur.Entity.ck;
  15. using com.hnshituo.pur.vo;
  16. using System.Collections;
  17. using Pur.configure;
  18. using Pur.Entity.pur_orderEntiy;
  19. using CoreFS.SA06;
  20. using Pur.Entity;
  21. using Pur.Pop_upWindow;
  22. namespace Pur.ck
  23. {
  24. public partial class PurExcDeliveryNoticeOk : FrmPmsBase
  25. {
  26. private string init_deliveryLocationCode = "";
  27. private ArrayList list;
  28. private OrderM orderM;
  29. private DateTime dateEnd=DateTime.Now;
  30. private DateTime dateBegin=DateTime.Now;
  31. public string Tips="0";
  32. public PurExcDeliveryNoticeOk()
  33. {
  34. InitializeComponent();
  35. }
  36. public PurExcDeliveryNoticeOk(OpeBase OB, ArrayList list)
  37. {
  38. // TODO: Complete member initialization
  39. this.ob = OB;
  40. this.list = list;
  41. InitializeComponent();
  42. }
  43. #region 工具栏
  44. /// <summary>
  45. /// 生成发货通知
  46. /// </summary>
  47. /// <param name="sender"></param>
  48. /// <param name="e"></param>
  49. private void btn_create_Click(object sender, EventArgs e)// 生成发货通知
  50. {
  51. Add_PurExc();
  52. }
  53. /// <summary>
  54. /// 刷新数据
  55. /// </summary>
  56. /// <param name="sender"></param>
  57. /// <param name="e"></param>
  58. private void btn_refresh_Click(object sender, EventArgs e)// 刷新数据
  59. {
  60. init();
  61. }
  62. /// <summary>
  63. /// 退出
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void btn_close_Click(object sender, EventArgs e)// 退出
  68. {
  69. this.Close();
  70. }
  71. #endregion
  72. /// <summary>
  73. /// 生成发货通知单
  74. /// </summary>
  75. private void Add_PurExc()// 生成发货通知单
  76. {
  77. if (testInPut() == false)
  78. {
  79. return;
  80. }
  81. ultraGrid1.UpdateData();
  82. try
  83. {
  84. //验证是否编制有效数量
  85. int i = 0;
  86. foreach (UltraGridRow uge in ultraGrid1.Rows.GetRowEnumerator(GridRowType.DataRow, null, null))
  87. {
  88. if (!uge.HasParent())
  89. {
  90. if (Convert.ToDouble(uge.Cells["canUseQty"].Value) < Convert.ToDouble(uge.Cells["createQty"].Value))
  91. {
  92. MessageUtil.ShowTips("合同交货行总编制数量不能大于可编制数量");
  93. return;
  94. }
  95. }
  96. if (uge.HasParent() &&Convert.ToBoolean(uge.Cells["isSelect"].Value) == true && !string.IsNullOrEmpty(uge.Cells["createQty"].Value.ToString()) && Convert.ToDouble(uge.Cells["createQty"].Value) > 0)
  97. {
  98. i = i + 1;
  99. }
  100. }
  101. if (i == 0)
  102. {
  103. MessageUtil.ShowTips("编制条数为0或者未编制有效数量");
  104. return;
  105. }
  106. //通知单主表信息
  107. ExcDeliveryNoticeM EdnM = new ExcDeliveryNoticeM();
  108. EdnM.Status = "1";
  109. EdnM.Validflag = "1";
  110. EdnM.CreateTime = DateTime.Now;
  111. EdnM.CreateName = CoreUserInfo.UserInfo.GetUserName();
  112. EdnM.CreateUserid = CoreUserInfo.UserInfo.GetUserID();
  113. EdnM.OrderId = orderM.OrderId;
  114. EdnM.SuppName = orderM.SuppName;
  115. EdnM.SuppCode = orderM.SuppCode;
  116. EdnM.DeliveryLocation = txt_DeliveryLocation.Text.ToString().Trim();
  117. EdnM.DeliveryLocationCode = init_deliveryLocationCode;
  118. EdnM.PlanedShipDate = Convert.ToDateTime(txt_MRPERIODSTART.Value);
  119. EdnM.PlanedDeliveryDate =Convert.ToDateTime(txt_MRPERIODEND.Value);
  120. EdnM.Remark = ultraTextEditor1.Text.ToString().Trim();
  121. //通知从表和从-从表信息
  122. ArrayList list1 = new ArrayList();
  123. ArrayList list2 = new ArrayList();
  124. foreach (UltraGridRow uge in ultraGrid1.Rows.GetRowEnumerator(GridRowType.DataRow, null, null))
  125. {
  126. if (!uge.HasParent())
  127. {
  128. String strOrderLineSqe=uge.Cells["OrderLineSqe"].Value.ToString();
  129. String strOrderLineDSqe=uge.Cells["OrderLineDSqe"].Value.ToString();
  130. if (String.IsNullOrEmpty(strOrderLineSqe))
  131. {
  132. MessageUtil.ShowTips("数据异常,发货通知单行编辑区中存在合同行号为空数据");
  133. return;
  134. }
  135. if (String.IsNullOrEmpty(strOrderLineDSqe))
  136. {
  137. MessageUtil.ShowTips("数据异常,发货通知单行编辑区中存在合同交货行号为空数据");
  138. return;
  139. }
  140. OrderC orderC = this.execute<OrderC>("com.hnshituo.pur.order.service.OrderCService", "findById", new object[] { strOrderLineSqe });
  141. if (orderC == null)
  142. {
  143. MessageUtil.ShowTips("数据异常,发货通知单行编辑区中的合同行号:" + strOrderLineSqe + "未在数据库找到对应信息,可能已被废除,获取刷新");
  144. return;
  145. }
  146. OrderCD orderCD = this.execute<OrderCD>("com.hnshituo.pur.order.service.OrderCDService", "findById", new object[] { strOrderLineDSqe });
  147. if (orderCD == null)
  148. {
  149. MessageUtil.ShowTips("数据异常,发货通知单行编辑区中的合同交货行号:" + strOrderLineDSqe + "未在数据库找到对应信息,可能已被废除,获取刷新");
  150. return;
  151. }
  152. ExcDeliveryNoticeC EdnC = new ExcDeliveryNoticeC();
  153. EdnC.Status = "1";
  154. EdnC.Validflag = "1";
  155. EdnC.OrderId = orderM.OrderId;
  156. EdnC.CreateTime = DateTime.Now;
  157. EdnC.CreateName = CoreUserInfo.UserInfo.GetUserName();
  158. EdnC.CreateUserid = CoreUserInfo.UserInfo.GetUserID();
  159. EdnC.ItemCode = orderC.ItemCode;
  160. EdnC.ItemDesc = orderC.ItemDesc;
  161. EdnC.ItemDescE = orderC.ItemDescE;
  162. EdnC.ItemName = orderC.ItemName;
  163. EdnC.ItemUom = orderC.ItemUom;
  164. EdnC.ItemAttr = orderC.ItemAttr;
  165. EdnC.ItemAttrId = orderC.ItemAttrId;
  166. EdnC.ItemStandardsCode = orderC.ItemStandardsCode;
  167. EdnC.ItemStandardsId = orderC.ItemStandardsId;
  168. EdnC.ItemUnique = orderC.ItemUnique;
  169. EdnC.ItemUomId = orderC.ItemUomId;
  170. EdnC.ItemUomConefficient = orderC.ItemUomConefficient;
  171. EdnC.ReceiveType = orderC.ReceiveType;
  172. EdnC.BuyerName = orderC.BuyerName;
  173. EdnC.MeteringFlag = orderC.MeteringFlag;
  174. EdnC.BatchFlag = orderC.BatchFlag;
  175. EdnC.PcFlag = orderC.PcFlag;
  176. EdnC.Remark = orderCD.Remark;
  177. EdnC.ItemUseUom = orderC.ItemUseUom;
  178. EdnC.OrderLineSqe = orderC.OrderLineSqe;
  179. EdnC.WeightUnit = orderC.WeightUnit;
  180. EdnC.OrderLineDSqe = orderCD.OrderLineDSqe;
  181. EdnC.Qty = Convert.ToDouble(uge.Cells["createQty"].Value);
  182. list2.Add(EdnC);
  183. }
  184. //确定为从从表信息
  185. if (uge.HasParent())
  186. {
  187. if(Convert.ToBoolean(uge.Cells["isSelect"].Value)==true)
  188. {
  189. if(!string.IsNullOrEmpty(uge.Cells["createQty"].Value.ToString()) && Convert.ToDouble(uge.Cells["createQty"].Value)>0)
  190. {
  191. ExcDeliveryNoticeRpR rp=new ExcDeliveryNoticeRpR();
  192. rp.Qty=Convert.ToDouble(uge.Cells["createQty"].Value.ToString());
  193. rp.RequireLineId=uge.Cells["mrLineId"].Value.ToString();
  194. String StrOrderLineSqe = uge.ParentRow.Cells["orderLineSqe"].Value.ToString();
  195. String StrOrderLineDSqe = uge.ParentRow.Cells["orderLineDSqe"].Value.ToString();
  196. rp.OrderLineDSqe = StrOrderLineDSqe;
  197. rp.CreateTime = DateTime.Now;
  198. rp.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  199. rp.CreateUserId = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  200. list1.Add(rp);
  201. }
  202. else
  203. {
  204. MessageUtil.ShowTips("需求行"+uge.Cells["mrLineId"].Value.ToString()+"未编制有效数量");
  205. CkClassCommon.doActiveSelRow(ultraGrid1,"mrLineId",uge.Cells["mrLineId"].Value.ToString());
  206. return;
  207. }
  208. }
  209. }
  210. }
  211. if (MessageUtil.ShowYesNoAndQuestion("确定生成发货通知单?") != DialogResult.Yes)
  212. {
  213. return;
  214. }
  215. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeRpRService", "doInsert_Rp", new object[] { EdnM, list2,list1 });
  216. if (crt.Resultcode != 0)
  217. {
  218. MessageUtil.ShowTips("生成失败" + crt.Resultmsg);
  219. return;
  220. }
  221. MessageUtil.ShowTips("发货通知 "+crt.Resultdata+" 单生成成功!");
  222. Tips = "1";
  223. //IQueryable<UltraGridRow> uRows = ultraGrid1.Rows.AsQueryable().Where("CHECK = 'True' ");
  224. //foreach (UltraGridRow uge in uRows)
  225. //{
  226. // if (uge.Cells["SurQty"].Value.ToString() == "0" ||string.IsNullOrEmpty(uge.Cells["SurQty"].Value.ToString()))
  227. // {
  228. // continue;
  229. // }
  230. // ExcDeliveryNoticeC EdnC = new ExcDeliveryNoticeC();
  231. // EdnC.Status = "1";
  232. // EdnC.Validflag = "1";
  233. // EdnC.OrderId = sub;
  234. // EdnC.CreateTime = DateTime.Now;
  235. // EdnC.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  236. // EdnC.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  237. // EdnC.ItemCode = uge.Cells["ItemCode"].Value.ToString();
  238. // EdnC.ItemDesc = uge.Cells["ItemDesc"].Value.ToString();
  239. // EdnC.ItemDescE = uge.Cells["ItemDescE"].Value.ToString();
  240. // EdnC.ItemModel = uge.Cells["ItemModel"].Value.ToString();
  241. // EdnC.ItemName = uge.Cells["ItemName"].Value.ToString();
  242. // EdnC.ItemSpec = uge.Cells["ItemSpec"].Value.ToString();
  243. // EdnC.ItemUom = uge.Cells["ItemUom"].Value.ToString();
  244. // if (!string.IsNullOrEmpty(uge.Cells["ItemUomConefficient"].Value.ToString()))
  245. // {
  246. // EdnC.ItemUomConefficient = Convert.ToDouble(uge.Cells["ItemUomConefficient"].Value);
  247. // }
  248. // EdnC.ReceiveType = uge.Cells["ReceiveType"].Value.ToString();
  249. // EdnC.BuyerName = uge.Cells["BuyerName"].Value.ToString();
  250. // EdnC.MeteringFlag = uge.Cells["MeteringFlag"].Value.ToString();
  251. // EdnC.BatchFlag = uge.Cells["BatchFlag"].Value.ToString();
  252. // EdnC.PcFlag = uge.Cells["PcFlag"].Value.ToString();
  253. // EdnC.Remark = uge.Cells["Remark"].Value.ToString();
  254. // EdnC.ItemUseUom = uge.Cells["ItemUseUom"].Value.ToString();
  255. // EdnC.OrderLineSqe = uge.Cells["OrderLineSqe"].Value.ToString();
  256. // EdnC.WeightUnit = uge.Cells["WeightUnit"].Value.ToString();
  257. // EdnC.Qty = Convert.ToDouble(uge.Cells["SurQty"].Value);
  258. // list.Add(EdnC);
  259. //}
  260. //CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "insert_ExcMC", new object[] { EdnM, list });
  261. //if (crt.Resultcode != 0)
  262. //{
  263. // Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("生成失败" + crt.Resultmsg);
  264. // return;
  265. //}
  266. //Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("发货通知 "+crt.Resultdata+" 单生成成功!");
  267. }
  268. catch (Exception e)
  269. {
  270. Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("生成失败"+e);
  271. }
  272. this.Close();
  273. }
  274. /// <summary>
  275. /// 界面加载
  276. /// </summary>
  277. /// <param name="sender"></param>
  278. /// <param name="e"></param>
  279. private void PurExcDeliveryNoticeOk_Load(object sender, EventArgs e)// 界面加载
  280. {
  281. init();
  282. }
  283. /// <summary>
  284. /// 加载数据
  285. /// </summary>
  286. private void init()// 加载数据
  287. {
  288. try
  289. {
  290. this.Cursor = Cursors.WaitCursor;
  291. //清空数据和显示合同信息
  292. dataSet1.Clear();
  293. if (list.Count <= 0)
  294. {
  295. MessageUtil.ShowTips("未发现待生成的合同交货行信息");
  296. return;
  297. }
  298. //加载交货行信息
  299. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderCDService", "doQueryOrderCDByList", new object[] { list });
  300. if (dt == null || dt.Rows.Count == 0)
  301. {
  302. MessageUtil.ShowTips("数据库无上述合同交货行信息");
  303. return;
  304. }
  305. //dt.Columns.Add("YEAR", Type.GetType("System.Int32"));
  306. dt.Columns.Add("canUseQty", Type.GetType("System.String"));
  307. dt.Columns.Add("createQty", Type.GetType("System.String"));
  308. foreach (DataRow rows in dt.Rows)
  309. {
  310. //生成数量默认为剩余数量
  311. // rows["SurQty"] = rows["Qty"];
  312. //JIT物料判断
  313. //if (!rows["receiveType"].ToString().Equals("JIT入库"))
  314. //{
  315. // MessageUtil.ShowTips("该合同明细存在非JIT物料,请选择其他通知单生成方式");
  316. // this.Close();
  317. // return;
  318. //}
  319. //行号判断
  320. if (String.IsNullOrEmpty(rows["deleteName"].ToString()))
  321. {
  322. MessageUtil.ShowTips("合同行:" + rows["orderLineSqe"].ToString() + "采购计划行号为空,无法查询到关联的需求计划行");
  323. this.Close();
  324. return;
  325. }
  326. //计算可编制量
  327. rows["Qty"] = rows["Qty"] == DBNull.Value ? 0 : rows["Qty"];
  328. rows["createdQty"] = rows["createdQty"] == DBNull.Value ? 0 : rows["createdQty"];
  329. rows["canUseQty"] = Convert.ToDouble(rows["Qty"]) - Convert.ToDouble(rows["createdQty"]);
  330. rows["createQty"] = 0;
  331. //计算最晚的交期
  332. DateTime strDateEnd = Convert.ToDateTime(rows["DELIVERYDATEEND"]);
  333. dateEnd = strDateEnd < dateEnd ? strDateEnd : dateEnd;
  334. DateTime strDateStart = Convert.ToDateTime(rows["DELIVERYDATESTART"]);
  335. dateBegin = strDateStart < dateBegin ? strDateStart : dateBegin;
  336. }
  337. GridHelper.CopyDataToDatatable(dt, dataTable4, true);
  338. //初始化时间
  339. txt_MRPERIODEND.Value = dateEnd;
  340. txt_MRPERIODSTART.Value = dateBegin;
  341. //加载合同头信息
  342. String StrOrderId = dt.Rows[0]["orderId"].ToString().Trim();
  343. orderM = this.execute<OrderM>("com.hnshituo.pur.order.service.OrderMService", "findById", new object[] { StrOrderId });
  344. if(orderM==null)
  345. {
  346. MessageUtil.ShowTips("数据库未发现合同头:"+StrOrderId+" 信息");
  347. return;
  348. }
  349. COP_OrderId.Text = orderM.OrderId;
  350. COP_SuppName.Text = orderM.SuppName;
  351. //加载需求行信息
  352. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "getRD_forOrder", new object[] { list });
  353. GridHelper.CopyDataToDatatable(dt1, dataTable3, true);
  354. //统一初始化交货行和需求行--默认选择和推算
  355. foreach (UltraGridRow uge in ultraGrid1.Rows)
  356. {
  357. if (!uge.HasParent())
  358. {
  359. double tepQty = Convert.ToDouble(uge.Cells["canUseQty"].Value);//剩余总可编制
  360. uge.Cells["createQty"].Value = tepQty;
  361. foreach (UltraGridRow uce in uge.ChildBands[0].Rows)
  362. {
  363. if (tepQty > 0)
  364. {
  365. double willUseQty = Convert.ToDouble(uce.Cells["qtyPur"].Value);
  366. if (tepQty > willUseQty)
  367. {
  368. tepQty = tepQty - willUseQty;
  369. uce.Cells["isSelect"].Value = true;
  370. uce.Cells["createQty"].Value = willUseQty;
  371. }
  372. else
  373. {
  374. uce.Cells["isSelect"].Value = true;
  375. uce.Cells["createQty"].Value = tepQty;
  376. tepQty = 0;
  377. }
  378. }
  379. else
  380. {
  381. uce.Cells["isSelect"].Value = false;
  382. uce.Cells["createQty"].Value = 0;
  383. }
  384. }
  385. if (tepQty > 0)
  386. {
  387. uge.Cells["createQty"].Value = Convert.ToDouble(uge.Cells["createQty"].Value)-tepQty;
  388. }
  389. }
  390. }
  391. ////需求行初始化
  392. //foreach (UltraGridRow rowd in ultraGrid1.Rows.GetRowEnumerator(GridRowType.DataRow, null, null))
  393. //{
  394. // if (rowd.HasParent())
  395. // {
  396. // rowd.Cells["isSelect"].Value = true;
  397. // rowd.Cells["createQty"].Value = rowd.Cells["qtyPur"].Value;
  398. // }
  399. //}
  400. ////交货行初始化
  401. //foreach (UltraGridRow rowd in ultraGrid1.Rows.GetRowEnumerator(GridRowType.DataRow, null, null))
  402. //{
  403. // if (!rowd.HasParent())
  404. // {
  405. // double tempval1 = 0;
  406. // foreach (UltraGridRow rows in rowd.ChildBands[0].Rows)
  407. // {
  408. // if (rows.Cells["createQty"].Value != null && !String.IsNullOrEmpty(rows.Cells["createQty"].Value.ToString()) && Convert.ToBoolean(rows.Cells["isSelect"].Value) == true)
  409. // {
  410. // tempval1 = tempval1 + Convert.ToDouble(rows.Cells["createQty"].Value);
  411. // }
  412. // }
  413. // rowd.Cells["createQty"].Value = tempval1;
  414. // }
  415. //}
  416. ultraGrid1.UpdateData();
  417. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { });
  418. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[1], new string[] {"isSelect","createQty"});
  419. }
  420. catch (Exception ex)
  421. {
  422. MessageUtil.ShowTips("生成通知单界面初始化失败:" + ex.Message);
  423. this.Close();
  424. }
  425. finally
  426. {
  427. this.Cursor = Cursors.Default;
  428. }
  429. }
  430. /// <summary>
  431. /// 数量输入控制
  432. /// </summary>
  433. /// <param name="sender"></param>
  434. /// <param name="e"></param>
  435. private void ultraGrid1_CellChange(object sender, CellEventArgs e)// 数量输入控制
  436. {
  437. double Qb_newParentVale = Convert.ToDouble(e.Cell.Row.ParentRow.Cells["canUseQty"].Value);
  438. if (e.Cell.Row.HasParent() && e.Cell.Column.Key=="createQty")
  439. {
  440. double Qb_newcellvalue =Convert.ToDouble(e.Cell.Value);
  441. ultraGrid1.UpdateData();
  442. if (e.Cell.Column.Key.Equals("createQty"))
  443. {
  444. double t1=Convert.ToDouble(e.Cell.Row.Cells["createQty"].Value);
  445. double t2=Convert.ToDouble(e.Cell.Row.Cells["qtyPur"].Value);
  446. if (t1 > t2)
  447. {
  448. e.Cell.Value = Qb_newcellvalue;
  449. e.Cell.Appearance.BorderColor = Color.Red;
  450. return;
  451. }
  452. e.Cell.Appearance.BorderColor = Color.Black;
  453. double tempval1 = 0;
  454. foreach (UltraGridRow rows in e.Cell.Row.ParentRow.ChildBands[0].Rows)
  455. {
  456. if (rows.Cells["createQty"].Value != null && !String.IsNullOrEmpty(rows.Cells["createQty"].Value.ToString()) && Convert.ToBoolean(rows.Cells["isSelect"].Value) == true)
  457. {
  458. tempval1 = tempval1 + Convert.ToDouble(rows.Cells["createQty"].Value);
  459. }
  460. }
  461. if (tempval1 > Qb_newParentVale)
  462. {
  463. e.Cell.Value = Qb_newcellvalue;
  464. e.Cell.Row.ParentRow.Cells["createQty"].Appearance.BorderColor = Color.Red;
  465. return;
  466. }
  467. e.Cell.Row.ParentRow.Cells["createQty"].Appearance.BorderColor = Color.Black;
  468. e.Cell.Row.ParentRow.Cells["createQty"].Value = tempval1;
  469. }
  470. }
  471. if (e.Cell.Row.HasParent() && e.Cell.Column.Key == "isSelect")
  472. {
  473. Boolean oldcheck = Convert.ToBoolean(e.Cell.Value);
  474. ultraGrid1.UpdateData();
  475. Boolean newcheck = Convert.ToBoolean(e.Cell.Value);
  476. double tempval1 = 0;
  477. foreach (UltraGridRow rows in e.Cell.Row.ParentRow.ChildBands[0].Rows)
  478. {
  479. if (rows.Cells["createQty"].Value != null && !String.IsNullOrEmpty(rows.Cells["createQty"].Value.ToString()) && Convert.ToBoolean(rows.Cells["isSelect"].Value) == true)
  480. {
  481. tempval1 = tempval1 + Convert.ToDouble(rows.Cells["createQty"].Value);
  482. }
  483. }
  484. if (tempval1 > Qb_newParentVale)
  485. {
  486. e.Cell.Value = oldcheck;
  487. e.Cell.Row.ParentRow.Cells["createQty"].Appearance.BorderColor = Color.Red;
  488. return;
  489. }
  490. e.Cell.Row.ParentRow.Cells["createQty"].Appearance.BorderColor = Color.Black;
  491. e.Cell.Row.ParentRow.Cells["createQty"].Value = tempval1;
  492. }
  493. }
  494. /// <summary>
  495. /// 地点选择
  496. /// </summary>
  497. /// <param name="sender"></param>
  498. /// <param name="e"></param>
  499. private void txt_DeliveryLocation_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)// 地点选择
  500. {
  501. FrmPop_upDeliveryLocation Dz = new FrmPop_upDeliveryLocation(this.ob);
  502. Dz.ShowDialog();
  503. if (Dz.DeliveryLocationCode == null)
  504. {
  505. return;
  506. }
  507. txt_DeliveryLocation.Text = Dz.DeliveryLocation;
  508. init_deliveryLocationCode = Dz.DeliveryLocationCode;
  509. }
  510. /// <summary>
  511. /// 输入数据校验
  512. /// </summary>
  513. /// <returns></returns>
  514. private bool testInPut()
  515. {
  516. if (String.IsNullOrEmpty(txt_MRPERIODSTART.Text))
  517. {
  518. MessageUtil.ShowTips("请输入要求交货开始时间!");
  519. txt_MRPERIODSTART.Focus();
  520. return false;
  521. }
  522. if (String.IsNullOrEmpty(txt_MRPERIODEND.Text))
  523. {
  524. MessageUtil.ShowTips("请输入要求交货结束时间!");
  525. txt_MRPERIODEND.Focus();
  526. return false;
  527. }
  528. if (Convert.ToDateTime(txt_MRPERIODEND.Value) < DateTime.Now)
  529. {
  530. MessageUtil.ShowTips("输入的通知单要求交货结束时间无效,需大于当前时间!");
  531. txt_MRPERIODEND.Focus();
  532. return false;
  533. }
  534. if (Convert.ToDateTime(txt_MRPERIODSTART.Value) >= Convert.ToDateTime(txt_MRPERIODEND.Value))
  535. {
  536. MessageUtil.ShowTips("通知单的要求交货结束时间需大于开始时间");
  537. txt_MRPERIODSTART.Focus();
  538. return false;
  539. }
  540. if (String.IsNullOrEmpty(init_deliveryLocationCode))
  541. {
  542. MessageUtil.ShowTips("通知单的交付地址不能为空!");
  543. txt_DeliveryLocation.Focus();
  544. return false;
  545. }
  546. return true;
  547. }
  548. }
  549. }