FrmShiftItems.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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 System.Collections;
  10. using Infragistics.Win.UltraWinGrid;
  11. using CoreFS.CA06;
  12. using Core.StlMes.Client.LgCommon;
  13. using Infragistics.Win.UltraWinEditors;
  14. namespace Core.StlMes.Client.LgIntegrationQuery
  15. {
  16. public partial class FrmShiftItems : Core.StlMes.Client.LgCommon.frmStyleBase
  17. {
  18. private bool ok_flag = false;
  19. private bool refreshflag = true;
  20. public FrmShiftItems(OpeBase oba)
  21. {
  22. InitializeComponent();
  23. this.ob = oba;
  24. }
  25. private void FrmShiftItems_Load(object sender, EventArgs e)
  26. {
  27. shiftConfigQuery();
  28. SetColumnModeClass(ugdShift);
  29. }
  30. // 查询班次配置的信息
  31. /// <summary>
  32. /// 查询班次配置的信息
  33. /// </summary>
  34. private void shiftConfigQuery()
  35. {
  36. try
  37. {
  38. string strErr = "";
  39. ArrayList arry = new ArrayList();
  40. CommonClientToServer ccTos = new CommonClientToServer();
  41. ccTos.ob = this.ob;
  42. DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  43. "QueryWithParameter", "STL_CON0002", 5, arry, out strErr);
  44. if (strErr == "" && ds != null)
  45. {
  46. udsConfig.Rows.Clear();
  47. if (ds.Tables.Count > 0)
  48. {
  49. foreach (DataRow dr in ds.Tables[0].Rows)
  50. {
  51. udsConfig.Rows.Add(new object[] {
  52. dr["ID"].ToString(),
  53. dr["SHIFTNAME"].ToString(),
  54. dr["SHIFTTYPE"].ToString(),
  55. dr["SHIFTTYPENAME"].ToString(),
  56. dr["CYCLES"].ToString(),
  57. dr["OPTPERSONNEL"].ToString(),
  58. dr["OPTPERDATE"].ToString()
  59. }
  60. );
  61. }
  62. }
  63. PublicMethod.RefreshAndAutoSize(ugdConfig);
  64. }
  65. else
  66. MessageBox.Show("信息查询失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  67. }
  68. catch { }
  69. }
  70. // 查询具体配置的信息
  71. /// <summary>
  72. /// 查询具体配置的信息
  73. /// </summary>
  74. private void DetailConfigQuery(String strID)
  75. {
  76. try
  77. {
  78. string strErr = "";
  79. ArrayList arry = new ArrayList();
  80. arry.Add(strID);
  81. CommonClientToServer ccTos = new CommonClientToServer();
  82. ccTos.ob = this.ob;
  83. DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  84. "QueryWithParameter", "STL_CON0003", 5, arry, out strErr);
  85. if (strErr == "" && ds != null)
  86. {
  87. udsShift.Rows.Clear();
  88. if (ds.Tables.Count > 0)
  89. {
  90. foreach (DataRow dr in ds.Tables[0].Rows)
  91. {
  92. udsShift.Rows.Add(new object[] {
  93. dr["CURDATE"].ToString(),
  94. dr["FUNC"].ToString(),
  95. dr["NO1"].ToString(),
  96. dr["NO2"].ToString(),
  97. dr["NO3"].ToString(),
  98. dr["NO4"].ToString()
  99. }
  100. );
  101. }
  102. }
  103. // PublicMethod.RefreshAndAutoSize(ugdShift);
  104. }
  105. else
  106. MessageBox.Show("信息查询失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  107. }
  108. catch { }
  109. }
  110. // 查询配置方案的最大id
  111. /// <summary>
  112. /// 查询配置方案的最大id
  113. /// </summary>
  114. private string MaxIDQuery()
  115. {
  116. try
  117. {
  118. string strInfo = "";
  119. string strErr = "";
  120. ArrayList arry = new ArrayList();
  121. CommonClientToServer ccTos = new CommonClientToServer();
  122. ccTos.ob = this.ob;
  123. DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  124. "QueryWithParameter", "STL_CON0006", 5, arry, out strErr);
  125. if (strErr == "" && ds != null)
  126. {
  127. if (ds.Tables.Count > 0)
  128. {
  129. strInfo = ds.Tables[0].Rows[0]["MAXID"].ToString();
  130. }
  131. }
  132. else
  133. MessageBox.Show("信息查询失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  134. return strInfo;
  135. }
  136. catch { return ""; }
  137. }
  138. // 执行排班操作
  139. /// <summary>
  140. /// 执行排班操作
  141. /// </summary>
  142. private void proc_Exe()
  143. {
  144. try
  145. {
  146. if (textName.Text.Length == 0)
  147. {
  148. MessageBox.Show("方案名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  149. textName.Focus();
  150. return;
  151. }
  152. if (cboShift1.SelectedIndex < 0 || cboShift2.SelectedIndex < 0)
  153. {
  154. MessageBox.Show("排班类型不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  155. cboShift1.Focus();
  156. return;
  157. }
  158. if (udtBeginTime.Value == null)
  159. {
  160. MessageBox.Show("开始时间不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  161. udtBeginTime.Focus();
  162. return;
  163. }
  164. if (cboJia.SelectedIndex < 0)
  165. {
  166. MessageBox.Show("甲班不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  167. cboJia.Focus();
  168. return;
  169. }
  170. if (cboYi.SelectedIndex < 0)
  171. {
  172. MessageBox.Show("乙班不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  173. cboYi.Focus();
  174. return;
  175. }
  176. if (cboBing.SelectedIndex < 0)
  177. {
  178. MessageBox.Show("丙班不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  179. cboBing.Focus();
  180. return;
  181. }
  182. if (cboDing.SelectedIndex < 0)
  183. {
  184. MessageBox.Show("丁班不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  185. cboDing.Focus();
  186. return;
  187. }
  188. int nJ = cboJia.SelectedIndex; //甲班
  189. int nY = cboYi.SelectedIndex; //乙班
  190. int nB = cboBing.SelectedIndex; //丙班
  191. int nD = cboDing.SelectedIndex; //丁班
  192. int nCount = 0;
  193. int nCount1 = 0;
  194. string strName = textName.Text.Trim();
  195. int tBZ = Convert.ToInt16(cboShift1.Value.ToString()); //总共班组
  196. int yBZ = Convert.ToInt16(cboShift2.Value.ToString()); //运转班组
  197. int cycles = Convert.ToInt16(numericUpDown1.Value); //循环次数
  198. DateTime dt = Convert.ToDateTime(udtBeginTime.Value);
  199. if (yBZ == 3)
  200. {
  201. if (nJ == 0)
  202. {
  203. nCount++;
  204. }
  205. else
  206. {
  207. nCount1++;
  208. }
  209. if (nY == 0)
  210. {
  211. nCount++;
  212. }
  213. else
  214. {
  215. nCount1++;
  216. }
  217. if (nB == 0)
  218. {
  219. nCount++;
  220. }
  221. else
  222. {
  223. nCount1++;
  224. }
  225. if (nD == 0)
  226. {
  227. nCount++;
  228. }
  229. else
  230. {
  231. nCount1++;
  232. }
  233. if (nCount > 1)
  234. {
  235. MessageBox.Show("你选择了三运转至少要选择三个班!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  236. return;
  237. }
  238. if (nCount1 > 3)
  239. {
  240. MessageBox.Show("你选择了三运转最多只能选择三个班!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  241. return;
  242. }
  243. }
  244. cboShift1.Value.ToString();
  245. if (udsConfig.Rows.Count == 0)
  246. {
  247. udsConfig.Rows.Add(new object[] {
  248. "",
  249. strName,
  250. tBZ.ToString()+yBZ.ToString(),
  251. cboShift1.SelectedItem.DisplayText.ToString()+cboShift2.SelectedItem.DisplayText.ToString(),
  252. cycles.ToString(),
  253. "",
  254. ""});
  255. }
  256. for (int i = 0; i < cycles; i++)
  257. {
  258. udsShift.Rows.Add(new object[] {
  259. dt.ToString("yyyy-MM-dd"),
  260. "",
  261. cboJia.Value.ToString(),
  262. cboYi.Value.ToString(),
  263. cboBing.Value.ToString(),
  264. cboDing.Value.ToString()});
  265. dt = dt.AddDays(1);
  266. }
  267. udtBeginTime.Value = dt;
  268. cboJia.SelectedIndex = 0;
  269. cboYi.SelectedIndex = 0;
  270. cboBing.SelectedIndex = 0;
  271. cboDing.SelectedIndex = 0;
  272. }
  273. catch { }
  274. }
  275. // 新增配置方案
  276. /// <summary>
  277. /// 新增配置方案
  278. /// </summary>
  279. private void proc_Add()
  280. {
  281. try
  282. {
  283. if (ugdConfig.Rows.Count == 0)
  284. {
  285. MessageBox.Show("配置方案不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  286. return;
  287. }
  288. if (ugdShift.Rows.Count == 0)
  289. {
  290. MessageBox.Show("具体方案不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  291. return;
  292. }
  293. ArrayList listDate = new ArrayList();
  294. ArrayList listNo1 = new ArrayList();
  295. ArrayList listNo2 = new ArrayList();
  296. ArrayList listNo3 = new ArrayList();
  297. ArrayList listNo4 = new ArrayList();
  298. string strName = ugdConfig.Rows[0].Cells["SHIFTNAME"].Value.ToString();
  299. string vType = ugdConfig.Rows[0].Cells["SHIFTTYPE"].Value.ToString(); //运转班组
  300. string vTypeName = ugdConfig.Rows[0].Cells["SHIFTTYPENAME"].Value.ToString(); //运转班组名称
  301. string cycles = ugdConfig.Rows[0].Cells["CYCLES"].Value.ToString(); //循环次数
  302. for (int i = 0; i < ugdShift.Rows.Count; i++)
  303. {
  304. listDate.Add(ugdShift.Rows[i].Cells["CURDATE"].Value.ToString());
  305. listNo1.Add(ugdShift.Rows[i].Cells["NO1"].Value.ToString());
  306. listNo2.Add(ugdShift.Rows[i].Cells["NO2"].Value.ToString());
  307. listNo3.Add(ugdShift.Rows[i].Cells["NO3"].Value.ToString());
  308. listNo4.Add(ugdShift.Rows[i].Cells["NO4"].Value.ToString());
  309. }
  310. string strErr = "";
  311. string strSqlID = "STL_CON0004"; //SQLID
  312. object[] sArgs = new object[11];
  313. sArgs[0] = strName; //方案名称
  314. sArgs[1] = vType; //运转班组
  315. sArgs[2] = vTypeName; //运转班组名称
  316. sArgs[3] = cycles; //循环次数
  317. sArgs[4] = ugdShift.Rows.Count.ToString(); //配置总数
  318. sArgs[5] = listDate; //班次日期
  319. sArgs[6] = listNo1; //甲班
  320. sArgs[7] = listNo2; //乙班
  321. sArgs[8] = listNo3; //丙班
  322. sArgs[9] = listNo4; //丁班
  323. sArgs[10] = this.UserInfo.GetUserName(); //操作人
  324. CommonClientToServer ccTs = new CommonClientToServer();
  325. ccTs.ob = ob;
  326. CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  327. "ExecProcWithCollParam", strSqlID, 5, sArgs, out strErr);
  328. if (strErr == "")
  329. {
  330. ok_flag = true;
  331. shiftConfigQuery();
  332. FrmShiftConfig frm = (FrmShiftConfig)this.Tag;
  333. frm.shiftConfigQuery();
  334. MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  335. }
  336. else
  337. MessageBox.Show("保存失败!" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  338. }
  339. catch { }
  340. }
  341. private void proc_Edit()
  342. {
  343. try
  344. {
  345. }
  346. catch { }
  347. }
  348. // 删除配置方案
  349. /// <summary>
  350. /// 删除配置方案
  351. /// </summary>
  352. private void proc_Delete()
  353. {
  354. try
  355. {
  356. if (ugdConfig.Rows.Count == 0)
  357. {
  358. MessageBox.Show("没有可以删除的配置方案!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  359. return;
  360. }
  361. if (ugdConfig.ActiveRow == null)
  362. {
  363. MessageBox.Show("请选择要删除的配置方案!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  364. return;
  365. }
  366. DialogResult dr = MessageBox.Show("是否确认删除名称为【" + ugdConfig.ActiveRow.Cells["SHIFTNAME"].Value.ToString() + "】的配置信息?",
  367. "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  368. if (dr == DialogResult.No) return;
  369. string strErr = "";
  370. string strSqlID = "STL_CON0005"; //SQLID
  371. object[] sArgs = new object[1];
  372. sArgs[0] = ugdConfig.ActiveRow.Cells["ID"].Value.ToString(); //方案ID
  373. CommonClientToServer ccTs = new CommonClientToServer();
  374. ccTs.ob = ob;
  375. CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  376. "ExecProcWithCollParam", strSqlID, 5, sArgs, out strErr);
  377. if (strErr == "")
  378. {
  379. shiftConfigQuery();
  380. FrmShiftConfig frm = (FrmShiftConfig)this.Tag;
  381. frm.shiftConfigQuery();
  382. MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  383. }
  384. else
  385. MessageBox.Show("删除失败!" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  386. }
  387. catch { }
  388. }
  389. // 测试存储方案
  390. /// <summary>
  391. /// 测试存储方案
  392. /// </summary>
  393. private void pro_Test()
  394. {
  395. try
  396. {
  397. if (textTestName.Text.Length == 0)
  398. {
  399. MessageBox.Show("没有选择配置方案!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  400. return;
  401. }
  402. DateTime dt = DateTime.Now;
  403. try
  404. {
  405. dt = Convert.ToDateTime(ute_TestTime.Text.ToString());
  406. }
  407. catch
  408. {
  409. MessageBox.Show("日期格式不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  410. return;
  411. }
  412. string strShift = "";
  413. string strErr = "";
  414. ArrayList arry = new ArrayList();
  415. arry.Add(dt.ToString("yyyy-MM-dd HH:mm:ss")); //时间
  416. arry.Add(ugdConfig.ActiveRow.Cells["ID"].Value.ToString()); //方案ID
  417. CommonClientToServer ccTos = new CommonClientToServer();
  418. ccTos.ob = this.ob;
  419. DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
  420. "QueryWithParameter", "STL_CON0010", 5, arry, out strErr);
  421. if (strErr == "" & ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  422. {
  423. strShift = ds.Tables[0].Rows[0][0].ToString();
  424. }
  425. if (strShift.Length == 2)
  426. {
  427. string strBC = "";
  428. string strBZ = "";
  429. switch (strShift.Substring(0, 1))
  430. {
  431. case "1":
  432. strBC = "白班";
  433. break;
  434. case "2":
  435. strBC = "小夜";
  436. break;
  437. case "3":
  438. strBC = "大夜";
  439. break;
  440. }
  441. switch (strShift.Substring(1, 1))
  442. {
  443. case "1":
  444. strBZ = "甲班";
  445. break;
  446. case "2":
  447. strBZ = "乙班";
  448. break;
  449. case "3":
  450. strBZ = "丙班";
  451. break;
  452. case "4":
  453. strBZ = "丁班";
  454. break;
  455. }
  456. textTextValue.Text = strBC + "-" + strBZ;
  457. }
  458. else
  459. {
  460. textTextValue.Text = "测试失败";
  461. }
  462. //string
  463. }
  464. catch { }
  465. }
  466. // 设置班组
  467. /// <summary>
  468. /// 设置班组
  469. /// </summary>
  470. /// <param name="Grid"></param>
  471. private void SetColumnModeClass(Infragistics.Win.UltraWinGrid.UltraGridBase Grid)
  472. {
  473. DataTable dt = new DataTable();
  474. dt.TableName = "CLASS";
  475. DataColumn dc = new DataColumn("BCBM", Type.GetType("System.String"));
  476. dt.Columns.Add(dc);
  477. dc = new DataColumn("BCNA", Type.GetType("System.String"));
  478. dt.Columns.Add(dc);
  479. DataRow dr = dt.NewRow();
  480. dr["BCBM"] = "0";
  481. dr["BCNA"] = "无";
  482. dt.Rows.Add(dr);
  483. dr = dt.NewRow();
  484. dr["BCBM"] = "1";
  485. dr["BCNA"] = "白班";
  486. dt.Rows.Add(dr);
  487. dr = dt.NewRow();
  488. dr["BCBM"] = "2";
  489. dr["BCNA"] = "小夜";
  490. dt.Rows.Add(dr);
  491. dr = dt.NewRow();
  492. dr["BCBM"] = "3";
  493. dr["BCNA"] = "大夜";
  494. dt.Rows.Add(dr);
  495. ClsControlPack.SetGridDropDownListCell("NO1", 0, "甲班", 60, Grid, dt, "BCBM", "BCNA");
  496. ClsControlPack.SetGridDropDownListCell("NO2", 0, "乙班", 60, Grid, dt, "BCBM", "BCNA");
  497. ClsControlPack.SetGridDropDownListCell("NO3", 0, "丙班", 60, Grid, dt, "BCBM", "BCNA");
  498. ClsControlPack.SetGridDropDownListCell("NO4", 0, "丁班", 60, Grid, dt, "BCBM", "BCNA");
  499. }
  500. // 设置编辑区域是否可编辑
  501. /// <summary>
  502. /// 设置编辑区域是否可编辑
  503. /// </summary>
  504. /// <param name="t_Enable"></param>
  505. private void setToolEnable(bool t_Enable)
  506. {
  507. try
  508. {
  509. textName.ReadOnly = t_Enable;
  510. cboShift1.ReadOnly = t_Enable;
  511. cboShift2.ReadOnly = t_Enable;
  512. numericUpDown1.ReadOnly = t_Enable;
  513. udtBeginTime.ReadOnly = t_Enable;
  514. cboJia.ReadOnly = t_Enable;
  515. cboYi.ReadOnly = t_Enable;
  516. cboBing.ReadOnly = t_Enable;
  517. cboDing.ReadOnly = t_Enable;
  518. butExe.Enabled = !t_Enable;
  519. textTestName.ReadOnly = t_Enable;
  520. ute_TestTime.ReadOnly = t_Enable;
  521. butTest.Enabled = t_Enable;
  522. }
  523. catch { }
  524. }
  525. // 清空编辑区域
  526. /// <summary>
  527. /// 清空编辑区域
  528. /// </summary>
  529. private void clearWidget()
  530. {
  531. textName.Text = "配置"+MaxIDQuery();
  532. cboShift1.SelectedIndex = 0;
  533. cboShift2.SelectedIndex = 0;
  534. numericUpDown1.Value = 1;
  535. udtBeginTime.Value = DateTime.Now.ToString("yyyy-MM-dd");
  536. cboJia.SelectedIndex = 0;
  537. cboYi.SelectedIndex = 0;
  538. cboBing.SelectedIndex = 0;
  539. cboDing.SelectedIndex = 0;
  540. }
  541. // 点击修改或删除时显示确认和取消按钮
  542. /// <summary>
  543. /// 点击修改或删除时显示确认和取消按钮
  544. /// </summary>
  545. /// <param name="bEnable"></param>
  546. private void SetDetailToolBarEnable(bool bEnable, string flag)
  547. {
  548. int count = this.uTbMTool.Tools.Count;
  549. for (int i = 0; i < count; i++)
  550. {
  551. this.uTbMTool.Tools[i].SharedProps.Enabled = !bEnable;
  552. }
  553. this.uTbMTool.Tools["ok"].SharedProps.Enabled = bEnable;
  554. this.uTbMTool.Tools["cancel"].SharedProps.Enabled = bEnable;
  555. this.uTbMTool.Tools["ok"].SharedProps.Visible = bEnable;
  556. this.uTbMTool.Tools["cancel"].SharedProps.Visible = bEnable;
  557. refreshflag = !bEnable;
  558. }
  559. private void ultraToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  560. {
  561. switch (e.Tool.Key)
  562. {
  563. case "Query":
  564. shiftConfigQuery();
  565. break;
  566. case "add":
  567. SetDetailToolBarEnable(true, "add");
  568. setToolEnable(false);
  569. this.uTbMTool.Tools["ok"].Tag = "add";
  570. clearWidget();
  571. ok_flag = false;
  572. udsConfig.Rows.Clear();
  573. udsShift.Rows.Clear();
  574. break;
  575. case "edit":
  576. if (ugdConfig.Rows.Count == 0)
  577. {
  578. MessageBox.Show("没有可修改的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  579. return;
  580. }
  581. if (ugdConfig.ActiveRow == null)
  582. {
  583. MessageBox.Show("请选择要修改的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  584. return;
  585. }
  586. SetDetailToolBarEnable(true, "edit");
  587. setToolEnable(false);
  588. this.uTbMTool.Tools["ok"].Tag = "edit";
  589. ok_flag = false;
  590. break;
  591. case "del":
  592. proc_Delete();
  593. break;
  594. case "ok":
  595. string flag = this.uTbMTool.Tools["ok"].Tag.ToString();
  596. if (flag == "edit")
  597. {
  598. proc_Edit();
  599. }
  600. if (flag == "add")
  601. {
  602. proc_Add();
  603. }
  604. if (ok_flag)
  605. {
  606. SetDetailToolBarEnable(false, "");
  607. setToolEnable(true);
  608. }
  609. break;
  610. case "cancel":
  611. SetDetailToolBarEnable(false, "");
  612. setToolEnable(true);
  613. ugdConfig_AfterRowActivate(null, null);
  614. shiftConfigQuery();
  615. break;
  616. case "left":
  617. if (ugdConfig.Rows.Count == 0) return;
  618. //将位置移动到前一条记录
  619. try
  620. {
  621. if (ugdConfig.ActiveRow == null)
  622. {
  623. ugdConfig.Rows[0].Activate();
  624. }
  625. else
  626. {
  627. int nIndex = ugdConfig.ActiveRow.Index;
  628. nIndex = nIndex - 1;
  629. if (nIndex < 0) nIndex = ugdConfig.Rows.Count - 1;
  630. ugdConfig.Rows[nIndex].Activate();
  631. }
  632. }
  633. catch { }
  634. break;
  635. case "right":
  636. if (ugdConfig.Rows.Count == 0) return;
  637. //将位置移动到后一条记录
  638. try
  639. {
  640. if (ugdConfig.ActiveRow == null)
  641. {
  642. ugdConfig.Rows[0].Activate();
  643. }
  644. else
  645. {
  646. int nIndex = ugdConfig.ActiveRow.Index;
  647. nIndex = nIndex + 1;
  648. if (nIndex >= ugdConfig.Rows.Count) nIndex = 0;
  649. ugdConfig.Rows[nIndex].Activate();
  650. }
  651. }
  652. catch { }
  653. break;
  654. }
  655. }
  656. private void butExe_Click(object sender, EventArgs e)
  657. {
  658. proc_Exe();
  659. }
  660. private void ugdConfig_AfterRowActivate(object sender, EventArgs e)
  661. {
  662. try
  663. {
  664. UltraGridRow row = ugdConfig.ActiveRow;
  665. try
  666. {
  667. textName.Text = row.Cells["SHIFTNAME"].Value.ToString();
  668. textTestName.Text = row.Cells["SHIFTNAME"].Value.ToString();
  669. cboShift1.Text = row.Cells["SHIFTTYPE"].Value.ToString().Substring(0, 1);
  670. cboShift2.Text = row.Cells["SHIFTTYPE"].Value.ToString().Substring(1, 1);
  671. }
  672. catch { }
  673. string ID = row.Cells["ID"].Value.ToString();
  674. if (refreshflag)
  675. {
  676. DetailConfigQuery(ID);
  677. }
  678. }
  679. catch { }
  680. }
  681. private void cboBZ_ValueChanged(object sender, EventArgs e)
  682. {
  683. try
  684. {
  685. UltraComboEditor ucbo = (UltraComboEditor)sender;
  686. string strName = ucbo.Name;
  687. int nCbo = ucbo.SelectedIndex;
  688. int nJ = cboJia.SelectedIndex; //甲班
  689. int nY = cboYi.SelectedIndex; //乙班
  690. int nB = cboBing.SelectedIndex; //丙班
  691. int nD = cboDing.SelectedIndex; //丁班
  692. if(nCbo!=0)
  693. {
  694. if (strName == "cboJia")
  695. {
  696. if (nCbo == nY || nCbo == nB || nCbo == nD)
  697. {
  698. cboJia.SelectedIndex = 0;
  699. cboJia.Focus();
  700. MessageBox.Show("班次重复请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  701. return;
  702. }
  703. }
  704. if (strName == "cboYi")
  705. {
  706. if (nCbo == nJ || nCbo == nB || nCbo == nD)
  707. {
  708. cboYi.SelectedIndex = 0;
  709. cboYi.Focus();
  710. MessageBox.Show("班次重复请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  711. return;
  712. }
  713. }
  714. if (strName == "cboBing")
  715. {
  716. if (nCbo == nJ || nCbo == nY || nCbo == nD)
  717. {
  718. cboBing.SelectedIndex = 0;
  719. cboBing.Focus();
  720. MessageBox.Show("班次重复请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  721. return;
  722. }
  723. }
  724. if (strName == "cboDing")
  725. {
  726. if (nCbo == nY || nCbo == nB || nCbo == nJ)
  727. {
  728. cboDing.SelectedIndex = 0;
  729. cboDing.Focus();
  730. MessageBox.Show("班次重复请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  731. return;
  732. }
  733. }
  734. }
  735. }
  736. catch { }
  737. }
  738. private void butTest_Click(object sender, EventArgs e)
  739. {
  740. pro_Test();
  741. }
  742. private void ute_TestTime_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  743. {
  744. try
  745. {
  746. frmSetTime frm = new frmSetTime(e.Context);
  747. //frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
  748. frm.Location = new Point(300, 200);//ClsControlPack.GetChildWindowLocation(frm.Size);
  749. frm.AutoSize = true;
  750. if (frm.ShowDialog() == DialogResult.OK)
  751. {
  752. ute_TestTime.Text = (Convert.ToDateTime(frm.SelectDate.ToString())).ToString("yyyy-MM-dd HH:mm:ss");
  753. ute_TestTime.Update();
  754. }
  755. }
  756. catch { }
  757. }
  758. }
  759. }