ComBasePhyRSizeFrm.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using Core.Mes.Client.Comm.Tool;
  2. using Core.StlMes.Client.Qcm.BLL;
  3. using Core.StlMes.Client.Qcm.model;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. namespace Core.StlMes.Client.Qcm
  11. {
  12. public partial class ComBasePhyRSizeFrm : FrmBase
  13. {
  14. private ComBasePhyRSizeBLL _PhyRSizeBLL;
  15. public ComBasePhyRSizeFrm()
  16. {
  17. InitializeComponent();
  18. }
  19. private void ComBasePhyRSizeFrm_Load(object sender, EventArgs e)
  20. {
  21. _PhyRSizeBLL = new ComBasePhyRSizeBLL(ob);
  22. }
  23. public override void ToolBar_Click(object sender, string ToolbarKey)
  24. {
  25. base.ToolBar_Click(sender, ToolbarKey);
  26. switch (ToolbarKey)
  27. {
  28. case "Query":
  29. Query();
  30. break;
  31. case "Save":
  32. Save();
  33. break;
  34. case "Close":
  35. this.Close();
  36. break;
  37. }
  38. }
  39. private void Query()
  40. {
  41. this.comBasePhyEntityBindingSource.DataSource = _PhyRSizeBLL.QueryPhy();
  42. }
  43. private void Save()
  44. {
  45. ultraGrid2.UpdateData();
  46. if (ultraGrid1.ActiveRow == null)
  47. {
  48. MessageUtil.ShowWarning("请选择检验项!");
  49. return;
  50. }
  51. ComBasePhyEntity phyEntity = (ComBasePhyEntity)ultraGrid1.ActiveRow.ListObject;
  52. IQueryable<UltraGridRow> rows = ultraGrid2.Rows.AsQueryable().Where("Chk = 'True'");
  53. if (rows.Count() == 0)
  54. {
  55. MessageUtil.ShowWarning("请至少勾选一条尺寸记录!");
  56. return;
  57. }
  58. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No)
  59. {
  60. return;
  61. }
  62. List<ComBasePhyRSizeEntity> parms = rows.Select(
  63. a => (ComBasePhyRSizeEntity)a.ListObject).ToList();
  64. foreach (ComBasePhyRSizeEntity phyRSizeEntity in parms)
  65. {
  66. phyRSizeEntity.PhyCode = phyEntity.PhyCode;
  67. phyRSizeEntity.PhyName = phyEntity.PhyName;
  68. phyRSizeEntity.CreateName = UserInfo.GetUserName();
  69. }
  70. _PhyRSizeBLL.Save(parms);
  71. MessageUtil.ShowTips("保存成功!");
  72. Query();
  73. }
  74. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  75. {
  76. ComBasePhyEntity phyEntity = (ComBasePhyEntity)ultraGrid1.ActiveRow.ListObject;
  77. this.comBasePhyRSizeEntityBindingSource.DataSource = _PhyRSizeBLL.QueryPhySize(phyEntity.PhyCode);
  78. }
  79. private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  80. {
  81. EntityHelper.ShowGridCaption<ComBasePhyEntity>(e.Layout.Bands[0]);
  82. }
  83. private void ultraGrid2_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  84. {
  85. EntityHelper.ShowGridCaption<ComBasePhyRSizeEntity>(e.Layout.Bands[0]);
  86. }
  87. }
  88. }