FrmBoxMainTenance.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.StlMes.Client.Mcp.CollarMaterial;
  4. using Core.StlMes.Client.Mcp.Control;
  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.Mcp.CollarMaterial
  17. {
  18. public partial class FrmBoxMainTenance : FrmBase
  19. {
  20. ArrayList list = new ArrayList();
  21. bool isValid = false;
  22. public FrmBoxMainTenance()
  23. {
  24. InitializeComponent();
  25. this.IsLoadUserView = true;
  26. }
  27. private void FrmBoxMainTenance_Load(object sender, EventArgs e)
  28. {
  29. InitComBox();
  30. getDepartMent();
  31. this.cmb_dw.Enabled = false;
  32. }
  33. /// <summary>
  34. /// 重写基类方法
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="ToolbarKey"></param>
  38. public override void ToolBar_Click(object sender, string ToolbarKey)
  39. {
  40. switch (ToolbarKey)
  41. {
  42. case "Query":
  43. DoQuery();
  44. break;
  45. case "Add":
  46. DoAdd();
  47. break;
  48. case "Update":
  49. DoUpdate();
  50. break;
  51. case "Delete":
  52. DoDeleteOrResume(true);
  53. break;
  54. case "Resume":
  55. DoDeleteOrResume(false);
  56. break;
  57. case "Refresh":
  58. DoRefresh();
  59. break;
  60. case "Export":
  61. GridHelper.ulGridToExcel(ultraGrid1, "框号维护");
  62. break;
  63. case "Close":
  64. this.Close();
  65. break;
  66. }
  67. }
  68. /// <summary>
  69. /// 刷新
  70. /// </summary>
  71. private void DoRefresh()
  72. {
  73. InitComBox();
  74. getDepartMent();
  75. }
  76. private void getDepartMent()
  77. {
  78. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.coup.FrmBoxMainTenance.doQueryData", new object[] { "1" }, this.ob);
  79. cmb_dw.DataSource = dt;
  80. cmb_dw.DisplayMember = "DEPARTNAME";
  81. cmb_dw.ValueMember = "DEPARTID";
  82. this.cmb_dw.SelectedIndex = -1;
  83. cmbManage1.DataSource = dt;
  84. cmbManage1.DisplayMember = "DEPARTNAME";
  85. cmbManage1.ValueMember = "DEPARTID";
  86. }
  87. /// <summary>
  88. /// 初始化下拉框
  89. /// </summary>
  90. private void InitComBox()
  91. {
  92. YdmBaseClass.InitComboEditor(cmbRackType, "com.steering.mes.mcp.coup.FrmBoxMainTenance.getRackType", "BASECODE", this.ob, true);
  93. YdmBaseClass.InitComboEditor(cmbType1, "com.steering.mes.mcp.coup.FrmBoxMainTenance.getRackType", "BASECODE", this.ob, false);
  94. }
  95. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  96. {
  97. if (ultraCheckEditor1.Checked)
  98. {
  99. cmbRackType.ReadOnly = false;
  100. }
  101. else
  102. {
  103. cmbRackType.ReadOnly = true;
  104. }
  105. }
  106. /// <summary>
  107. /// 获取编辑区的数据
  108. /// </summary>
  109. private bool GetData()
  110. {
  111. list = new ArrayList();
  112. if (cmbType1.SelectedItem == null)
  113. {
  114. MessageBox.Show("请选择框号类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  115. return false;
  116. }
  117. if (cmbManage1.SelectedItem == null)
  118. {
  119. MessageBox.Show("请选择所属单位", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  120. return false;
  121. }
  122. //if (txtRackWidth.Value == null)
  123. //{
  124. // MessageBox.Show("请输入框号宽度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  125. // return false;
  126. //}
  127. //if (txtRackHeight.Value == null)
  128. //{
  129. // MessageBox.Show("请输入框号高度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  130. // return false;
  131. //}
  132. //if (txtRackLen.Value == null)
  133. //{
  134. // MessageBox.Show("请输入框号长度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  135. // return false;
  136. //}
  137. list.Add(cmbType1.Text.Trim()); //用于编码类型
  138. list.Add(cmbType1.Text.Trim()); //框号类型
  139. list.Add(txtRackWidth.Value.ToString());
  140. list.Add(txtRackHeight.Value.ToString());
  141. list.Add(txtRackLen.Value.ToString());
  142. list.Add(cmbManage1.Value.ToString());
  143. list.Add(cmbManage1.Text.Trim());
  144. list.Add(txtMemo.Text.Trim());
  145. list.Add(this.UserInfo.GetUserName());
  146. return true;
  147. }
  148. /// <summary>
  149. /// 新增数据
  150. /// </summary>
  151. private void DoAdd()
  152. {
  153. if (!GetData()) return;
  154. if (list.Count <= 0)
  155. return;
  156. int count = ServerHelper.SetData("com.steering.mes.mcp.coup.FrmBoxMainTenance.doAdd", new Object[] { list }, this.ob);
  157. if (count > 0)
  158. {
  159. MessageBox.Show("数据新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  160. DoQuery();
  161. }
  162. }
  163. /// <summary>
  164. /// 查询
  165. /// </summary>
  166. private void DoQuery()
  167. {
  168. string manage = "";
  169. string racktype = "";
  170. if (this.ultraCheckEditor2.Checked)
  171. {
  172. if (string.IsNullOrEmpty(cmb_dw.Text.Trim()))
  173. {
  174. MessageBox.Show("请选择框号所属单位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  175. return;
  176. }
  177. else
  178. {
  179. manage = cmb_dw.Text.ToString();
  180. }
  181. }
  182. else
  183. {
  184. manage = "";
  185. }
  186. if (cmbRackType.SelectedItem != null && cmbRackType.Text != "")
  187. racktype = cmbRackType.Text;
  188. else
  189. racktype = "%";
  190. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.coup.FrmBoxMainTenance.doQuery", new Object[] { manage, racktype, isValid }, this.ob);
  191. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  192. YdmBaseClass.SetGridRowColor(ultraGrid1);
  193. YdmBaseClass.SetGridActivateOnly(ultraGrid1);
  194. YdmBaseClass.SetColAutoSizeExceptMemo(ultraGrid1);
  195. //gdRack.DisplayLayout.Bands[0].Columns["CREATE_TIME"].SortIndicator = SortIndicator.Ascending;
  196. }
  197. /// <summary>
  198. /// 更新数据
  199. /// </summary>
  200. private void DoUpdate()
  201. {
  202. this.ultraGrid1.UpdateData();
  203. UltraGridRow ugr = ultraGrid1.ActiveRow;
  204. if (ugr == null)
  205. {
  206. MessageBox.Show("请选择需要修改的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  207. return;
  208. }
  209. string rackNo = ugr.Cells["KEP_NO"].Text.ToString();
  210. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.coup.FrmBoxMainTenance.getReferRack", new object[] { rackNo }, this.ob);
  211. if (dt.Rows.Count > 0)
  212. {
  213. if (dt.Rows[0]["VALIDFLAG"].ToString() == "0")
  214. {
  215. MessageBox.Show("无效数据,无法修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  216. return;
  217. }
  218. }
  219. if (!GetData()) return;
  220. string newrackno = "";
  221. if (list.Count > 0)
  222. {
  223. string rackno = ugr.Cells["KEP_NO"].Value.ToString();
  224. newrackno = rackno.Replace(rackno.Substring(0, 1), cmbType1.Text.Trim());
  225. list.RemoveAt(0);
  226. list.Add(newrackno);
  227. list.Add(rackno);
  228. }
  229. if (MessageBox.Show("是否确认修改该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  230. {
  231. return;
  232. }
  233. int count = ServerHelper.SetData("com.steering.mes.mcp.coup.FrmBoxMainTenance.doUpdate", new Object[] { list }, this.ob);
  234. if (count > 0)
  235. {
  236. MessageBox.Show("数据修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  237. DoQuery();
  238. }
  239. }
  240. /// <summary>
  241. /// 行激活事件
  242. /// </summary>
  243. /// <param name="sender"></param>
  244. /// <param name="e"></param>
  245. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  246. {
  247. this.ultraGrid1.UpdateData();
  248. UltraGridRow ugr = ultraGrid1.ActiveRow;
  249. if (ugr == null)
  250. {
  251. return;
  252. }
  253. string rackno = ugr.Cells["KEP_NO"].Value.ToString();
  254. txtRacknoHead.Value = rackno.Substring(0, 1);
  255. txtRacknoTail.Value = rackno.Substring(1, 5);
  256. cmbType1.Text = ugr.Cells["KEP_TYPE"].Value.ToString();
  257. this.cmbManage1.Text = ugr.Cells["HL_MANAGEMENT_NAME"].Text.ToString();
  258. txtRackWidth.Value = ugr.Cells["KEP_WIDTH"].Value.ToString();
  259. txtRackHeight.Value = ugr.Cells["KEP_HEIGHT"].Value.ToString();
  260. txtRackLen.Value = ugr.Cells["KEP_LEN"].Value.ToString();
  261. txtMemo.Value = ugr.Cells["MEMO"].Value.ToString();
  262. }
  263. /// <summary>
  264. /// 作废或恢复数据
  265. /// </summary>
  266. /// <param name="flag">true 作废 false 恢复</param>
  267. private void DoDeleteOrResume(bool flag)
  268. {
  269. UltraGridRow ugr = ultraGrid1.ActiveRow;
  270. if (ugr == null)
  271. {
  272. MessageBox.Show("请选择你要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  273. return;
  274. }
  275. if (flag == false && ugr.Cells["VALIDFLAG"].Value.ToString().ToUpper() == "有效")
  276. {
  277. MessageBox.Show("有效数据,无法恢复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  278. return;
  279. }
  280. if (flag == true && ugr.Cells["VALIDFLAG"].Value.ToString().ToUpper() != "有效")
  281. {
  282. MessageBox.Show("无效数据,无法作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  283. return;
  284. }
  285. if (MessageBox.Show("是否确认" + (flag ? "作废" : "恢复") + "该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  286. {
  287. return;
  288. }
  289. string rackno = ugr.Cells["KEP_NO"].Value.ToString();
  290. //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.coup.FrmBoxMainTenance.getReferRack", new object[] { rackno }, this.ob);
  291. //if (dt.Rows.Count > 0)
  292. //{
  293. // if (dt.Rows[0]["VALIDFLAG"].ToString() == "1")
  294. // {
  295. // MessageBox.Show("有效数据,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  296. // return;
  297. // }
  298. //}
  299. string name = this.UserInfo.GetUserName();
  300. int count = ServerHelper.SetData("com.steering.mes.mcp.coup.FrmBoxMainTenance.doDelete", new Object[] { rackno, name, flag }, this.ob);
  301. if (count > 0)
  302. {
  303. MessageBox.Show("数据" + (flag ? "作废" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  304. DoQuery();
  305. }
  306. }
  307. private void chkValid_CheckedChanged(object sender, EventArgs e)
  308. {
  309. if (chkValid.Checked)
  310. {
  311. isValid = true;
  312. }
  313. else
  314. {
  315. isValid = false;
  316. }
  317. }
  318. private void ultraCheckEditor2_CheckedChanged(object sender, EventArgs e)
  319. {
  320. this.cmb_dw.Enabled = this.ultraCheckEditor2.Checked;
  321. }
  322. }
  323. }