FrmCarEff.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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 Core.Mes.Client.Comm.Control;
  10. using Core.Mes.Client.Comm.Format;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Core.StlMes.Client.LgResMgt.Mcms.entity;
  13. using CoreFS.CA06;
  14. namespace Core.StlMes.Client.LgResMgt.Mcms
  15. {
  16. public partial class FrmCarEff : FrmBase
  17. {
  18. public FrmCarEff()
  19. {
  20. InitializeComponent();
  21. }
  22. protected override void OnLoad(EventArgs e)
  23. {
  24. base.OnLoad(e);
  25. EntityHelper.ShowGridCaption<CmmCarEffEntity>(ugData.DisplayLayout.Bands[0]);
  26. DoQuery();
  27. }
  28. public override void ToolBar_Click(object sender, string ToolbarKey)
  29. {
  30. switch (ToolbarKey)
  31. {
  32. case "DoQuery":
  33. DoQuery();
  34. break;
  35. case "DoUpdate":
  36. DoUpdate();
  37. break;
  38. case "DoAdd":
  39. DoAdd();
  40. break;
  41. case "DoDelete":
  42. DoDelete();
  43. break;
  44. case "DoRecover":
  45. DoRecover();
  46. break;
  47. case "Export":
  48. GridHelper.ulGridToExcel(ugData, "内倒车辆");
  49. break;
  50. case "DoClose":
  51. Close();
  52. break;
  53. }
  54. }
  55. private void DoRecover()
  56. {
  57. if (ugData.ActiveRow == null)
  58. {
  59. MessageBox.Show("请选择需要还原的车辆数据");
  60. return;
  61. };
  62. CmmCarEffEntity data = ugData.ActiveRow.ListObject as CmmCarEffEntity;
  63. CmmCarEffEntity data1 = new CmmCarEffEntity()
  64. {
  65. CarNo = data.CarNo,
  66. UpdateName = this.UserInfo.GetUserName()
  67. };
  68. var ccp = new CoreClientParam
  69. {
  70. ServerName = "com.steering.Mcms.CarEffServer",
  71. MethodName = "DoRecover",
  72. ServerParams = new object[]
  73. {
  74. JSONFormat.Format(data1),
  75. }
  76. };
  77. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  78. if (ccp.ReturnCode != -1)
  79. {
  80. if (ccp.ReturnInfo.ToString2().Contains("成功"))
  81. {
  82. MessageBox.Show("成功还原车辆" + data.CarNo);
  83. DoQuery();
  84. }
  85. else
  86. {
  87. MessageUtil.ShowTips(ccp.ReturnInfo);
  88. }
  89. }
  90. }
  91. private void DoDelete()
  92. {
  93. if (ugData.ActiveRow == null)
  94. {
  95. MessageBox.Show("请选择需要作废的车辆数据");
  96. return;
  97. };
  98. CmmCarEffEntity data = ugData.ActiveRow.ListObject as CmmCarEffEntity;
  99. CmmCarEffEntity data1 = new CmmCarEffEntity()
  100. {
  101. CarNo = data.CarNo,
  102. DeleteName = this.UserInfo.GetUserName()
  103. };
  104. var ccp = new CoreClientParam
  105. {
  106. ServerName = "com.steering.Mcms.CarEffServer",
  107. MethodName = "DoDelete",
  108. ServerParams = new object[]
  109. {
  110. JSONFormat.Format(data1),
  111. }
  112. };
  113. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  114. if (ccp.ReturnCode != -1)
  115. {
  116. if (ccp.ReturnInfo.ToString2().Contains("成功"))
  117. {
  118. MessageBox.Show("成功作废车辆" + data.CarNo);
  119. DoQuery();
  120. }
  121. else
  122. {
  123. MessageUtil.ShowTips(ccp.ReturnInfo);
  124. }
  125. }
  126. }
  127. private void DoUpdate()
  128. {
  129. if (String.IsNullOrWhiteSpace(uteCarNoEdit.Text))
  130. {
  131. MessageBox.Show("车牌号不能为空!");
  132. return;
  133. }
  134. if (String.IsNullOrWhiteSpace(uneTimeEff.Text))
  135. {
  136. MessageBox.Show("车牌皮重时效不能为空!");
  137. return;
  138. }
  139. CmmCarEffEntity data = new CmmCarEffEntity()
  140. {
  141. CarNo = uteCarNoEdit.Text,
  142. UpdateName = this.UserInfo.GetUserName(),
  143. TimeEff = decimal.Parse(uneTimeEff.Value.ToString3()),
  144. Id = uteId.Text
  145. };
  146. var ccp = new CoreClientParam
  147. {
  148. ServerName = "com.steering.Mcms.CarEffServer",
  149. MethodName = "DoUpdate",
  150. ServerParams = new object[]
  151. {
  152. JSONFormat.Format(data),
  153. }
  154. };
  155. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  156. if (ccp.ReturnCode != -1)
  157. {
  158. if (ccp.ReturnInfo.ToString2().Contains("成功"))
  159. {
  160. MessageBox.Show("成功更新车辆" + data.CarNo);
  161. DoQuery();
  162. }
  163. else
  164. {
  165. MessageUtil.ShowTips(ccp.ReturnInfo);
  166. }
  167. }
  168. }
  169. private void DoAdd()
  170. {
  171. if (String.IsNullOrWhiteSpace(uteCarNoEdit.Text))
  172. {
  173. MessageBox.Show("车牌号不能为空!");
  174. return;
  175. }
  176. if (String.IsNullOrWhiteSpace(uneTimeEff.Text))
  177. {
  178. MessageBox.Show("车牌皮重时效不能为空!");
  179. return;
  180. }
  181. CmmCarEffEntity data = new CmmCarEffEntity()
  182. {
  183. CarNo = uteCarNoEdit.Text,
  184. CreateName = this.UserInfo.GetUserName(),
  185. TimeEff = decimal.Parse(uneTimeEff.Value.ToString3())
  186. };
  187. var ccp = new CoreClientParam
  188. {
  189. ServerName = "com.steering.Mcms.CarEffServer",
  190. MethodName = "DoAdd",
  191. ServerParams = new object[]
  192. {
  193. JSONFormat.Format(data),
  194. }
  195. };
  196. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  197. if (ccp.ReturnCode != -1)
  198. {
  199. if (ccp.ReturnInfo.ToString2().Contains("成功"))
  200. {
  201. MessageBox.Show("成功新增车辆" + data.CarNo);
  202. DoQuery();
  203. }
  204. else
  205. {
  206. MessageUtil.ShowTips(ccp.ReturnInfo);
  207. }
  208. }
  209. }
  210. private void DoQuery()
  211. {
  212. var dic = new Dictionary<string, object>();
  213. dic.Add("carNo", uteCarNo.Text);
  214. if (chkValidflag.Checked)
  215. {
  216. dic.Add("validflag", new List<string>() {"1", "0"});
  217. }
  218. else
  219. {
  220. dic.Add("validflag", new List<string>() { "1" });
  221. }
  222. cmmCarEffEntityBindingSource.DataSource = EntityHelper.GetData<CmmCarEffEntity>(
  223. "com.steering.Mcms.CarEffServer.doQuery",
  224. new object[] { dic },
  225. ob);
  226. Comm.RefreshAndAutoSize(ugData);
  227. }
  228. private void ugData_AfterRowActivate(object sender, EventArgs e)
  229. {
  230. if(ugData.ActiveRow==null) return;
  231. CmmCarEffEntity data = ugData.ActiveRow.ListObject as CmmCarEffEntity;
  232. uteCarNoEdit.Text = data.CarNo;
  233. uneTimeEff.Value = data.TimeEff;
  234. uteId.Text = data.Id;
  235. }
  236. private void ugData_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  237. {
  238. CmmCarEffEntity data = e.Row.ListObject as CmmCarEffEntity;
  239. if (data != null)
  240. {
  241. if(data.Validflag=="0") e.Row.Cells["Validflag"].Appearance.BackColor= Color.Red;
  242. }
  243. }
  244. }
  245. }