FrmWeightCheck.cs.svn-base 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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 CoreFS.CA06;
  10. using System.Collections;
  11. using Infragistics.Win.UltraWinGrid;
  12. using Core.Mes.Client.Common;
  13. using System.Diagnostics;
  14. using System.IO;
  15. namespace Core.LgMes.Client.lgIntegrationQuery
  16. {
  17. public partial class FrmWeightCheck : FrmBase
  18. {
  19. public FrmWeightCheck()
  20. {
  21. InitializeComponent();
  22. }
  23. private void FrmWeightCheck_Load(object sender, EventArgs e)
  24. {
  25. }
  26. public override void ToolBar_Click(object sender, string ToolbarKey)
  27. {
  28. switch (ToolbarKey)
  29. {
  30. case "Query":
  31. {
  32. proc_Query();
  33. break;
  34. }
  35. case "CheckIn":
  36. {
  37. CheckIn("审核通过");
  38. break;
  39. }
  40. case " ":
  41. {
  42. CheckIn("审核不通过");
  43. break;
  44. }
  45. case "CheckCancel":
  46. {
  47. CheckCancel();
  48. break;
  49. }
  50. case "Export":
  51. {
  52. ExportExcel();
  53. break;
  54. }
  55. case "Close":
  56. {
  57. this.Close();
  58. break;
  59. }
  60. }
  61. }
  62. public void proc_Query()
  63. {
  64. this.dataSet1.Tables[0].Clear();
  65. if (uldtEndTime.DateTime > uldtBeginTime.DateTime)
  66. {
  67. MessageBox.Show("查询起始时间不能大于结束时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  68. return;
  69. }
  70. try
  71. {
  72. string strErr = "";
  73. this.dataSet1.Tables[0].Clear();
  74. string DelToDateFrom = Convert.ToString(this.uldtBeginTime.DateTime.ToString("yyyyMMdd"));
  75. string DelToDateTo = Convert.ToString(this.uldtEndTime.DateTime.ToString("yyyyMMdd"));
  76. DateTime t1 = DateTime.ParseExact(DelToDateFrom, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
  77. DateTime t2 = DateTime.ParseExact(DelToDateTo, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
  78. System.TimeSpan t3 = t2 - t1; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
  79. double getDay = t3.TotalDays; //将这个天数转换成天数, 返回值是double类型的(其实不必转换,因为t3默认就是天数) 得到:
  80. if (getDay > 30)
  81. {
  82. MessageBox.Show("查询周期过长,是否继续查询?");
  83. }
  84. string sqlCondition = "1=1 AND (T1.MATRL_END_CAUSE_CD IS NULL OR T1.MATRL_END_CAUSE_CD != '4')";
  85. sqlCondition += " AND T1.SLAB_CUT_DTIME BETWEEN '" + DelToDateFrom + "000000" + "' AND '" + DelToDateTo + "235959" + "'";
  86. if (this.chk_CCMID.Checked)
  87. {
  88. sqlCondition += " AND T1.PROC_CD LIKE 'J" + this.cmb_CCMID.Text.Trim() + "%'";
  89. }
  90. sqlCondition += " ORDER BY T1.SLAB_CUT_DTIME ";
  91. ArrayList arry1 = new ArrayList();
  92. ArrayList sqlList = new ArrayList();
  93. arry1.Add("FrmWeightCheckInfo.Select");//此ID为XML文件ID
  94. sqlList.Add(sqlCondition);
  95. //调用服务端方法
  96. CoreClientParam CCP_JJBQuery = new CoreClientParam();
  97. DataTable dt = new DataTable();
  98. CCP_JJBQuery.ServerName = "Core.LgMes.Server.Common.ComDBQuery";
  99. CCP_JJBQuery.MethodName = "doQuery";
  100. CCP_JJBQuery.ServerParams = new object[] { arry1, sqlList };
  101. CCP_JJBQuery.SourceDataTable = dt;//dataSet1.Tables[0];
  102. this.ExecuteQueryToDataTable(CCP_JJBQuery, CoreInvokeType.Internal);
  103. if (string.IsNullOrEmpty(strErr))
  104. {
  105. if (dt != null && dt.Rows.Count > 0)
  106. {
  107. this.dataTable1.Rows.Clear();
  108. DataRow dr;
  109. for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
  110. {
  111. dr = this.dataTable1.NewRow();
  112. for (int jCol = 0; jCol < dt.Columns.Count; jCol++)
  113. {
  114. if (this.dataTable1.Columns.Contains(dt.Columns[jCol].ColumnName))
  115. {
  116. dr[dt.Columns[jCol].ColumnName] = dt.Rows[iRow][jCol];
  117. }
  118. }
  119. this.dataTable1.Rows.Add(dr);
  120. }
  121. }
  122. }
  123. //this.dataSet1.data = dt;
  124. //System.Diagnostics.Debug.WriteLine(this.dataSet1.Tables[0].ToString());
  125. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  126. {
  127. if (ugr.Cells["CHECK_STATE"].Text.Trim() == "审核不通过")
  128. ugr.CellAppearance.BackColor = Color.OrangeRed;
  129. else if (ugr.Cells["CHECK_STATE"].Text.Trim() == "审核通过")
  130. ugr.CellAppearance.BackColor = Color.Lime;
  131. }
  132. this.ultraGrid1.DisplayLayout.Bands[0].Columns["Choose"].CellActivation = Activation.AllowEdit;
  133. this.ultraGrid1.DisplayLayout.Bands[0].Columns["BILLETNO"].CellActivation = Activation.ActivateOnly;
  134. this.ultraGrid1.DisplayLayout.Bands[0].Columns["BilletType"].CellActivation = Activation.ActivateOnly;
  135. this.ultraGrid1.DisplayLayout.Bands[0].Columns["THICK"].CellActivation = Activation.ActivateOnly;
  136. this.ultraGrid1.DisplayLayout.Bands[0].Columns["WIDTH"].CellActivation = Activation.ActivateOnly;
  137. this.ultraGrid1.DisplayLayout.Bands[0].Columns["LENGTH"].CellActivation = Activation.ActivateOnly;
  138. this.ultraGrid1.DisplayLayout.Bands[0].Columns["QUANTITY"].CellActivation = Activation.ActivateOnly;
  139. this.ultraGrid1.DisplayLayout.Bands[0].Columns["WEIGHT"].CellActivation = Activation.ActivateOnly;
  140. this.ultraGrid1.DisplayLayout.Bands[0].Columns["THEORYWEIGHT"].CellActivation = Activation.ActivateOnly;
  141. this.ultraGrid1.DisplayLayout.Bands[0].Columns["GOWHERE"].CellActivation = Activation.ActivateOnly;
  142. this.ultraGrid1.DisplayLayout.Bands[0].Columns["Check_State"].CellActivation = Activation.ActivateOnly;
  143. }
  144. catch (Exception EX)
  145. {
  146. MessageBox.Show(EX.ToString());
  147. }
  148. }
  149. private void CheckIn(string state)
  150. {
  151. string strErr = "", sqlNew = ""; int i = 0;
  152. if (this.ultraGrid1.Rows.Count == 0)
  153. {
  154. MessageBox.Show("请查询数据后再进行审核");
  155. return;
  156. }
  157. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  158. {
  159. if (ugr.Cells["Choose"].Text.Trim().ToUpper() != "TRUE")
  160. continue;
  161. string billetno = ugr.Cells["BILLETNO"].Text.Trim();//坯号
  162. string billettype = ugr.Cells["BilletType"].Text.Trim();//坯料类型
  163. string MeterWeight = ugr.Cells["WeightPerMeter"].Text.Trim();//米单重
  164. string thick = ugr.Cells["THICK"].Text.Trim();//厚度
  165. string width = ugr.Cells["WIDTH"].Text.Trim();//宽度
  166. string length = ugr.Cells["LENGTH"].Text.Trim();//长度
  167. string quantity = ugr.Cells["QUANTITY"].Text.Trim();//支数
  168. string weight = ugr.Cells["WEIGHT"].Text.Trim();//磅重
  169. string theoryweight = ugr.Cells["THEORYWEIGHT"].Text.Trim();//理重
  170. string optman = this.UserInfo.GetUserName();
  171. string gowhere = ugr.Cells["GOWHERE"].Text.Trim();//去向
  172. string ccmid = ugr.Cells["CCMID"].Text.Trim();//铸机号
  173. if (!string.IsNullOrEmpty(ugr.Cells["Check_State"].Text.Trim()) && ugr.Cells["Check_State"].Text.Trim() != "未审核")
  174. {
  175. MessageBox.Show(billetno + "已审核,如需重新审核,请先撤销审核");
  176. return;
  177. }
  178. else
  179. {
  180. sqlNew = "select * from CXUSER.JOB_WEIGHTCHECK_INFO@XGCX where billetno = '" + billetno + "'";
  181. CoreClientParam CCP_Query = new CoreClientParam();
  182. DataTable dt = new DataTable();
  183. CCP_Query.ServerName = "Core.LgMes.Server.Common.ComDBExecute"; // 考虑原来返回数据形式性能太低,修改为前端传sql,服务端直接执行模式 2013.11.18
  184. CCP_Query.MethodName = "doSimpleQuery";
  185. CCP_Query.ServerParams = new object[] { sqlNew };
  186. CCP_Query.SourceDataTable = dt;
  187. ExecuteQueryToDataTable(CCP_Query, CoreInvokeType.Internal);
  188. if (dt != null && dt.Rows.Count > 0)
  189. {
  190. MessageBox.Show(billetno + "已审核,如需重新审核,请先撤销审核");
  191. proc_Query();
  192. return;
  193. }
  194. }
  195. string sql = "insert into CXUSER.JOB_WEIGHTCHECK_INFO@XGCX(BILLETNO,THICK,WIDTH,LENGTH,THEORYWEIGHT,WEIGHT,CHECK_STATE,CHECK_TIME,CHECK_MAN,"
  196. + "QUANTITY,METER_WEIGHT,BILLETTYPE,SLAB_SOURCE,GOWHERE,CCMID) "
  197. + " values('" + billetno + "','" + thick + "','" + width + "','" + length + "','" + theoryweight + "','" + weight + "','" + state + "',sysdate,'" + optman + "','" + quantity + "','" + MeterWeight + "','" + billettype + "' , '" + "第二炼钢厂" + "','" + gowhere + "','" + ccmid + "')";
  198. CommonClientToServer cctos = new CommonClientToServer();
  199. cctos.ob = this.ob;
  200. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute",
  201. "ExcuteNoParameter", sql, out strErr);
  202. if (!string.IsNullOrEmpty(strErr))
  203. {
  204. MessageBox.Show("坯料:" + billetno + "审核失败。" + strErr);
  205. proc_Query();
  206. return;
  207. }
  208. i++;
  209. }
  210. MessageBox.Show(i + "条坯料全部审核成功。");
  211. proc_Query();
  212. }
  213. private void CheckCancel()
  214. {
  215. string strErr = "", sqlNew = ""; int i = 0;
  216. if (this.ultraGrid1.Rows.Count == 0)
  217. {
  218. MessageBox.Show("请查询数据后再进行撤销审核");
  219. return;
  220. }
  221. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  222. {
  223. if (ugr.Cells["Choose"].Text.Trim().ToUpper() != "TRUE")
  224. continue;
  225. string billetno = ugr.Cells["BILLETNO"].Text.Trim();//坯号
  226. string billettype = ugr.Cells["BilletType"].Text.Trim();//坯料类型
  227. if (string.IsNullOrEmpty(ugr.Cells["Check_State"].Text.Trim()))
  228. {
  229. MessageBox.Show(billetno + "已撤销,无需再次撤销");
  230. return;
  231. }
  232. /*if (ugr.Cells["STORAGESTATUS"].Text.Trim() == "已出库")
  233. {
  234. MessageBox.Show(billetno + "已出库,不允许撤销审核,请联系一钢质检");
  235. return;
  236. }
  237. else
  238. {
  239. if (billettype == "板坯")
  240. {
  241. sqlNew = "select STORAGESTATUS from cxuser.kcg_stufflist@xgcx where billetno = '" + billetno + "'";
  242. }
  243. else
  244. {
  245. sqlNew = "select MAX(STORAGESTATUS) from cxuser.kcg_stufflist@xgcx where heatno = '" + billetno + "' group by heatno";
  246. }
  247. CallingMessage par1 = new CallingMessage();
  248. par1.ServerName = "lgIntegrationQuery";
  249. par1.AssemblyName = "Core.LgMes.Server.lgIntegrationQuery";
  250. par1.ClassName = "Core.LgMes.Server.lgIntegrationQuery.LgGeneralInfo";
  251. par1.MethodName = "ExecuteCommand_Return";
  252. par1.args = new object[] { sqlNew };
  253. DataSet ds1 = (DataSet)ClientCommon._RemotingHelp.ExecuteMethod(par1, out strErr);
  254. String flag = ds1.Tables[0].Rows[0][0].ToString();
  255. if (flag == "2")
  256. {
  257. MessageBox.Show(billetno + "已出库,不允许撤销审核,请联系一钢质检");
  258. return;
  259. }
  260. }*/
  261. string sql = "DELETE FROM CXUSER.JOB_WEIGHTCHECK_INFO@XGCX WHERE BILLETNO = '" + billetno + "'";
  262. CommonClientToServer cctos = new CommonClientToServer();
  263. cctos.ob = this.ob;
  264. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBExecute",
  265. "ExcuteNoParameter", sql, out strErr);
  266. if (!string.IsNullOrEmpty(strErr))
  267. {
  268. MessageBox.Show("坯料:" + billetno + "撤销失败。" + strErr);
  269. proc_Query();
  270. return;
  271. }
  272. i++;
  273. }
  274. MessageBox.Show(i + "条坯料全部撤销成功。");
  275. proc_Query();
  276. }
  277. private void ExportExcel()
  278. {
  279. try
  280. {
  281. if (this.ultraGrid1.Rows.Count == 0)
  282. {
  283. MessageBox.Show("请先检索数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  284. return;
  285. }
  286. string StrfileName = System.Windows.Forms.Application.StartupPath + "\\Report\\过磅数据审核.xls";
  287. this.GridExcelExporter.Export(this.ultraGrid1, StrfileName);
  288. ProcessStartInfo p = new ProcessStartInfo(StrfileName);
  289. p.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
  290. p.WorkingDirectory = Path.GetDirectoryName(StrfileName);
  291. Process.Start(p);
  292. }
  293. catch (Exception ex)
  294. {
  295. MessageBox.Show(ex.Message + "\n处理方法:查看(" + System.Windows.Forms.Application.StartupPath + ")目录下是否有[ Report文件夹 ],如果没有请手动创建!");
  296. }
  297. }
  298. private void uCkEditorForFilter_CheckedChanged(object sender, EventArgs e)
  299. {
  300. try
  301. {
  302. if (uCkEditorForFilter.Checked)
  303. {
  304. this.ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;
  305. }
  306. else
  307. {
  308. this.ultraGrid1.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
  309. this.ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
  310. }
  311. }
  312. catch { }
  313. }
  314. private void chk_CCMID_CheckedChanged(object sender, EventArgs e)
  315. {
  316. if (chk_CCMID.Checked)
  317. cmb_CCMID.Enabled = true;
  318. else
  319. cmb_CCMID.Enabled = false;
  320. }
  321. }
  322. }