ComMscRJgCtrl.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Tool;
  3. using Core.StlMes.Client.Qcm.BLL;
  4. using Core.StlMes.Client.Qcm.model;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Windows.Forms;
  12. namespace Core.StlMes.Client.Qcm.Control
  13. {
  14. public partial class ComMscRJgCtrl : UserControl
  15. {
  16. private ComMscRJgBLL _mscRJgBLL;
  17. public ComMscRJgCtrl(OpeBase ob, System.Windows.Forms.Control container)
  18. {
  19. InitializeComponent();
  20. EntityHelper.ShowGridCaption<ComMscRJgEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  21. _mscRJgBLL = new ComMscRJgBLL(ob);
  22. container.Controls.Add(this);
  23. this.Dock = DockStyle.Fill;
  24. }
  25. public void GetMscRJgBySpec(string ordLnPk, bool isCraft)
  26. {
  27. List<ComMscRJgEntity> listSource = _mscRJgBLL.GetMscRJgBySpec(ordLnPk);
  28. comMscRJgEntityBindingSource.DataSource = listSource;
  29. SlmOrdDesignMscJgEntity designMscJg = _mscRJgBLL.GetKeyJgByOrdLnPk(ordLnPk, isCraft);
  30. if (designMscJg != null)
  31. {
  32. foreach (UltraGridRow row in ultraGrid1.Rows)
  33. {
  34. if (row.GetValue("KeyJg") == designMscJg.KeyJg)
  35. {
  36. row.Cells["CHK"].Value = true;
  37. }
  38. }
  39. }
  40. GridHelper.RefreshAndAutoSize(ultraGrid1);
  41. ultraGrid1.UpdateData();
  42. }
  43. public void InsertDesignMscRJg(string ordLnPk, bool isCraft)
  44. {
  45. ultraGrid1.UpdateData();
  46. if (MessageUtil.ShowYesNoAndQuestion("是否确认设定接箍?") == DialogResult.No)
  47. {
  48. return;
  49. }
  50. List<SlmOrdDesignMscJgEntity> parms = new List<SlmOrdDesignMscJgEntity>();
  51. foreach (UltraGridRow row in ultraGrid1.Rows)
  52. {
  53. SlmOrdDesignMscJgEntity parm = EntityHelper.CopyEntity<SlmOrdDesignMscJgEntity>(row.ListObject);
  54. if (row.GetValue("CHK").ToString() == "True")
  55. {
  56. parm.SetJg = "1";
  57. }
  58. else
  59. {
  60. parm.SetJg = "0";
  61. }
  62. parms.Add(parm);
  63. }
  64. _mscRJgBLL.InsertDesignMscRJg(parms, ordLnPk, isCraft);
  65. MessageUtil.ShowTips("设定接箍成功!");
  66. }
  67. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  68. {
  69. ultraGrid1.UpdateData();
  70. if (e.Cell.Column.Key == "CHK")
  71. {
  72. if (e.Cell.Value.ToString() == "True")
  73. {
  74. IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where(
  75. a => a.GetValue("KeyJg") != e.Cell.Row.GetValue("KeyJg") &&
  76. a.GetValue("CHK") == "True");
  77. if (rows.Count() > 0)
  78. {
  79. rows.First().Cells["CHK"].Value = false;
  80. }
  81. }
  82. }
  83. ultraGrid1.UpdateData();
  84. }
  85. }
  86. }