frmCcmMgt.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. namespace Core.LgMes.Client.LgResMgt
  11. {
  12. public partial class frmCcmMgt : Core.Mes.Client.Common.frmStyleBase
  13. {
  14. string strError = null;
  15. // string strBC = null;
  16. DataSet ccmXX = new DataSet();
  17. string v_GWBM = "";
  18. string strNumId = "";
  19. public frmCcmMgt(string aaa)
  20. {
  21. InitializeComponent();
  22. v_GWBM = aaa;
  23. }
  24. /// <summary>
  25. /// 写日志信息到日志文件
  26. /// </summary>
  27. /// <param name="str"></param>
  28. private void WriteLog(string str)
  29. {
  30. //string strDate = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString();
  31. //System.IO.TextWriter tw = new System.IO.StreamWriter(System.Environment.CurrentDirectory + "\\log\\log_" + strDate + ".log", true);
  32. //tw.WriteLine(str);
  33. //tw.Close();
  34. }
  35. private void FrmMisManage_Load(object sender, EventArgs e)
  36. {
  37. ultraDataSource1.Rows.Add(new object[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0 });
  38. ultraDataSource2.Rows.Add(new object[] { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" });
  39. //初始化页面,绑定设备运行项目和耗材消耗项目
  40. BindingData();
  41. //交接班人员
  42. txtName.Text = this.UserInfo.GetUserName();
  43. ulcmeState.SelectedIndex = 1;
  44. //自动获取当前班次信息
  45. BandingShift();
  46. GetJJBInfo();
  47. }
  48. /// <summary>
  49. /// 判断是否交接班
  50. /// </summary>
  51. private bool JudgeESState(DateTime currTime)
  52. {
  53. string szWhere = "";
  54. string strShift = ulcmeShift1.Value.ToString() + ulcmeShift2.Value.ToString();
  55. szWhere = " where StationCode='" + v_GWBM + "' and ShiftCode='" + strShift + "' and to_char(ESDATE,'yyyy-MM-dd')='" + currTime.ToString("yyyy-MM-dd") + "'";
  56. DataSet ds = null;//hengxing (DataSet)Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "GetChangeClassInfo", new object[] { szWhere }, out strError);
  57. if (strError == "" && ds.Tables.Count > 0)
  58. {
  59. DataTable dt = ds.Tables[0];
  60. if (dt.Rows.Count > 0 && dt.Rows[0]["AFFIRMFLAG"].ToString() == "1")
  61. {
  62. return true;
  63. }
  64. else
  65. {
  66. return false;
  67. }
  68. }
  69. else
  70. {
  71. return false;
  72. }
  73. }
  74. /// <summary>
  75. /// 判断交接班项目信息是否存在
  76. /// </summary>
  77. /// <param name="strNumID">交接班序号</param>
  78. /// <param name="strItemCode">项目编码</param>
  79. /// <param name="strItemDataType">数据类型</param>
  80. /// <returns>返回True信息存在,否则不存在</returns>
  81. private bool GetDetailInfo(string strNumID, string strItemCode, string strItemDataType)
  82. {
  83. string strError = "";
  84. DataSet ds = null;//hengxing (DataSet)Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt",
  85. // "Core.LgMes.Server.LgResMgt.LfsCollect",
  86. // "GetDetailInfo",
  87. // new object[] { strNumId,strItemCode,strItemDataType }, out strError);
  88. if (strError == "" && ds != null)
  89. {
  90. if (ds.Tables[0].Rows.Count == 0)
  91. return false;
  92. else
  93. return true;
  94. }
  95. else
  96. return true;
  97. }
  98. /// <summary>
  99. /// 自动获取当前班次信息 班别班次从存储过程中取。。。暂不知道存储过程名,后面再加
  100. /// </summary>
  101. private void BandingShift()
  102. {
  103. try
  104. {
  105. #region 班别班次从存储过程中取。
  106. string strError = "";
  107. string strBC = "";//hengxing (string)Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "GetClassInfo", new object[] { }, out strError);
  108. if (strBC.Trim().Length == 2)
  109. {
  110. ulcmeShift1.Value = strBC.Substring(0, 1);
  111. ulcmeShift2.Value = strBC.Substring(1, 1);
  112. }
  113. #endregion
  114. }//end try
  115. catch (System.Exception exp)
  116. {
  117. MessageBox.Show(exp.Message);
  118. }
  119. finally
  120. {
  121. }
  122. }
  123. /// <summary>
  124. /// 绑定设备运行项目和耗材项目
  125. /// </summary>
  126. private void BindingData()
  127. {
  128. //获取设备运行状态项目数据
  129. GetEsItemData1("设备运行", v_GWBM);
  130. //获取耗材消耗项目数据
  131. GetEsItemData2("耗材消耗", v_GWBM);
  132. //绑定设备运行状态项目数据
  133. if (ccmXX.Tables["YXZT"] != null && ccmXX.Tables["YXZT"].Rows.Count > 0)
  134. {
  135. for (int i = 0; i < ccmXX.Tables["YXZT"].Rows.Count; i++)
  136. {
  137. this.ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Header.Caption = ccmXX.Tables["YXZT"].Rows[i]["ITEMNAME"].ToString();
  138. this.ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag = ccmXX.Tables["YXZT"].Rows[i]["ITEMCODE"].ToString();
  139. this.ulgridEquipment.DisplayLayout.Rows[0].Cells[i].Value = true;
  140. }
  141. }
  142. if (ccmXX.Tables["HCXH"] != null && ccmXX.Tables["HCXH"].Rows.Count > 0)
  143. {
  144. //绑定耗材消耗项目数据
  145. for (int i = 0; i < ccmXX.Tables["HCXH"].Rows.Count; i++)
  146. {
  147. this.ulgridConsume.DisplayLayout.Bands[0].Columns[i].Header.Caption = ccmXX.Tables["HCXH"].Rows[i]["ITEMNAME"].ToString();
  148. this.ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag = ccmXX.Tables["HCXH"].Rows[i]["ITEMCODE"].ToString();
  149. }
  150. }
  151. }
  152. /// <summary>
  153. /// 获取项目数据 设备运行状态
  154. /// </summary>
  155. /// <param name="strXMType">项目类型</param>
  156. /// <param name="strGWCode">岗位编码</param>
  157. /// <returns></returns>
  158. private void GetEsItemData1(string strXMType, string strGWCode)
  159. {
  160. try
  161. {
  162. string szWhere = " Where ITEMTYPE = '" + strXMType + "' and STATIONCODE = '" + strGWCode + "' ";
  163. DataSet ds = null;//hengxing (DataSet)Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "GetHCXMData", new object[] { szWhere }, out strError);
  164. if (strError == "" && ds != null)
  165. {
  166. DataTable dt = ds.Tables[0];
  167. dt.TableName = "YXZT";
  168. if (ccmXX.Tables.Contains("YXZT"))
  169. {
  170. ccmXX.Tables["YXZT"].Clear();
  171. }
  172. ccmXX.Merge(dt);
  173. }
  174. }//end try
  175. catch (System.Exception exp)
  176. {
  177. MessageBox.Show(exp.Message);
  178. }
  179. finally
  180. {
  181. }
  182. }
  183. /// <summary>
  184. /// 获取项目数据 耗材消耗
  185. /// </summary>
  186. /// <param name="strXMType">项目类型</param>
  187. /// <param name="strGWCode">岗位编码</param>
  188. /// <returns></returns>
  189. private void GetEsItemData2(string strXMType, string strGWCode)
  190. {
  191. try
  192. {
  193. string szWhere = " Where ITEMTYPE = '" + strXMType + "' and STATIONCODE = '" + strGWCode + "' ";
  194. DataSet ds = null;//hengxing (DataSet)Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "GetHCXMData", new object[] { szWhere }, out strError);
  195. if (strError == "" && ds != null)
  196. {
  197. DataTable dt = ds.Tables[0];
  198. dt.TableName = "HCXH";
  199. if (ccmXX.Tables.Contains("HCXH"))
  200. {
  201. ccmXX.Tables["HCXH"].Clear();
  202. }
  203. ccmXX.Merge(dt);
  204. }
  205. }//end try
  206. catch (System.Exception exp)
  207. {
  208. MessageBox.Show(exp.Message);
  209. }
  210. finally
  211. {
  212. }
  213. }
  214. /// <summary>
  215. /// 获取交接班信息
  216. /// </summary>
  217. private void GetJJBInfo()
  218. {
  219. string strError = "";
  220. string strStationCode="";
  221. strStationCode = v_GWBM; //岗位编码
  222. DataSet ds = null;//hengxing (DataSet)Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt",
  223. // "Core.LgMes.Server.LgResMgt.LfsCollect", "GetJJBInfo", new object[] { strStationCode }, out strError);
  224. if (strError == "" && ds != null)
  225. {
  226. foreach (DataRow dr in ds.Tables[0].Rows)
  227. {
  228. if (dr["itemdatatype"].ToString() == "0") //设备运行数据
  229. {
  230. for (int i = 0; i < ulgridEquipment.DisplayLayout.Bands[0].Columns.Count; i++)
  231. {
  232. if (ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag != null && ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag.ToString() == dr["itemcode"].ToString())
  233. {
  234. ulgridEquipment.DisplayLayout.Rows[0].Cells[i].Value = Convert.ToBoolean(Convert.ToInt16(dr["itemvalue"]));
  235. break;
  236. }
  237. }
  238. }
  239. else if (dr["itemdatatype"].ToString() == "1") //耗材消耗
  240. {
  241. for (int i = 0; i < ulgridConsume.DisplayLayout.Bands[0].Columns.Count; i++)
  242. {
  243. if (ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag != null && ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag.ToString() == dr["itemcode"].ToString())
  244. {
  245. ulgridConsume.DisplayLayout.Rows[0].Cells[i].Value = dr["itemvalue"].ToString();
  246. break;
  247. }
  248. }
  249. }
  250. strNumId = dr["numid"].ToString();
  251. ulcmeState.SelectedIndex = Convert.ToInt16(dr["affirmflag"]);
  252. txtName.Text = dr["esname"].ToString();
  253. txtMemo.Text = dr["esmemo"].ToString();
  254. dtpkDate.Value =Convert.ToDateTime(dr["esdate"]);
  255. if (!string.IsNullOrEmpty(dr["shiftcode"].ToString()))
  256. {
  257. ulcmeShift1.Value = dr["shiftcode"].ToString().Substring(0, 1);
  258. ulcmeShift2.Value = dr["shiftcode"].ToString().Substring(1, 1);
  259. }
  260. }
  261. }
  262. }
  263. private void btnOk_Click(object sender, EventArgs e)
  264. {
  265. if (ulcmeShift1.Text.Length == 0 || ulcmeShift2.Text.Length == 0)
  266. {
  267. MessageBox.Show("请选择班别班次!");
  268. return;
  269. }
  270. string strBC = ulcmeShift1.Value.ToString() + ulcmeShift2.Value.ToString();
  271. DateTime currTime = DateTime.Now;//hengxing (DateTime)ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "GetSystemTime", new object[] { }, out strError);
  272. if (strError == "")
  273. {
  274. dtpkDate.Value = currTime;
  275. }
  276. try
  277. {
  278. DialogResult result;
  279. result = MessageBox.Show(this, "您确认要交接班吗?", "提示", MessageBoxButtons.YesNo,
  280. MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
  281. if (result == DialogResult.Yes)
  282. {
  283. //判断是否交接班
  284. if (!StaticFunction.CheckIsChangeClass(currTime))
  285. {
  286. MessageBox.Show("提示:现在暂时不能交班,请等到交班时间再进行交接班!");
  287. return;
  288. }
  289. //
  290. if (ulcmeState.Text == "否")
  291. {
  292. MessageBox.Show("提示:必须确认交接班状态!");
  293. return;
  294. }
  295. //交接班序号
  296. string strJJBID = v_GWBM + System.DateTime.Now.ToString("yyyyMMddHHmm");
  297. //判断耗材消耗是否全部录入
  298. for (int i = 0; i < ulgridConsume.DisplayLayout.Rows[0].Cells.Count; i++)
  299. {
  300. if (ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag!=null)
  301. {
  302. if (ulgridConsume.DisplayLayout.Rows[0].Cells[i].Value.ToString() == "")
  303. {
  304. MessageBox.Show("耗材消耗输入不完全,请重新输入!");
  305. return;
  306. }
  307. }
  308. }
  309. bool ESFlag = JudgeESState(currTime);
  310. if (ESFlag == true)
  311. UpdateMainInfo(strNumId); //更机新交接班主表数据
  312. else
  313. AddESMainData(strJJBID); //新增交接班主表数据
  314. //新增交接班详表数据
  315. //耗材消耗
  316. for (int i = 0; i < ulgridConsume.DisplayLayout.Rows[0].Cells.Count; i++)
  317. {
  318. if (ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag!=null)
  319. {
  320. if (string.IsNullOrEmpty(strNumId))
  321. {
  322. if (GetDetailInfo(strJJBID, ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "1") == false)
  323. AddESDetailData(strJJBID, ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "1", ulgridConsume.DisplayLayout.Rows[0].Cells[i].Value.ToString());
  324. }
  325. else
  326. if (GetDetailInfo(strNumId, ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "1") == false)
  327. AddESDetailData(strNumId, ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "1", ulgridConsume.DisplayLayout.Rows[0].Cells[i].Value.ToString());
  328. else
  329. UpdateDetailInfo(strNumId, ulgridConsume.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "1", ulgridConsume.DisplayLayout.Rows[0].Cells[i].Value.ToString());
  330. }
  331. }
  332. //交接班运行
  333. for (int i = 0; i < ulgridEquipment.DisplayLayout.Rows[0].Cells.Count; i++)
  334. {
  335. if (ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag !=null)
  336. {
  337. if (string.IsNullOrEmpty(strNumId))
  338. {
  339. if (GetDetailInfo(strJJBID, ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "0") == false)
  340. AddESDetailData(strJJBID, ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "0", ulgridEquipment.DisplayLayout.Rows[0].Cells[i].Value.ToString());// == "True" ? "1" : "0");
  341. }
  342. else
  343. {
  344. if (GetDetailInfo(strNumId, ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "0") == false)
  345. AddESDetailData(strNumId, ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "0", ulgridEquipment.DisplayLayout.Rows[0].Cells[i].Value.ToString());// == "True" ? "1" : "0");
  346. else
  347. UpdateDetailInfo(strNumId, ulgridEquipment.DisplayLayout.Bands[0].Columns[i].Tag.ToString(), "0", ulgridEquipment.DisplayLayout.Rows[0].Cells[i].Value.ToString());//() == "True" ? "1" : "0");
  348. }
  349. }
  350. }
  351. GetJJBInfo();
  352. }
  353. }//end try
  354. catch (System.Exception exp)
  355. {
  356. MessageBox.Show(exp.Message);
  357. }
  358. finally
  359. {
  360. }
  361. }
  362. /// <summary>
  363. /// 新增交接班主表数据
  364. /// </summary>
  365. public void AddESMainData(string strJJBID)
  366. {
  367. try
  368. {
  369. //班次编码
  370. string strBC = ulcmeShift1.Value.ToString() + ulcmeShift2.Value.ToString();
  371. //hengxing ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "Add_DT_JJBMain", new object[] { strJJBID, v_GWBM, strBC, dtpkDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), txtName.Text.Trim(), ulcmeState.Value, txtMemo.Text.Trim(),"0"}, out strError);
  372. if (strError != "")
  373. {
  374. MessageBox.Show(strError);
  375. }
  376. }//end try
  377. catch (System.Exception exp)
  378. {
  379. WriteLog("Hnst.QG.Client.ESManage.ESManage" + exp.Message);
  380. }
  381. finally
  382. {
  383. }
  384. }
  385. /// <summary>
  386. /// 修改交接班主表信息
  387. /// </summary>
  388. /// <param name="strNumID">交接班序号</param>
  389. /// <returns></returns>
  390. public void UpdateMainInfo(string strNumID)
  391. {
  392. try
  393. {
  394. //班次编码
  395. string strBC = ulcmeShift1.Value.ToString() + ulcmeShift2.Value.ToString();
  396. //hengxing ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt",
  397. // "Core.LgMes.Server.LgResMgt.LfsCollect",
  398. // "UpdateMainInfo", new object[] { strNumId, v_GWBM, strBC, dtpkDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), txtName.Text.Trim(), ulcmeState.Value, txtMemo.Text.Trim(), "0" }, out strError);
  399. if (strError != "")
  400. {
  401. MessageBox.Show(strError);
  402. }
  403. }
  404. catch (System.Exception exp)
  405. {
  406. WriteLog("Hnst.QG.Client.ESManage.ESManage" + exp.Message);
  407. }
  408. finally { }
  409. }
  410. /// <summary>
  411. /// 保存交接班配置项目数据表
  412. /// </summary>
  413. /// <param name="strJJBID"></param>
  414. /// <param name="strXMCode"></param>
  415. /// <param name="strXMSJType"></param>
  416. /// <param name="strXMValue"></param>
  417. public void AddESDetailData(string strJJBID, string strXMCode, string strXMSJType, string strXMValue)
  418. {
  419. try
  420. {
  421. //hengxing Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "AddQG_DT_JJBXMDetail", new object[] { strJJBID, strXMCode, strXMSJType, strXMValue }, out strError);
  422. if (strError != "")
  423. {
  424. MessageBox.Show(strError);
  425. }
  426. }//end try
  427. catch (System.Exception exp)
  428. {
  429. MessageBox.Show(exp.Message);
  430. }
  431. finally
  432. {
  433. }
  434. }
  435. /// <summary>
  436. /// 更新交接班项目信息
  437. /// </summary>
  438. /// <param name="strNumID"></param>
  439. /// <param name="strItemCode"></param>
  440. /// <param name="strItemDataType"></param>
  441. /// <param name="strItemValue"></param>
  442. public void UpdateDetailInfo(string strNumID, string strItemCode, string strItemDataType, string strItemValue)
  443. {
  444. try
  445. {
  446. //hengxing Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("lgResMgt", "Core.LgMes.Server.LgResMgt.LfsCollect", "UpdateDetailInfo", new object[] { strNumID,strItemCode,strItemDataType,strItemValue}, out strError);
  447. if (strError != "")
  448. {
  449. MessageBox.Show(strError);
  450. }
  451. }//end try
  452. catch (System.Exception exp)
  453. {
  454. MessageBox.Show(exp.Message);
  455. }
  456. finally
  457. {
  458. }
  459. }
  460. public void GridKeyDown(int RowId, Infragistics.Win.UltraWinGrid.UltraGrid GRID)
  461. {
  462. switch (RowId)
  463. {
  464. case 38:
  465. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode);
  466. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.AboveCell);
  467. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
  468. break;
  469. case 37:
  470. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode);
  471. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.PrevCellByTab);
  472. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
  473. break;
  474. case 39:
  475. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode);
  476. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextCellByTab);
  477. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
  478. break;
  479. case 40:
  480. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode);
  481. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.BelowCell);
  482. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
  483. break;
  484. case 13://回车
  485. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode);
  486. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextCellByTab);
  487. GRID.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
  488. break;
  489. }
  490. }
  491. class StaticFunction
  492. {
  493. public static bool CheckIsChangeClass(DateTime currTime)
  494. {
  495. string datetime = currTime.ToString("HH:mm:ss");
  496. string Z1 = "07:45:00", Z2 = "08:15:00", Z3 = "15:45:00", Z4 = "16:15:00", Z5 = "23:45:00", Z6 = "00:15:00", Z7 = "00:00:00", Z8 = "23:59:59";
  497. if ((string.Compare(datetime, Z1) >= 0 && string.Compare(datetime, Z2) < 0)
  498. || (string.Compare(datetime, Z3) >= 0 && string.Compare(datetime, Z4) < 0)
  499. || ((string.Compare(datetime, Z5) >= 0 && string.Compare(datetime, Z8) < 0)
  500. || (string.Compare(datetime, Z7) >= 0 && string.Compare(datetime, Z6)<0)))
  501. {
  502. return true;
  503. }
  504. return false;
  505. }
  506. }
  507. private void ulgridEquipment_KeyDown(object sender, KeyEventArgs e)
  508. {
  509. GridKeyDown(e.KeyValue, ulgridEquipment);
  510. }
  511. private void ulgridConsume_KeyDown(object sender, KeyEventArgs e)
  512. {
  513. GridKeyDown(e.KeyValue, ulgridConsume);
  514. }
  515. public static void CheckNumValidate(string szVal)
  516. {
  517. try
  518. {
  519. Convert.ToDecimal(szVal);
  520. }
  521. catch (Exception ex)
  522. {
  523. MessageBox.Show(ex.Message, "提示");
  524. }
  525. }
  526. private void ultraGroupBox2_KeyPress(object sender, KeyPressEventArgs e)
  527. {
  528. if (e.KeyChar == (char)13)
  529. {
  530. Control c = GetNextControl(this.ActiveControl, true);
  531. bool ok = SelectNextControl(this.ActiveControl, true, true, true, true);
  532. if (ok && c != null)
  533. {
  534. if (c is System.Windows.Forms.TextBox)
  535. {
  536. ((System.Windows.Forms.TextBox)c).SelectAll();
  537. }
  538. }
  539. }
  540. }
  541. private void ulgridEquipment_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  542. {
  543. }
  544. private void ulgridConsume_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  545. {
  546. if (ulgridConsume.ActiveCell.Text != "")
  547. CheckNumValidate(ulgridConsume.ActiveCell.Text);
  548. }
  549. }
  550. }