FrmBaseCrane.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.YdmBcPipeManage.Entity;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. namespace Core.StlMes.Client.YdmBcPipeManage
  17. {
  18. public partial class FrmBaseCrane : FrmBase
  19. {
  20. public FrmBaseCrane()
  21. {
  22. InitializeComponent();
  23. }
  24. private void FrmBaseCrane_Load(object sender, EventArgs e)
  25. {
  26. EntityHelper.ShowGridCaption<YdmBsMaxwgtEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  27. }
  28. /// <summary>
  29. /// 重写基类方法
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="ToolbarKey"></param>
  33. public override void ToolBar_Click(object sender, string ToolbarKey)
  34. {
  35. switch (ToolbarKey)
  36. {
  37. case "Query":
  38. doQuery();
  39. break;
  40. case "Add":
  41. doAdd();
  42. break;
  43. case "Update":
  44. doUpdate();
  45. break;
  46. case"Delete":
  47. deleteData();
  48. break;
  49. case "Close":
  50. close();
  51. break;
  52. }
  53. }
  54. /// <summary>
  55. /// 查询
  56. /// </summary>
  57. private void doQuery()
  58. {
  59. string storageNo = "";
  60. if (this.userChk.Checked && this.txtStorageNo.Text != "")
  61. {
  62. storageNo = this.txtStorageNo.Text.Trim();
  63. }
  64. ArrayList parmList = new ArrayList();
  65. parmList.Add(storageNo);
  66. List<YdmBsMaxwgtEntity> listSource = EntityHelper.GetData<YdmBsMaxwgtEntity>("com.steering.ydm.bc.FrmBaseCrane.doQuery", new object[] { parmList }, ob);
  67. ydmBsMaxwgtEntityBindingSource.DataSource = listSource;
  68. }
  69. /// <summary>
  70. /// 新增
  71. /// </summary>
  72. private void doAdd()
  73. {
  74. ArrayList parmList = new ArrayList();
  75. if(this.chkStorageNo.Text == "")
  76. {
  77. MessageUtil.ShowTips("请选中对应的库区信息!");
  78. return;
  79. }
  80. if (this.uComUnload.Text == "")
  81. {
  82. MessageUtil.ShowTips("请选中对应的装卸点信息!");
  83. return;
  84. }
  85. if (this.txtMaxWgt.Text.Trim() == "")
  86. {
  87. MessageUtil.ShowTips("吊装最大载重不能为空!");
  88. return;
  89. }
  90. else
  91. {
  92. if (!StringUtil.IsFloat(this.txtMaxWgt.Text.Trim()))
  93. {
  94. MessageUtil.ShowTips("请输入正确的载重数!");
  95. return;
  96. }
  97. }
  98. YdmBsMaxwgtEntity ydmBsWt = new YdmBsMaxwgtEntity();
  99. ydmBsWt.StorageNo = this.chkStorageNo.Tag.ToString2();
  100. ydmBsWt.StorageName = this.chkStorageNo.Text.ToString2();
  101. ydmBsWt.UnloadingCode = this.uComUnload.Value.ToString2();
  102. ydmBsWt.UnloadingDesc = this.uComUnload.Text.ToString2();
  103. ydmBsWt.MaxWgt = this.txtMaxWgt.Text.Trim();
  104. ydmBsWt.CreateName = this.UserInfo.GetUserName();
  105. string ydmBsEntity = JSONFormat.Format(ydmBsWt);
  106. CoreClientParam ccp = new CoreClientParam();
  107. ccp.ServerName = "com.steering.ydm.bc.FrmBaseCrane";
  108. ccp.MethodName = "doAdd";
  109. ccp.ServerParams = new object[] { ydmBsEntity };
  110. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  111. if (ccp.ReturnCode != -1)
  112. {
  113. if (ccp.ReturnInfo.Equals("新增成功!"))
  114. {
  115. doQuery();
  116. MessageUtil.ShowTips(ccp.ReturnInfo);
  117. }
  118. else
  119. {
  120. MessageUtil.ShowTips(ccp.ReturnInfo);
  121. }
  122. }
  123. }
  124. /// <summary>
  125. /// 修改
  126. /// </summary>
  127. private void doUpdate()
  128. {
  129. this.ultraGrid1.UpdateData();
  130. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  131. if (uRow == null) return;
  132. YdmBsMaxwgtEntity ydmBsEntity = (YdmBsMaxwgtEntity)uRow.ListObject;
  133. if (this.txtMaxWgt.Text.Trim() == "")
  134. {
  135. MessageUtil.ShowTips("吊装最大载重不能为空!");
  136. return;
  137. }
  138. else
  139. {
  140. if (!StringUtil.IsFloat(this.txtMaxWgt.Text.Trim()))
  141. {
  142. MessageUtil.ShowTips("请输入正确的载重数!");
  143. return;
  144. }
  145. }
  146. ydmBsEntity.MaxWgt = this.txtMaxWgt.Text.Trim();
  147. ydmBsEntity.UpdateName = this.UserInfo.GetUserName();
  148. string ydmBsTity = JSONFormat.Format(ydmBsEntity);
  149. CoreClientParam ccp = new CoreClientParam();
  150. ccp.ServerName = "com.steering.ydm.bc.FrmBaseCrane";
  151. ccp.MethodName = "doUpdate";
  152. ccp.ServerParams = new object[] { ydmBsTity };
  153. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  154. if (ccp.ReturnCode != -1)
  155. {
  156. if (ccp.ReturnInfo.Equals("修改成功!"))
  157. {
  158. doQuery();
  159. MessageUtil.ShowTips(ccp.ReturnInfo);
  160. }
  161. else
  162. {
  163. MessageUtil.ShowTips(ccp.ReturnInfo);
  164. }
  165. }
  166. }
  167. /// <summary>
  168. /// 删除
  169. /// </summary>
  170. private void deleteData()
  171. {
  172. this.ultraGrid1.UpdateData();
  173. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  174. if (uRow == null) return;
  175. YdmBsMaxwgtEntity ydmBsEntity = (YdmBsMaxwgtEntity)uRow.ListObject;
  176. string ydmBsTity = JSONFormat.Format(ydmBsEntity);
  177. CoreClientParam ccp = new CoreClientParam();
  178. ccp.ServerName = "com.steering.ydm.bc.FrmBaseCrane";
  179. ccp.MethodName = "deleteData";
  180. ccp.ServerParams = new object[] { ydmBsTity };
  181. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  182. if (ccp.ReturnCode != -1)
  183. {
  184. if (ccp.ReturnInfo.Equals("删除成功!"))
  185. {
  186. doQuery();
  187. MessageUtil.ShowTips(ccp.ReturnInfo);
  188. }
  189. else
  190. {
  191. MessageUtil.ShowTips(ccp.ReturnInfo);
  192. }
  193. }
  194. }
  195. private void close()
  196. {
  197. this.close();
  198. }
  199. private void userChk_CheckedChanged(object sender, EventArgs e)
  200. {
  201. this.txtStorageNo.Enabled = this.userChk.Checked;
  202. }
  203. private void chkStorageNo_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  204. {
  205. DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmSupervisonInfo.doQueryStorageNo",
  206. new object[] { }, ob);
  207. dt.Columns["STORAGE_NAME"].Caption = "库区";
  208. BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "STORAGE_NAME", "STORAGE_NO");
  209. baseInfo.Shown += new EventHandler((a, b) =>
  210. {
  211. var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where(
  212. c => c.GetValue("STORAGE_NO") == this.chkStorageNo.Tag.ToString2()).FirstOrDefault();
  213. if (actRow != null) actRow.Activate();
  214. });
  215. if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  216. {
  217. chkStorageNo.Tag = baseInfo.ChoicedRow.GetValue("STORAGE_NO");
  218. chkStorageNo.Text = baseInfo.ChoicedRow.GetValue("STORAGE_NAME");
  219. }
  220. }
  221. private void chkStorageNo_ValueChanged(object sender, EventArgs e)
  222. {
  223. DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmBaseCrane.doQueryUnLoad", new object[] {this.chkStorageNo.Tag.ToString2() }, this.ob);
  224. if (dt.Rows.Count > 0)
  225. {
  226. uComUnload.DataSource = dt;
  227. uComUnload.DisplayMember = "UNLOADING_DESC";
  228. uComUnload.ValueMember = "UNLOADING_CODE";
  229. }
  230. }
  231. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  232. {
  233. UltraGridRow row = this.ultraGrid1.ActiveRow;
  234. this.chkStorageNo.Tag = row.Cells["StorageNo"].Text;
  235. this.chkStorageNo.Text = row.Cells["StorageName"].Text;
  236. this.uComUnload.Value = row.Cells["UnloadingCode"].Text;
  237. this.uComUnload.Text = row.Cells["UnloadingDesc"].Text;
  238. this.txtMaxWgt.Text = row.Cells["MaxWgt"].Text;
  239. }
  240. }
  241. }