FrmOxygenLanceManage.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Collections;
  9. using CoreFS.CA06;
  10. using Core.Mes.Client.Common;
  11. namespace Core.LgMes.Client.LgDeviceManager
  12. {
  13. public partial class FrmOxygenLanceManage : FrmLgDevFunctions
  14. {
  15. //定义一个时间变量,用于确定氧枪喷头累计消耗量的清空
  16. public static string LastUpdateTime;
  17. public static string NowUpdateTime;
  18. public FrmOxygenLanceManage()
  19. {
  20. InitializeComponent();
  21. }
  22. public void FrmOxygenLanceManage_Load(object sender, EventArgs e)
  23. {
  24. LastUpdateTime = System.DateTime.Now.ToString("yyyy-MM-dd");
  25. OLInfoToShow();
  26. }
  27. public override void ToolBar_Click(object sender, string ToolbarKey)
  28. {
  29. switch (ToolbarKey)
  30. {
  31. case "Basicinfo"://基本信息
  32. FrmOLBaseInfo fb = new FrmOLBaseInfo(ob);
  33. fb.Tag = this;
  34. fb.ShowDialog();
  35. break;
  36. case "Recordinfo"://使用记录信息
  37. FrmOLUseDetailOperation FrmOLUDO = new FrmOLUseDetailOperation(this.ob);
  38. FrmOLUDO.Tag = this;
  39. FrmOLUDO.Show();
  40. break;
  41. case "Query":
  42. this.OLInfoToShow();
  43. break;
  44. case "exit":
  45. this.Close();
  46. break;
  47. }
  48. }
  49. /// <氧枪查询信息>
  50. /// 氧枪查询信息
  51. /// </summary>
  52. public void OLInfoToShow()
  53. {
  54. try
  55. {
  56. string SqlCommand = "CALL UPDATE_YQ_BASE_CUT()";
  57. string err1 = NoQueryExecutive(SqlCommand, ob);
  58. CoreClientParam ccp = new CoreClientParam();
  59. ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  60. ccp.MethodName = "QueryMethods";
  61. string strsql = "select t1.OxygenLanceID,case t1.Status when '使用' then t2.NOWPOSITION end usetype,case t1.Status when '使用' then t2.OVENID end nowposition,t1.Status,t1.usemaxtime,"
  62. + "case t1.yqtype when '1' then '炼钢' when '2' then '提钒' end yqtype,"
  63. + "to_char(t1.BuyDate, 'yyyy-mm-dd') BuyDate,to_char(T3.BEGINTIME, 'yyyy-mm-dd HH:mm:ss') BEGINTIME,to_char(T3.ENDTIME, 'yyyy-mm-dd HH:mm:ss') ENDTIME,CUTSULFUR USETIMES,t1.Memo,t1.ParaID "
  64. + "from DEV_YQ_Base_Info t1,(select * from DEV_YQ_USE_DETAIL where RECRODID in (select max(to_number(RECRODID)) from DEV_YQ_USE_DETAIL group by OXYGENLANCEID)) t2,"
  65. + " (select OXYGENLANCEID,count(*) USETIMES,max(BEGINTIME)BEGINTIME,max(ENDTIME)ENDTIME from DEV_yq_use_detail group by OXYGENLANCEID )t3 "
  66. + "where t1.OXYGENLANCEID = t2.OXYGENLANCEID(+) and t1.oxygenlanceid = t3.oxygenlanceid(+) "
  67. + "order by t1.Status,"
  68. + "case t1.Status when '使用' then t2.OVENID else '' end,"
  69. + "case t1.Status when '使用' then t2.NOWPOSITION else '' end,"
  70. + "length(t1.OxygenLanceID),t1.OxygenLanceID";
  71. ccp.ServerParams = new Object[] { strsql };//查询条件
  72. DataTable dt = new DataTable();
  73. ccp.SourceDataTable = dt;
  74. this.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal);//
  75. DataSet ds = new DataSet();
  76. ds.Tables.Add(dt);
  77. try
  78. {
  79. ((DataTable)ulgridBaseInfo.DataSource).Rows.Clear();
  80. ((DataSet)ulgridUseInfo.DataSource).Tables[0].Rows.Clear();
  81. }
  82. catch (Exception)
  83. {
  84. }
  85. if(ds.Tables[0].Rows.Count>0)
  86. {
  87. ulgridBaseInfo.DataSource = ds;
  88. }
  89. if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  90. {
  91. Hashtable htOperate = new Hashtable();
  92. htOperate.Add("使用", Color.LightGreen);
  93. htOperate.Add("备用", Color.LightBlue);
  94. htOperate.Add("下线", Color.LightYellow);
  95. }
  96. else
  97. {
  98. FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this;
  99. FrmOLM.Show();
  100. MessageBox.Show("Warning:未查到任何记录!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  101. }
  102. }
  103. catch (Exception ex)
  104. {
  105. Console.WriteLine(ex.Message);
  106. }
  107. }
  108. /// <返回氧枪总数量>
  109. /// //返回氧枪总数量
  110. /// </summary>
  111. /// <returns></returns>
  112. public string YQAdd()
  113. {
  114. //取出不在库氧枪数量
  115. string sql = "select count(*) from DEV_yq_base_info";
  116. //string err = "";
  117. string month = System.DateTime.Now.ToString("yyyy-MM-dd").Substring(5, 2);
  118. int YQAdd1 = 0;
  119. DataSet ds = QueryFixedFunions(sql,ob);
  120. if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  121. {
  122. YQAdd1 = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
  123. }
  124. else
  125. {
  126. YQAdd1 = 0;
  127. }
  128. //取出在库氧枪数量
  129. string sql1 = "select StockNumber from DEV_bak_yq_inv where ToolName='氧枪' and UseType='备用' and month ='" + month + "'";
  130. int YQAdd2 = 0;
  131. DataSet ds1 = QueryFixedFunions(sql1, ob);
  132. if (ds1 != null && ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
  133. {
  134. YQAdd2 = Convert.ToInt32(ds1.Tables[0].Rows[0][0].ToString());
  135. }
  136. else
  137. {
  138. YQAdd2 = 0;
  139. }
  140. return Convert.ToString(YQAdd1 + YQAdd2);
  141. }
  142. /// <氧枪使用记录查询>
  143. /// 氧枪使用记录查询
  144. /// </summary>
  145. /// <param name="sender"></param>
  146. /// <param name="e"></param>
  147. private void ulgridBaseInfo_AfterRowActivate(object sender, EventArgs e)
  148. {
  149. string strOxygenLanceID = ulgridBaseInfo.ActiveRow.Cells[0].Value.ToString();
  150. string sql = "select RECRODID,OXYGENLANCEID,CLASS,NOWPOSITION,OVENID,NOWSTATUS,USETIMES,to_char(BEGINTIME, 'yyyy-mm-dd HH:mm:ss') BEGINTIME,"
  151. +"to_char(ENDTIME, 'yyyy-mm-dd HH:mm:ss') ENDTIME,REASON,SPOUTFACTORY,FLUX,MEMO from DEV_yq_use_detail t where t.oxygenlanceid='" + strOxygenLanceID + "' and t.RECRODID=" +
  152. "(select max(to_number(g.RECRODID)) from DEV_yq_use_detail g where g.oxygenlanceid='" + strOxygenLanceID + "')";
  153. CoreClientParam ccp = new CoreClientParam();
  154. ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  155. ccp.MethodName = "QueryMethods";
  156. ccp.ServerParams = new Object[] { sql };//查询条件
  157. DataTable dt = new DataTable();
  158. ccp.SourceDataTable = dt;
  159. ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  160. DataSet ds = new DataSet();
  161. ds.Tables.Add(dt);
  162. try
  163. {
  164. ((DataSet)ulgridUseInfo.DataSource).Tables[0].Rows.Clear();
  165. }
  166. catch (Exception)
  167. {
  168. }
  169. if (ds.Tables[0].Rows.Count > 0)
  170. {
  171. ulgridUseInfo.DataSource = ds;
  172. }
  173. }
  174. private string ClassTransChar(string code)
  175. {
  176. string str = "";
  177. switch (code)
  178. {
  179. case "1":
  180. {
  181. str = "甲";
  182. break;
  183. }
  184. case "2":
  185. {
  186. str = "乙";
  187. break;
  188. }
  189. case "3":
  190. {
  191. str = "丙";
  192. break;
  193. }
  194. case "4":
  195. {
  196. str = "丁";
  197. break;
  198. }
  199. }
  200. return str;
  201. }
  202. private void timer1_Tick(object sender, EventArgs e)
  203. {
  204. OLInfoToShow();
  205. }
  206. }
  207. }