FrmBaseMaterialIPl.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using com.steering.pss.plnsaleord.processOrder.entity;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  14. using CoreFS.CA06;
  15. using Infragistics.Win.UltraWinEditors;
  16. using Infragistics.Win.UltraWinGrid;
  17. using Core.StlMes.Client.PlnSaleOrd.Entity;
  18. using Core.Mes.Client.Comm.Format;
  19. namespace Core.StlMes.Client.PlnSaleOrd
  20. {
  21. public partial class FrmBaseMaterialIPl : FrmBase
  22. {
  23. private string _inMaterialNo = "";
  24. private string _outMaterialNo = "";
  25. private string _inMaterialDesc = "";
  26. private string _outMaterialDesc = "";
  27. private string _groupId = "";
  28. private string _plineCode = "";
  29. //public FrmBaseMaterialIPl()
  30. //{
  31. // InitializeComponent();
  32. //}
  33. public FrmBaseMaterialIPl(string inMaterialNo, string outMaterialNo,string groupId,string plineCode, OpeBase ob)
  34. {
  35. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  36. InitializeComponent();
  37. _inMaterialNo = inMaterialNo;
  38. _plineCode = plineCode;
  39. _outMaterialNo = outMaterialNo;
  40. _groupId = groupId;
  41. this.ob = ob;
  42. }
  43. public FrmBaseMaterialIPl(string inMaterialNo, string outMaterialNo, OpeBase ob)
  44. {
  45. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  46. InitializeComponent();
  47. _inMaterialNo = inMaterialNo;
  48. _outMaterialNo = outMaterialNo;
  49. this.ob = ob;
  50. }
  51. private void FrmBaseMaterialI_Load(object sender, EventArgs e)
  52. {
  53. EntityHelper.ShowGridCaption<SlmBaseMaterialKPlEntity>(ultraGridJgx.DisplayLayout.Bands[0]);
  54. BaseHelper.setColumnBackColor(ultraGridJgx, new string[] { "HrCapcty", "PrdRate", "WasteRate", "PlineCode", "PlineLevel", "DisableFl" });
  55. BaseHelper.InitCellPosition(ultraGridJgx, new string[] { "HrCapcty", "PrdRate", "WasteRate", "PlineLevel" });
  56. InitMaterialDesc();
  57. if (_inMaterialDesc.Equals(""))
  58. {
  59. ultraGridJgx.Enabled = false;
  60. return;
  61. }
  62. InitPline();
  63. DoQuery();
  64. }
  65. /// <summary>
  66. /// 初始化产线
  67. /// </summary>
  68. private void InitPline()
  69. {
  70. UltraComboEditor uce = new UltraComboEditor();
  71. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMaterialIPl.getBaseJgxPline", new object[] {_groupId }, this.ob);
  72. uce.DataSource = dt;
  73. uce.DisplayMember = "PLINE_NAME";
  74. uce.ValueMember = "PLINE_CODE";
  75. Controls.Add(uce);
  76. uce.Visible = false;
  77. uce.DropDownListWidth = -1;
  78. UltraGridBand ugb = ultraGridJgx.DisplayLayout.Bands[0];
  79. ugb.Columns["PlineCode"].EditorComponent = uce;
  80. ugb.Columns["PlineCode"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  81. }
  82. /// <summary>
  83. /// 初始化物料描述
  84. /// </summary>
  85. private void InitMaterialDesc()
  86. {
  87. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMaterialIPl.getMaterialDesc", new object[] { _inMaterialNo, _outMaterialNo }, this.ob);
  88. if (dt != null && dt.Rows.Count > 0)
  89. {
  90. _inMaterialDesc = dt.Rows[0]["IN_MATERIAL_DESC"].ToString();
  91. _outMaterialDesc = dt.Rows[0]["OUT_MATERIAL_DESC"].ToString();
  92. }
  93. }
  94. /// <summary>
  95. /// 控制字段可编辑
  96. /// </summary>
  97. /// <param name="row"></param>
  98. private void ControlCellEdit(UltraGridRow row)
  99. {
  100. foreach (UltraGridCell cell in row.Cells)
  101. {
  102. if (cell.Column.CellAppearance.BackColor == Color.FromArgb(255, 255, 128))
  103. {
  104. if (row.Cells["CHC"].Value.ToString() == "True")
  105. {
  106. cell.Activation = Activation.AllowEdit;
  107. }
  108. else
  109. {
  110. cell.Activation = Activation.ActivateOnly;
  111. }
  112. if (!row.Cells["CreateTime"].Value.ToString().Equals(""))
  113. {
  114. if (cell.Column.Key.Equals("PlineCode"))
  115. {
  116. cell.Activation = Activation.ActivateOnly;
  117. }
  118. }
  119. }
  120. else
  121. {
  122. if (!cell.Column.Key.Equals("CHC"))
  123. {
  124. cell.Activation = Activation.ActivateOnly;
  125. }
  126. }
  127. }
  128. }
  129. private void ultraGridJgx_InitializeRow(object sender, InitializeRowEventArgs e)
  130. {
  131. ControlCellEdit(e.Row);
  132. }
  133. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  134. {
  135. switch (e.Tool.Key.Trim())
  136. {
  137. case "查询":
  138. DoQuery();
  139. break;
  140. case "新增":
  141. DoSave("0");
  142. break;
  143. case "修改":
  144. DoSave("1");
  145. break;
  146. case "删除":
  147. DoSave("2");
  148. break;
  149. case "关闭":
  150. this.Close();
  151. break;
  152. }
  153. }
  154. public void DoQuery()
  155. {
  156. List<SlmBaseMaterialKPlEntity> materialFPlEntityList = EntityHelper.GetData<SlmBaseMaterialKPlEntity>(
  157. "com.steering.pss.plnsaleord.processOrder.FrmBaseMaterialIPl.getGjxPl", new object[] { _inMaterialNo, _outMaterialNo,_groupId }, ob);
  158. slmBaseMaterialKPlEntityBindingSource.DataSource = materialFPlEntityList;
  159. if (!_plineCode.Equals(""))
  160. {
  161. IQueryable<UltraGridRow> chcRows = ultraGridJgx.Rows.AsQueryable().Where(a => a.GetValue("PlineCode") == _plineCode);
  162. if (chcRows != null && chcRows.Count() != 0)
  163. {
  164. chcRows.First().Activate();
  165. chcRows.First().Cells["CHC"].Value = true;
  166. }
  167. }
  168. }
  169. private void DoSave(string flag)
  170. {
  171. ultraGridJgx.UpdateData();
  172. IQueryable<UltraGridRow> chcRows = ultraGridJgx.Rows.AsQueryable().Where("CHC = 'True'");
  173. if (chcRows.Count() == 0)
  174. {
  175. MessageUtil.ShowTips("请选择记录!");
  176. return;
  177. }
  178. ArrayList plineList = new ArrayList();
  179. ArrayList list = new ArrayList();
  180. foreach (UltraGridRow ugr in chcRows)
  181. {
  182. SlmBaseMaterialKPlEntity fPlEntity = (SlmBaseMaterialKPlEntity)ugr.ListObject;
  183. if (fPlEntity.PlineCode.Equals(""))
  184. {
  185. MessageUtil.ShowWarning("请选择加工产线!");
  186. return;
  187. }
  188. if (plineList.Contains(fPlEntity.PlineCode))
  189. {
  190. MessageUtil.ShowWarning("存在相同的产线(" + fPlEntity.PlineName + ")!");
  191. return;
  192. }
  193. else
  194. {
  195. plineList.Add(fPlEntity.PlineCode);
  196. }
  197. if (flag.Equals("0") && CheckIsExist(fPlEntity.PlineCode, fPlEntity.InMaterialNo, fPlEntity.OutMaterialNo))
  198. {
  199. MessageUtil.ShowWarning("已经存在的记录(产线:" + fPlEntity.PlineName + ",投入物料:" + fPlEntity.InMaterialDesc + ",产出物料:" + fPlEntity.OutMaterialDesc + "),不能新增!");
  200. return;
  201. }
  202. if (flag.Equals("1") && (!CheckIsExist(fPlEntity.PlineCode, fPlEntity.InMaterialNo, fPlEntity.OutMaterialNo) || fPlEntity.CreateTime.Equals("")))
  203. {
  204. MessageUtil.ShowWarning("不存在的记录(产线:" + fPlEntity.PlineName + ",投入物料:" + fPlEntity.InMaterialDesc + ",产出物料:" + fPlEntity.OutMaterialDesc + "),不能修改!");
  205. return;
  206. }
  207. if (flag.Equals("2") && (!CheckIsExist(fPlEntity.PlineCode, fPlEntity.InMaterialNo, fPlEntity.OutMaterialNo) || fPlEntity.CreateTime.Equals("")))
  208. {
  209. MessageUtil.ShowWarning("不存在的记录(产线:" + fPlEntity.PlineName + ",投入物料:" + fPlEntity.InMaterialDesc + ",产出物料:" + fPlEntity.OutMaterialDesc + "),不能删除!");
  210. return;
  211. }
  212. fPlEntity.CreateName = UserInfo.GetUserName();
  213. fPlEntity.UpdateName = UserInfo.GetUserName();
  214. list.Add(JSONFormat.Format( fPlEntity));
  215. }
  216. string message = "";
  217. if (flag.Equals("0"))
  218. {
  219. message = "是否新增记录?";
  220. }
  221. else if (flag.Equals("1"))
  222. {
  223. message = "是否修改记录?";
  224. }
  225. else
  226. {
  227. message = "此操作不可恢复,是否删除记录?";
  228. }
  229. if (MessageUtil.ShowYesNoAndQuestion(message) == DialogResult.No)
  230. {
  231. return;
  232. }
  233. ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMaterialIPl.saveGjxPl", new object[] { list, flag }, ob);
  234. DoQuery();
  235. MessageUtil.ShowTips("操作成功!");
  236. }
  237. private bool CheckIsExist(string plineCode,string inMaterialNo,string outMaterialNo)
  238. {
  239. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMaterialIPl.checkIsExist", new object[] { plineCode, inMaterialNo, outMaterialNo }, this.ob);
  240. if (dt != null && dt.Rows.Count > 0)
  241. {
  242. return true;
  243. }
  244. else
  245. {
  246. return false;
  247. }
  248. }
  249. private void ultraGridJgx_AfterRowInsert(object sender, RowEventArgs e)
  250. {
  251. UltraGridRow ugr = e.Row;
  252. ugr.Cells["InMaterialDesc"].Value = _inMaterialDesc;
  253. ugr.Cells["InMaterialNo"].Value = _inMaterialNo;
  254. ugr.Cells["OutMaterialDesc"].Value = _outMaterialDesc;
  255. ugr.Cells["OutMaterialNo"].Value = _outMaterialNo;
  256. ugr.Cells["DisableFl"].Value = "False";
  257. }
  258. private void ultraGridJgx_CellChange(object sender, CellEventArgs e)
  259. {
  260. ultraGridJgx.UpdateData();
  261. if (e.Cell.Column.Key.Equals("PlineCode"))
  262. {
  263. e.Cell.Row.Cells["PlineName"].Value = e.Cell.Text;
  264. }
  265. }
  266. }
  267. }