FrmStlControlLogCollect.cs 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368
  1. using com.steering.mes.zgmil.entity;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Format;
  4. using Core.Mes.Client.Comm.Server;
  5. using Core.Mes.Client.Comm.Tool;
  6. using Core.StlMes.Client.ZGMil.Entity;
  7. using CoreFS.CA06;
  8. using Infragistics.Win;
  9. using Infragistics.Win.UltraWinEditors;
  10. using Infragistics.Win.UltraWinGrid;
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Data;
  16. using System.Drawing;
  17. using System.Globalization;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Windows.Forms;
  21. namespace Core.StlMes.Client.ZGMil.Signature
  22. {
  23. public partial class FrmStlControlLogCollect : FrmBase
  24. {
  25. private string departm = "";
  26. UltraComboEditor ucePline = new UltraComboEditor();//产线名称
  27. private string plineCode;
  28. private string userId = "";
  29. private string[] plineCodes = { };
  30. //int stratday;//开始时间日期差,天,时,分
  31. //int strathours;
  32. //int stratminutes;
  33. //int endday;//结束时间日期差,天,时,分
  34. //int endhours;
  35. //int endminutes;toolba
  36. int flag = 0;//分析时间错误
  37. int flag1 = 0;//分析相差时间
  38. private string basecodeSamll = "";//停机小类值
  39. private string basecodeReason = "";//停机原因值
  40. public FrmStlControlLogCollect()
  41. {
  42. InitializeComponent();
  43. }
  44. private void FrmStlControlLogCollect_Load(object sender, EventArgs e)
  45. {
  46. EntityHelper.ShowGridCaption<StlControlLogEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  47. NativeMethodNew na = new NativeMethodNew(this.ob);
  48. departm = UserInfo.GetDepartment();
  49. userId = UserInfo.GetUserID();
  50. plineCode = na.GetPCode(departm);//获取 用户 对应的产线
  51. plineCodes = na.GetPlineCode(this.ValidDataPurviewIds);
  52. //cmbPline.DataSource = ServerHelper.GetData("com.steering.mes.signature.FrmTubeRollFileManage.queryPlineCode", new object[] { plineCode }, this.ob);
  53. //cmbPline.ValueMember = "PLINE_CODE";
  54. //cmbPline.DisplayMember = "PLINE_NAME";
  55. //TubeRoll.SetComboItemHeight(cmbPline);
  56. //cmbPlineE.DataSource = ServerHelper.GetData("com.steering.mes.signature.FrmTubeRollFileManage.queryPlineCode", new object[] { plineCode }, this.ob);
  57. //cmbPlineE.ValueMember = "PLINE_CODE";
  58. //cmbPlineE.DisplayMember = "PLINE_NAME";
  59. //TubeRoll.SetComboItemHeight(cmbPlineE);
  60. if (plineCode.Equals(""))
  61. {
  62. this.chkpline.Visible = true;
  63. this.cmbPline.Visible = true;
  64. }
  65. //cmbDate.MaxDate = DateTime.Now;
  66. cmbDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
  67. cmbDate2.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
  68. cmbPline.Value = na.GetPCodePline(this.ValidDataPurviewIds);
  69. TubeRoll.setUltraGridColumnInput(ultraGrid1, new string[] { "QualifiedNum", "ScrapNum" });//支数
  70. TubeRoll.setUltraGridColumnMaxInput(ultraGrid1, new string[] { "QualifiedWt", "ScrapWt" });//重量
  71. TubeRoll.SetComboItemHeight(cmbPline);
  72. TubeRoll.SetComboItemHeight(cmbBc);
  73. TubeRoll.SetComboItemHeight(cmbBz);
  74. DataTable dt = TubeRoll.GetComBaseInfo("3001", ob);
  75. cmbStop.DataSource = dt;
  76. cmbStop.ValueMember = "BASECODE";
  77. cmbStop.DisplayMember = "BASENAME";
  78. TubeRoll.SetComboItemHeight(cmbStop);
  79. }
  80. /// <summary>
  81. /// 重写基类方法
  82. /// </summary>
  83. /// <param name="sender"></param>
  84. /// <param name="ToolbarKey"></param>
  85. public override void ToolBar_Click(object sender, string ToolbarKey)
  86. {
  87. switch (ToolbarKey)
  88. {
  89. case "Query":
  90. doQuery();
  91. break;
  92. //case "Add":
  93. // doAdd();
  94. // break;
  95. //case "Update":
  96. // doUpdate("0");
  97. // break;
  98. case "Update":
  99. doUpdate();
  100. break;
  101. //case "Delete":
  102. // doDelete();
  103. // break;
  104. case "Analysis":
  105. doQuery();
  106. doAnalysis();
  107. break;
  108. //case "Confirm":
  109. // doConfirm();
  110. // break;
  111. //case "UpConfirm":
  112. // UpConfirm();
  113. // break;
  114. //case "OneKeyProces":
  115. // DoOneKeyProces();
  116. // break;
  117. //case "Statistical":
  118. // DoStatistical();
  119. // break;
  120. //case "OneKeyUpdate":
  121. // DoOneKeyUpdate();
  122. // break;
  123. //case "Production":
  124. // DoProduction();
  125. // break;
  126. case "Export":
  127. GridHelper.ulGridToExcel(ultraGrid1, "炼钢调度数据汇总");
  128. break;
  129. case "Close":
  130. this.Close();
  131. break;
  132. }
  133. }
  134. /// <summary>
  135. /// 生产记录
  136. /// </summary>
  137. private void DoProduction()
  138. {
  139. FrmProductionDetails pro = new FrmProductionDetails(cmbDate.Value.ToString("yyyyMMdd"), plineCode, this.ob);
  140. pro.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  141. pro.Text = "生产详细";
  142. pro.ShowDialog();
  143. }
  144. /// <summary>
  145. /// 查询统计数据
  146. /// </summary>
  147. private void DoStatistical()
  148. {
  149. UltraGridRow row = ultraGrid1.ActiveRow;
  150. if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
  151. //foreach (UltraGridRow urg in ultraGrid1.Rows)
  152. //{
  153. // if (row.Cells["ConfirmFlag"].Text.Equals("未确认")) { MessageUtil.ShowTips("未确认,不允许此操作!"); return; }
  154. //}
  155. FrmStatistical fsta = new FrmStatistical(plineCode, ob);
  156. fsta.AutoSize = true;
  157. fsta.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  158. fsta.Text = "统计查询";
  159. fsta.ShowDialog();
  160. }
  161. /// <summary>
  162. /// 查询
  163. /// </summary>
  164. private void doQuery()
  165. {
  166. ArrayList list = new ArrayList();
  167. //当天
  168. string date = "";
  169. //前一天
  170. string endDate = "";
  171. date = cmbDate.Value.ToString("yyyyMMdd");
  172. endDate = cmbDate2.Value.ToString("yyyyMMdd");
  173. if (this.chkpline.Checked)
  174. {
  175. plineCode = this.cmbPline.Value.ToString();
  176. }
  177. else
  178. {
  179. NativeMethodNew na = new NativeMethodNew(this.ob);
  180. plineCode = na.GetPCode(departm);
  181. }
  182. //当班数据
  183. List<StlControlLogEntity> listSource = EntityHelper.GetData<StlControlLogEntity>
  184. ("com.steering.mes.signature.FrmStlControlLog.doQueryPlanCollect", new object[] { date, endDate, plineCode }, this.ob);
  185. StlControlLogEntity.DataSource = listSource;
  186. GridHelper.RefreshAndAutoSize(ultraGrid1);
  187. this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsBeg"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
  188. this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsBeg"].MaskInput = "yyyy-mm-dd hh:mm";
  189. this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsEnd"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
  190. this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsEnd"].MaskInput = "yyyy-mm-dd hh:mm";
  191. }
  192. /// <summary>
  193. /// 一键处理新增(分析后五分钟以内的时间间隔)
  194. /// </summary>
  195. //private void DoOneKeyProces()
  196. //{
  197. // ultraGrid1.UpdateData();
  198. // UltraGridRow row = ultraGrid1.ActiveRow;
  199. // if (row == null) { MessageUtil.ShowTips("无数据,不允许此操作!"); return; }
  200. // int minutes = int.Parse(MinTime.Value.ToString());
  201. // if (minutes == 0) { MessageUtil.ShowTips("请输入相差时间!"); }
  202. // ArrayList pram = new ArrayList();
  203. // if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; }
  204. // if (flag == 1 && flag1 == 0) { MessageUtil.ShowTips("分析通过,不允许此操作!"); return; }
  205. // if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; }
  206. // int i = 0;
  207. // try
  208. // {
  209. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  210. // {
  211. // //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
  212. // //{
  213. // // MessageUtil.ShowTips("已确认数据,不允许此操作!");
  214. // // return;
  215. // //}
  216. // if (!ugr.Cells["LogsEnd"].Value.Equals(""))
  217. // {
  218. // i += 1;
  219. // }
  220. // }
  221. // for (int j = 0; j < i; j++)
  222. // {
  223. // string loagEnd = ultraGrid1.Rows[j].Cells["LogsEnd"].Text.ToString();
  224. // string loagBeg = "";
  225. // if (j + 1 < i)
  226. // {
  227. // loagBeg = ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Text.ToString();
  228. // if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
  229. // {
  230. // if (TubeRoll.JudgeTimeMax(Convert.ToDateTime(loagEnd), Convert.ToDateTime(loagBeg)) <= minutes
  231. // && TubeRoll.JudgeTimeMax(Convert.ToDateTime(loagEnd), Convert.ToDateTime(loagBeg)) > 0)
  232. // {
  233. // ArrayList list = new ArrayList();
  234. // list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
  235. // list.Add(DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  236. // list.Add(this.UserInfo.GetUserName());
  237. // list.Add(this.UserInfo.GetUserOrder());
  238. // list.Add(this.UserInfo.GetUserGroup());
  239. // list.Add(plineCode);
  240. // pram.Add(list);
  241. // }
  242. // }
  243. // }
  244. // }
  245. // if (MessageUtil.ShowYesNoAndQuestion("是否一键新增处理?") == DialogResult.No)
  246. // {
  247. // return;
  248. // }
  249. // CoreClientParam ccp = new CoreClientParam();
  250. // ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
  251. // ccp.MethodName = "oneKeyProcesMilControlLog";
  252. // ccp.ServerParams = new object[] { pram };
  253. // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  254. // if (ccp.ReturnCode != -1)
  255. // {
  256. // MessageUtil.ShowTips(ccp.ReturnInfo);
  257. // if (ccp.ReturnInfo.Equals("一键处理成功!"))
  258. // {
  259. // doQuery();
  260. // doAnalysis();
  261. // }
  262. // }
  263. // }
  264. // catch (Exception ex)
  265. // {
  266. // MessageUtil.ShowTips("开始时间或结束时间不能为空!");
  267. // }
  268. //}
  269. /// <summary>
  270. /// 一键修改
  271. /// </summary>
  272. //private void DoOneKeyUpdate()
  273. //{
  274. // ultraGrid1.UpdateData();
  275. // UltraGridRow row = ultraGrid1.ActiveRow;
  276. // if (row == null) { MessageUtil.ShowTips("无数据,不允许此操作!"); return; }
  277. // ArrayList pram = new ArrayList();
  278. // if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; }
  279. // if (flag == 1 && flag1 == 0) { MessageUtil.ShowTips("分析通过,不允许此操作!"); return; }
  280. // //if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; }
  281. // int i = 0;
  282. // try
  283. // {
  284. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  285. // {
  286. // //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
  287. // //{
  288. // // MessageUtil.ShowTips("已确认数据,不允许此操作!");
  289. // // return;
  290. // //}
  291. // if (!ugr.Cells["LogsEnd"].Value.Equals(""))
  292. // {
  293. // i += 1;
  294. // }
  295. // }
  296. // for (int j = 0; j < i; j++)
  297. // {
  298. // string loagEnd = ultraGrid1.Rows[j].Cells["LogsEnd"].Text.ToString();
  299. // string loagBeg = "";
  300. // if (j + 1 < i)
  301. // {
  302. // loagBeg = ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Text.ToString();
  303. // if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0)
  304. // {
  305. // ArrayList list = new ArrayList();
  306. // list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  307. // list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
  308. // list.Add(DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  309. // list.Add(this.UserInfo.GetUserName());
  310. // list.Add(this.UserInfo.GetUserOrder());
  311. // list.Add(this.UserInfo.GetUserGroup());
  312. // list.Add(plineCode);
  313. // list.Add(ultraGrid1.Rows[j].Cells["ControlId"].Value.ToString());
  314. // pram.Add(list);
  315. // }
  316. // }
  317. // }
  318. // if (ultraGrid1.Rows.Count > 0 && ultraGrid2.Rows.Count > 0)
  319. // {
  320. // int a = ultraGrid2.Rows.Count;
  321. // string logsBeg = ultraGrid1.Rows[0].Cells["LogsBeg"].Value.ToString();
  322. // string logsEnd = ultraGrid2.Rows[a - 1].Cells["LogsEnd"].Value.ToString();
  323. // string ControlId = ultraGrid1.Rows[0].Cells["ControlId"].Value.ToString();
  324. // if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) < 0)
  325. // {
  326. // logsEnd = DateTime.Parse(logsEnd).ToString("yyyyMMddHHmm");
  327. // ServerHelper.SetData("com.steering.mes.signature.FrmMilControlLog.updateOneDate", new object[] { logsEnd, ControlId }, this.ob);
  328. // }
  329. // }
  330. // if (MessageUtil.ShowYesNoAndQuestion("是否一键修改处理?") == DialogResult.No)
  331. // {
  332. // return;
  333. // }
  334. // CoreClientParam ccp = new CoreClientParam();
  335. // ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
  336. // ccp.MethodName = "oneKeyUpdateMilControlLog";
  337. // ccp.ServerParams = new object[] { pram };
  338. // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  339. // if (ccp.ReturnCode != -1)
  340. // {
  341. // MessageUtil.ShowTips(ccp.ReturnInfo);
  342. // if (ccp.ReturnInfo.Equals("一键处理成功!"))
  343. // {
  344. // doQuery();
  345. // doAnalysis();
  346. // }
  347. // }
  348. // }
  349. // catch (Exception ex)
  350. // {
  351. // MessageUtil.ShowTips("开始时间或结束时间不能为空!");
  352. // }
  353. //}
  354. /// <summary>
  355. /// 新增
  356. /// </summary>
  357. //private void doAdd()
  358. //{
  359. // ultraGrid1.UpdateData();
  360. // ArrayList pram = new ArrayList();
  361. // UltraGridRow row = ultraGrid1.ActiveRow;
  362. // int count = 0;
  363. // int statrindex = 0;//第一行记录
  364. // int endindex = 0;//最后一行记录
  365. // int indexEnd = 0;//获取Grid最后一行记录
  366. // string statime = "";//新增开始时间
  367. // string endtime = "";//新增结束时间
  368. // string datetime1 = "";//获取选中第一行结束时间
  369. // string datetime2 = "";//获取选中第二行开始时间
  370. // if (row != null)
  371. // {
  372. // try
  373. // {
  374. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  375. // {
  376. // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  377. // {
  378. // //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
  379. // //{
  380. // // MessageUtil.ShowTips("已确认数据,不允许此操作!");
  381. // // return;
  382. // //}
  383. // statime = DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm");//新增开始时间
  384. // datetime1 = DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm");
  385. // statrindex = ugr.Index;
  386. // break;
  387. // }
  388. // }
  389. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  390. // {
  391. // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  392. // {
  393. // count += 1;
  394. // endindex = ugr.Index;
  395. // endtime = DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm");//新增结束时间
  396. // datetime2 = DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm");
  397. // }
  398. // indexEnd = ugr.Index;
  399. // }
  400. // //判断选中的两行没有时间差,不许增加
  401. // int cnt = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Count();
  402. // if (datetime2 == datetime1 && cnt > 1)
  403. // { MessageUtil.ShowTips("选中的两行没有时间差,不允许增加!"); return; }
  404. // int index = endindex - statrindex;
  405. // if (index == 0)
  406. // {
  407. // if (statrindex == 0)//获取第一行
  408. // {
  409. // if (indexEnd == 0)//如果只有一条数据
  410. // {
  411. // FrmPopupWindow win = new FrmPopupWindow();
  412. // win.AutoSize = true;
  413. // win.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  414. // win.Text = "提示";
  415. // win.ShowDialog();
  416. // if (win.DialogResult == System.Windows.Forms.DialogResult.OK)
  417. // {
  418. // if (win.Popup == "之前")
  419. // {
  420. // pram.Add(DateTime.Parse(row.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  421. // pram.Add(DateTime.Parse(row.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  422. // }
  423. // else if (win.Popup == "之后")
  424. // {
  425. // pram.Add(DateTime.Parse(row.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
  426. // pram.Add(DateTime.Parse(row.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
  427. // }
  428. // else
  429. // {
  430. // return;
  431. // }
  432. // }
  433. // }
  434. // else
  435. // {
  436. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  437. // {
  438. // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  439. // {
  440. // pram.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  441. // pram.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  442. // }
  443. // }
  444. // }
  445. // }
  446. // else if (statrindex == indexEnd)//获取最后一行
  447. // {
  448. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  449. // {
  450. // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  451. // {
  452. // pram.Add(DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
  453. // pram.Add(DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"));
  454. // }
  455. // }
  456. // }
  457. // else
  458. // {
  459. // if (count == 0 || count > 2 || count < 2 && index < 2)
  460. // {
  461. // MessageUtil.ShowTips("请选择数据且选择相邻两条数据新增!");
  462. // return;
  463. // }
  464. // if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
  465. // {
  466. // return;
  467. // }
  468. // pram.Add(statime);
  469. // pram.Add(endtime);
  470. // }
  471. // }
  472. // else
  473. // {
  474. // if (count == 0 || count > 2 || count < 2 && index < 2)
  475. // {
  476. // MessageUtil.ShowTips("请选择数据且选择相邻两条数据新增!");
  477. // return;
  478. // }
  479. // if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
  480. // {
  481. // return;
  482. // }
  483. // pram.Add(statime);
  484. // pram.Add(endtime);
  485. // }
  486. // }
  487. // catch (Exception ex)
  488. // {
  489. // MessageUtil.ShowTips("开始时间或结束时间不能为空!");
  490. // return;
  491. // }
  492. // }
  493. // else//Grid 为空
  494. // {
  495. // if (MessageUtil.ShowYesNoAndQuestion("当前班次无数据是否新增?") == DialogResult.No)
  496. // {
  497. // return;
  498. // }
  499. // pram.Add(cmbDate.Value.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmm"));
  500. // pram.Add(cmbDate.Value.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmm"));
  501. // //pram.Add(DateTime.Now.ToString("yyyyMMddHHmm"));
  502. // //pram.Add(DateTime.Now.ToString("yyyyMMddHHmm"));
  503. // }
  504. // pram.Add(this.UserInfo.GetUserName());
  505. // pram.Add(this.UserInfo.GetUserOrder());
  506. // pram.Add(this.UserInfo.GetUserGroup());
  507. // pram.Add(plineCode);
  508. // CoreClientParam ccp = new CoreClientParam();
  509. // ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
  510. // ccp.MethodName = "addMilControlLog";
  511. // ccp.ServerParams = new object[] { pram };
  512. // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  513. // if (ccp.ReturnCode != -1)
  514. // {
  515. // MessageUtil.ShowTips(ccp.ReturnInfo);
  516. // if (ccp.ReturnInfo.Equals("新增成功!"))
  517. // {
  518. // doQuery();
  519. // doAnalysis();
  520. // }
  521. // }
  522. //}
  523. /// <summary>
  524. /// 修改
  525. /// </summary>
  526. /// <param name="ifConfirm">0只能修改未确认的,1可以修改已确认的</param>
  527. ///
  528. private void doUpdate()
  529. {
  530. ultraGrid1.UpdateData();
  531. UltraGridRow row = ultraGrid1.ActiveRow;
  532. if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
  533. ArrayList pram = new ArrayList();
  534. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  535. if (checkMagRows.Count() == 0)
  536. {
  537. MessageUtil.ShowTips("请选择需要修改的停机记录!");
  538. return;
  539. }
  540. foreach (UltraGridRow uRow in checkMagRows)
  541. {
  542. StlControlLogEntity stlControlLogEntity = (StlControlLogEntity)uRow.ListObject;
  543. //if (stlControlLogEntity.ConfirmFlag.Equals("1"))
  544. //{
  545. // MessageUtil.ShowTips("已确认的数据不能修改!");
  546. // return;
  547. //}
  548. stlControlLogEntity.LogsBeg = DateTime.Parse(uRow.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm");
  549. stlControlLogEntity.LogsEnd = DateTime.Parse(uRow.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm");
  550. //stlControlLogEntity.StopType = row.Cells["StopType"].Value.ToString();
  551. stlControlLogEntity.StopReason = basecodeReason;
  552. stlControlLogEntity.StopSmall = basecodeSamll;
  553. string matZcTity = JSONFormat.Format(stlControlLogEntity);
  554. pram.Add(matZcTity);
  555. }
  556. CoreClientParam ccp = new CoreClientParam();
  557. ccp.ServerName = "com.steering.mes.signature.FrmStlControlLog";
  558. ccp.MethodName = "updateMilControlLog";
  559. ccp.ServerParams = new object[] { pram };
  560. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  561. if (ccp.ReturnCode != -1)
  562. {
  563. MessageUtil.ShowTips(ccp.ReturnInfo);
  564. if (ccp.ReturnInfo.Equals("修改成功!"))
  565. {
  566. doQuery();
  567. //doAnalysis();
  568. }
  569. }
  570. }
  571. /// <summary>
  572. /// 删除
  573. /// </summary>
  574. //private void doDelete()
  575. //{
  576. // ultraGrid1.UpdateData();
  577. // UltraGridRow row = ultraGrid1.ActiveRow;
  578. // if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
  579. // int count = 0;
  580. // ArrayList list = new ArrayList();
  581. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  582. // {
  583. // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  584. // {
  585. // count += 1;
  586. // //只有各厂总账号可以删除正常数据,普通账号只可删除停机数据。
  587. // if (userId != "250001" && userId != "1680001" && userId != "2580001" && userId != "4600001")
  588. // {
  589. // if (ugr.Cells["ProType"].Text.Equals("正常"))
  590. // {
  591. // MessageUtil.ShowTips("请选择停机数据!");
  592. // return;
  593. // }
  594. // }
  595. // if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认"))
  596. // {
  597. // MessageUtil.ShowTips("已确认数据,不允许此操作!");
  598. // return;
  599. // }
  600. // ArrayList pram = new ArrayList();
  601. // pram.Add(ugr.Cells["ControlId"].Value.ToString());
  602. // list.Add(pram);
  603. // }
  604. // }
  605. // if (count == 0)
  606. // {
  607. // MessageUtil.ShowTips("请选择要删除的停机数据!");
  608. // return;
  609. // }
  610. // if (MessageUtil.ShowYesNoAndQuestion("是否删除?") == DialogResult.No)
  611. // {
  612. // return;
  613. // }
  614. // CoreClientParam ccp = new CoreClientParam();
  615. // ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
  616. // ccp.MethodName = "deleteMilControlLog";
  617. // ccp.ServerParams = new object[] { list };
  618. // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  619. // if (ccp.ReturnCode != -1)
  620. // {
  621. // MessageUtil.ShowTips(ccp.ReturnInfo);
  622. // if (ccp.ReturnInfo.Equals("删除成功!"))
  623. // {
  624. // doQuery();
  625. // doAnalysis();
  626. // }
  627. // }
  628. //}
  629. /// <summary>
  630. ///分析
  631. /// </summary>
  632. private void doAnalysis()
  633. {
  634. flag = 1;
  635. flag1 = 0;
  636. int i = 0;
  637. try
  638. {
  639. //当班数据分析
  640. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  641. {
  642. if (!ugr.Cells["LogsEnd"].Value.Equals(""))
  643. { i += 1; }
  644. if (!ugr.Cells["LogsEnd"].Value.Equals(""))
  645. {
  646. if (Convert.ToDateTime(ugr.Cells["LogsBeg"].Value.ToString()) > Convert.ToDateTime(ugr.Cells["LogsEnd"].Value.ToString()))
  647. {
  648. ugr.RowSelectorAppearance.BackColor = Color.Red;
  649. //ugr.Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None;
  650. //ugr.Cells["LogsEnd"].Appearance.BackColor = Color.Red;
  651. //ugr.Cells["LogsEnd"].Appearance.BackHatchStyle = BackHatchStyle.None;
  652. flag = 2;//分析时间错误
  653. }
  654. }
  655. }
  656. for (int j = 0; j < i; j++)
  657. {
  658. string loagEnd = ultraGrid1.Rows[j].Cells["LogsEnd"].Text.ToString();
  659. string loagBeg = "";
  660. if (j + 1 < i)
  661. {
  662. loagBeg = ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Text.ToString();
  663. if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
  664. {
  665. if (TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
  666. {
  667. ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.Pink;
  668. ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
  669. ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackColor = Color.Pink;
  670. ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
  671. flag1 = 1;//时间差
  672. }
  673. //else if (TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) <= 5 && TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd))>=3)
  674. //{
  675. // ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.LightGray;
  676. // ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
  677. // ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackColor = Color.LightGray;
  678. // ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
  679. // flag = 2;
  680. //}
  681. }
  682. else if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0)
  683. {
  684. ultraGrid1.Rows[j].RowSelectorAppearance.BackColor = Color.Red;
  685. //ultraGrid1.Rows[j + 1].RowSelectorAppearance.BackColor = Color.Red;
  686. //ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Appearance.BackColor = Color.Orange;
  687. //ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None;
  688. //ultraGrid1.Rows[j].Cells["LogsBeg"].Appearance.BackColor = Color.Orange;
  689. //ultraGrid1.Rows[j].Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None;
  690. flag = 2;
  691. }
  692. TimeSpan timeSpan = DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()) -
  693. DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString());
  694. ultraGrid1.Rows[j + 1].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString();
  695. }
  696. }
  697. //上班数据分析
  698. //i = 0;
  699. //foreach (UltraGridRow ugr in ultraGrid2.Rows)
  700. //{
  701. // if (!ugr.Cells["LogsBeg"].Value.Equals(""))
  702. // { i += 1; }
  703. // if (!ugr.Cells["LogsEnd"].Value.Equals(""))
  704. // {
  705. // //i += 1;
  706. // if (Convert.ToDateTime(ugr.Cells["LogsBeg"].Value.ToString()) > Convert.ToDateTime(ugr.Cells["LogsEnd"].Value.ToString()))
  707. // {
  708. // ugr.RowSelectorAppearance.BackColor = Color.Red;
  709. // flag = 2;//分析时间错误
  710. // }
  711. // }
  712. //}
  713. //for (int j = 0; j < i; j++)
  714. //{
  715. // string loagEnd = ultraGrid2.Rows[j].Cells["LogsEnd"].Text.ToString();
  716. // string loagBeg = "";
  717. // if (j + 1 < i)
  718. // {
  719. // loagBeg = ultraGrid2.Rows[j + 1].Cells["LogsBeg"].Text.ToString();
  720. // if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
  721. // {
  722. // if (TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0)
  723. // {
  724. // ultraGrid2.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.Pink;
  725. // ultraGrid2.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
  726. // ultraGrid2.Rows[j].Cells["StopType"].Appearance.BackColor = Color.Pink;
  727. // ultraGrid2.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None;
  728. // flag1 = 1;//时间差
  729. // }
  730. // }
  731. // else if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0)
  732. // {
  733. // ultraGrid2.Rows[j].RowSelectorAppearance.BackColor = Color.Red;
  734. // flag = 2;
  735. // }
  736. // TimeSpan timeSpan = DateTime.Parse(ultraGrid2.Rows[j + 1].Cells["LogsBeg"].Value.ToString()) -
  737. // DateTime.Parse(ultraGrid2.Rows[j].Cells["LogsEnd"].Value.ToString());
  738. // ultraGrid2.Rows[j + 1].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString();
  739. // }
  740. //}
  741. //if (ultraGrid1.Rows.Count > 0 && ultraGrid2.Rows.Count > 0)
  742. //{
  743. // string logsBeg = ultraGrid1.Rows[0].Cells["LogsBeg"].Value.ToString();
  744. // string logsEnd = ultraGrid2.Rows[i - 1].Cells["LogsEnd"].Value.ToString();
  745. // if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) > 0)
  746. // {
  747. // if (TubeRoll.JudgeTime(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) > 0)
  748. // {
  749. // flag1 = 1;//时间差
  750. // }
  751. // }
  752. // else if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) < 0)
  753. // {
  754. // flag = 2;
  755. // }
  756. // TimeSpan timeSpan = DateTime.Parse(logsBeg) - DateTime.Parse(logsEnd);
  757. // ultraGrid1.Rows[0].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString();
  758. //}
  759. }
  760. catch (Exception ex)
  761. {
  762. // MessageUtil.ShowTips(ex.Message);
  763. MessageUtil.ShowTips("开始时间或结束时间不能为空!");
  764. }
  765. }
  766. private string DateDiff(DateTime DateTime1, DateTime DateTime2)
  767. {
  768. string dateDiff = null;
  769. try
  770. {
  771. TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
  772. TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
  773. TimeSpan ts = ts1.Subtract(ts2).Duration();
  774. dateDiff = ts.Minutes.ToString();
  775. }
  776. catch
  777. {
  778. }
  779. return dateDiff;
  780. }
  781. /// <summary>
  782. ///确认
  783. /// </summary>
  784. //private void doConfirm()
  785. //{
  786. // UltraGridRow uow = ultraGrid1.ActiveRow;
  787. // if (uow == null) { MessageUtil.ShowTips("无数据!"); return; }
  788. // ArrayList list = new ArrayList();
  789. // string date = DateTime.Now.ToString();
  790. // int count = 0;
  791. // if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; }
  792. // if (flag1 == 1) { MessageUtil.ShowTips("有停机记录未新增,不允许此操作!"); return; }
  793. // if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; }
  794. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  795. // {
  796. // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true && ugr.Cells["LogsBeg"].Value.ToString().Equals(""))
  797. // {
  798. // MessageUtil.ShowTips("有开始时间为空,不允许此操作!"); return;
  799. // }
  800. // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true && ugr.Cells["LogsEnd"].Value.ToString().Equals(""))
  801. // {
  802. // MessageUtil.ShowTips("有结束时间为空,不允许此操作!"); return;
  803. // }
  804. // }
  805. // ultraGrid1.UpdateData();
  806. // int seqmin1 = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Count();
  807. // if (seqmin1 < 1)
  808. // {
  809. // MessageUtil.ShowTips("没有选中要确认的数据!"); return;
  810. // }
  811. // if (seqmin1 > 0 && ultraGrid1.Rows.Count > 0)
  812. // {
  813. // int seqmin = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Min();
  814. // for (int i = 0; i < seqmin; i++)
  815. // {
  816. // if (ultraGrid1.Rows[i].Cells["ConfirmFlag"].Value.ToString().Trim().Equals("未确认"))
  817. // {
  818. // MessageBox.Show("前面有未确认的数据,请先确认!");
  819. // return;
  820. // }
  821. // }
  822. // }
  823. // //if (flag2 == 1) { MessageUtil.ShowTips("有开始时间为空,不允许此操作!"); return; }
  824. // //if (flag2 == 2) { MessageUtil.ShowTips("有结束时间为空,不允许此操作!"); return; }
  825. // //判断上班是否有未确认的数据
  826. // if (ultraGrid2.Rows.Count() < 1)
  827. // {
  828. // MessageBox.Show("上班有停机记录未新增!");
  829. // return;
  830. // }
  831. // foreach (UltraGridRow row in ultraGrid2.Rows)
  832. // {
  833. // if (row.Cells["ConfirmFlag"].Value.ToString().Trim().Equals("未确认"))
  834. // {
  835. // MessageBox.Show("上班有未确认的数据,请先确认!");
  836. // return;
  837. // }
  838. // }
  839. // string startdate = "";
  840. // string endDate = "";
  841. // if (chkDate.Checked)
  842. // {
  843. // startdate = cmbDate.Value.ToString("yyyyMMdd1800");
  844. // }
  845. // else
  846. // {
  847. // MessageUtil.ShowTips("请选择日期!");
  848. // return;
  849. // //startdate = cmbDate.Value.ToString("199901012100");
  850. // //endDate = cmbEndDate.Value.ToString("203901012100");
  851. // }
  852. // foreach (UltraGridRow ugr in ultraGrid1.Rows)
  853. // {
  854. // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  855. // {
  856. // if (ugr.Cells["ProType"].Text.ToString().Trim().Equals("停机"))
  857. // {
  858. // if (ugr.Cells["StopType"].Value.Equals("") || ugr.Cells["StopSmall"].Value.Equals("") || ugr.Cells["StopReason"].Value.Equals(""))
  859. // {
  860. // MessageUtil.ShowTips("停机大类,停机小类,停机原因不能为空!");
  861. // return;
  862. // }
  863. // }
  864. // string shift = ugr.Cells["ProBc"].Value.ToString();
  865. // string group = ugr.Cells["ProBz"].Value.ToString();
  866. // if (shift != this.UserInfo.GetUserOrder() || group != this.UserInfo.GetUserGroup())
  867. // {
  868. // MessageUtil.ShowTips("您登录的班次班组与要确认的数据班次班组不符,请重新确认!");
  869. // return;
  870. // }
  871. // count += 1;
  872. // ArrayList list1 = new ArrayList();
  873. // list1.Add(ugr.Cells["ControlId"].Text.ToString());
  874. // list1.Add(this.UserInfo.GetUserName());
  875. // list1.Add(date);
  876. // list1.Add(this.UserInfo.GetUserOrder());
  877. // list1.Add(this.UserInfo.GetUserGroup());
  878. // list1.Add(plineCode);
  879. // list1.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  880. // list1.Add(startdate);
  881. // list1.Add(endDate);
  882. // list1.Add(ugr.Cells["JudgeStoveNo"].Text.ToString());
  883. // list.Add(list1);
  884. // }
  885. // }
  886. // if (count == 0)
  887. // {
  888. // MessageUtil.ShowTips("请选中要确认的数据!");
  889. // return;
  890. // }
  891. // string intCount = "0";//是否选择确认
  892. // if (MessageUtil.ShowYesNoAndQuestion("是否只确认选中行数据?") == DialogResult.No)
  893. // {
  894. // intCount = "0";
  895. // if (count == 2)
  896. // {
  897. // MessageUtil.ShowTips("请选择一条数据!");
  898. // return;
  899. // }
  900. // }
  901. // else
  902. // {
  903. // intCount = "1";
  904. // }
  905. // //if (MessageUtil.ShowYesNoAndQuestion("是否确认?") == DialogResult.No)
  906. // //{
  907. // // return;
  908. // //}
  909. // UltraGridRow ugr1 = ultraGrid1.ActiveRow;
  910. // if (ugr1 != null)
  911. // {
  912. // string logbeg = ugr1.Cells["LogsBeg"].Value.ToString();
  913. // }
  914. // CoreClientParam ccp = new CoreClientParam();
  915. // ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
  916. // ccp.MethodName = "confirmMilControlLog";
  917. // ccp.ServerParams = new object[] { list, intCount };
  918. // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  919. // if (ccp.ReturnCode != -1)
  920. // {
  921. // MessageUtil.ShowTips(ccp.ReturnInfo);
  922. // if (ccp.ReturnInfo.Equals("确认成功!"))
  923. // {
  924. // doQuery();
  925. // doAnalysis();
  926. // }
  927. // }
  928. //}
  929. /// <summary>
  930. ///取消确认
  931. /// </summary>
  932. private void UpConfirm()
  933. {
  934. UltraGridRow uow = ultraGrid1.ActiveRow;
  935. if (uow == null) { MessageUtil.ShowTips("无数据!"); return; }
  936. ultraGrid1.UpdateData();
  937. int seqmax1 = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Count();
  938. if (seqmax1 < 1)
  939. {
  940. MessageUtil.ShowTips("没有选中要确认的数据!"); return;
  941. }
  942. if (seqmax1 > 0 && ultraGrid1.Rows.Count() > 0)
  943. {
  944. int seqmax = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Max();
  945. for (int i = seqmax + 1; i < ultraGrid1.Rows.Count(); i++)
  946. {
  947. if (ultraGrid1.Rows[i].Cells["ConfirmFlag"].Value.ToString().Trim().Equals("已确认"))
  948. {
  949. MessageBox.Show("后面有已确认的数据,请先取消确认!");
  950. return;
  951. }
  952. }
  953. }
  954. ArrayList list = new ArrayList();
  955. string date = DateTime.Now.ToString();
  956. int count = 0;
  957. string startdate = "";
  958. string endDate = "";
  959. if (chkDate.Checked)
  960. {
  961. startdate = cmbDate.Value.ToString("yyyyMMdd1800");
  962. }
  963. else
  964. {
  965. MessageUtil.ShowTips("请选择日期!");
  966. return;
  967. //startdate = cmbDate.Value.ToString("199901012100");
  968. //endDate = cmbEndDate.Value.ToString("203901012100");
  969. }
  970. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  971. {
  972. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  973. {
  974. count += 1;
  975. ArrayList list1 = new ArrayList();
  976. list1.Add(ugr.Cells["ControlId"].Text.ToString());
  977. list1.Add(this.UserInfo.GetUserOrder());
  978. list1.Add(this.UserInfo.GetUserGroup());
  979. list1.Add(plineCode);
  980. list1.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"));
  981. list1.Add(startdate);
  982. list1.Add(endDate);
  983. list1.Add(ugr.Cells["JudgeStoveNo"].Text.ToString());
  984. list.Add(list1);
  985. }
  986. }
  987. if (count == 0) { MessageUtil.ShowTips("请选中要取消确认的数据!"); return; }
  988. string intCount = "0";//是否选择取消确认
  989. if (MessageUtil.ShowYesNoAndQuestion("是否只取消确认选中行数据?") == DialogResult.No)
  990. {
  991. intCount = "0";
  992. if (count == 2)
  993. {
  994. MessageUtil.ShowTips("请选择一条数据!");
  995. return;
  996. }
  997. }
  998. else
  999. {
  1000. intCount = "1";
  1001. }
  1002. //if (MessageUtil.ShowYesNoAndQuestion("是否取消确认?") == DialogResult.No)
  1003. //{
  1004. // return;
  1005. //}
  1006. CoreClientParam ccp = new CoreClientParam();
  1007. ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog";
  1008. ccp.MethodName = "upConfirmMilControlLog";
  1009. ccp.ServerParams = new object[] { list, intCount };
  1010. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1011. if (ccp.ReturnCode != -1)
  1012. {
  1013. MessageUtil.ShowTips(ccp.ReturnInfo);
  1014. if (ccp.ReturnInfo.Equals("取消确认成功!"))
  1015. {
  1016. doQuery();
  1017. doAnalysis();
  1018. }
  1019. }
  1020. }
  1021. private void chkDate_CheckedChanged(object sender, EventArgs e)
  1022. {
  1023. if (chkDate.Checked) { cmbDate.Enabled = true; } else { cmbDate.Enabled = false; }
  1024. if (chkBc.Checked) { cmbBc.Enabled = true; } else { cmbBc.Enabled = false; }
  1025. if (chkBz.Checked) { cmbBz.Enabled = true; } else { cmbBz.Enabled = false; }
  1026. if (chkpline.Checked) { cmbPline.Enabled = true; } else { cmbPline.Enabled = false; }
  1027. }
  1028. /// <summary>
  1029. /// Grid字段修改触发事件
  1030. /// </summary>
  1031. /// <param name="sender"></param>
  1032. /// <param name="e"></param>
  1033. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  1034. {
  1035. UltraGridRow row = ultraGrid1.ActiveRow;
  1036. //string stratime = row.Cells["LogsBeg"].Value.ToString();
  1037. //string endtime = row.Cells["LogsEnd"].Value.ToString();
  1038. try
  1039. {
  1040. //string updateStratime = "";
  1041. //string updateEndtime = "";
  1042. ultraGrid1.UpdateData();
  1043. //if (e.Cell.Column.Key.Equals("LogsEnd"))
  1044. //{
  1045. // if (Convert.ToBoolean(e.Cell.Row.Cells["CHK"].Text) == true)
  1046. // {
  1047. // if (e.Cell.Value == null || e.Cell.Value.ToString().Trim().Equals(""))
  1048. // {
  1049. // return;
  1050. // }
  1051. // else
  1052. // {
  1053. // updateEndtime = e.Cell.Row.Cells["LogsEnd"].Value.ToString();
  1054. // TimeSpan midTime = DateTime.Parse(updateEndtime) - DateTime.Parse(endtime);
  1055. // stratday = midTime.Days;
  1056. // strathours = midTime.Hours;
  1057. // stratminutes = midTime.Minutes;
  1058. // int i = e.Cell.Row.Index;//h获取选中行序号
  1059. // UltraGridRow urg = ultraGrid1.Rows.AsQueryable().Where(a => a.Index == i + 1).First();//获取选择行下一行序号
  1060. // DateTime time = DateTime.Parse(urg.Cells["LogsBeg"].Value.ToString()).AddDays(stratday).AddHours(strathours).AddMinutes(stratminutes);
  1061. // urg.Cells["LogsBeg"].Value = time;
  1062. // }
  1063. // }
  1064. // else
  1065. // {
  1066. // MessageUtil.ShowTips("请选择需要修改的数据!");
  1067. // e.Cell.Row.Cells["LogsEnd"].Value = row.Cells["LogsEnd"].Value.ToString();
  1068. // return;
  1069. // }
  1070. //}
  1071. //if (e.Cell.Column.Key.Equals("LogsBeg"))
  1072. //{
  1073. // if (Convert.ToBoolean(e.Cell.Row.Cells["CHK"].Text) == true)
  1074. // {
  1075. // if (e.Cell.Value == null || e.Cell.Value.ToString().Trim().Equals(""))
  1076. // {
  1077. // return;
  1078. // }
  1079. // else
  1080. // {
  1081. // updateStratime = e.Cell.Row.Cells["LogsBeg"].Value.ToString();
  1082. // TimeSpan midTime = DateTime.Parse(updateStratime) - DateTime.Parse(stratime);
  1083. // endday = midTime.Days;
  1084. // endhours = midTime.Hours;
  1085. // endminutes = midTime.Minutes;
  1086. // int i = e.Cell.Row.Index;//h获取选中行序号
  1087. // UltraGridRow urg = ultraGrid1.Rows.AsQueryable().Where(a => a.Index == i -1).First();//获取选择行上一行序号
  1088. // //if (urg.Index < 0) return;
  1089. // DateTime time = DateTime.Parse(urg.Cells["LogsEnd"].Value.ToString()).AddDays(endday).AddHours(endhours).AddMinutes(endminutes);
  1090. // urg.Cells["LogsEnd"].Value = time;
  1091. // }
  1092. // }
  1093. // else
  1094. // {
  1095. // MessageUtil.ShowTips("请选择需要修改的数据!");
  1096. // e.Cell.Row.Cells["LogsBeg"].Value = row.Cells["LogsBeg"].Value.ToString();
  1097. // return;
  1098. // }
  1099. //}
  1100. if (e.Cell.Column.Key.Equals("QualifiedNum"))
  1101. {
  1102. if (e.Cell.Row.Cells["QualifiedNum"].Value == null)
  1103. {
  1104. e.Cell.Row.Cells["QualifiedNum"].Value = "0";
  1105. }
  1106. else
  1107. {
  1108. string actCount = e.Cell.Row.Cells["QualifiedNum"].Value.ToString();
  1109. if (!StringUtil.IsInt(actCount) || actCount == "0")//actCount == "" || int.Parse(actCount)==0
  1110. {
  1111. e.Cell.Row.Cells["QualifiedNum"].Value = "0";
  1112. }
  1113. }
  1114. }
  1115. if (e.Cell.Column.Key.Equals("QualifiedWt"))
  1116. {
  1117. if (e.Cell.Row.Cells["QualifiedWt"].Value == null)
  1118. {
  1119. e.Cell.Row.Cells["QualifiedWt"].Value = "0";
  1120. }
  1121. else
  1122. {
  1123. string actWt = e.Cell.Row.Cells["QualifiedWt"].Value.ToString();
  1124. if (!StringUtil.IsDouble(actWt) || actWt == "0")//actCount == "" || int.Parse(actCount)==0
  1125. {
  1126. e.Cell.Row.Cells["QualifiedWt"].Value = "0";
  1127. }
  1128. }
  1129. }
  1130. if (e.Cell.Column.Key.Equals("ScrapNum"))
  1131. {
  1132. if (e.Cell.Row.Cells["ScrapNum"].Value == null)
  1133. {
  1134. e.Cell.Row.Cells["ScrapNum"].Value = "0";
  1135. }
  1136. else
  1137. {
  1138. string scrpNum = e.Cell.Row.Cells["ScrapNum"].Value.ToString();
  1139. if (!StringUtil.IsInt(scrpNum) || scrpNum == "0")//actCount == "" || int.Parse(actCount)==0
  1140. {
  1141. e.Cell.Row.Cells["ScrapNum"].Value = "0";
  1142. }
  1143. }
  1144. }
  1145. if (e.Cell.Column.Key.Equals("ScrapWt"))
  1146. {
  1147. if (e.Cell.Row.Cells["ScrapWt"].Value == null)
  1148. {
  1149. e.Cell.Row.Cells["ScrapWt"].Value = "0";
  1150. }
  1151. else
  1152. {
  1153. string scrpwt = e.Cell.Row.Cells["ScrapWt"].Value.ToString();
  1154. if (!StringUtil.IsDouble(scrpwt) || scrpwt == "0")//actCount == "" || int.Parse(actCount)==0
  1155. {
  1156. e.Cell.Row.Cells["ScrapWt"].Value = "0";
  1157. }
  1158. }
  1159. }
  1160. if (e.Cell.Column.Key.Equals("StopType"))
  1161. {
  1162. e.Cell.Row.Cells["StopSmall"].Value = "";
  1163. e.Cell.Row.Cells["StopReason"].Value = "";
  1164. }
  1165. if (e.Cell.Column.Key.Equals("StopSmall"))
  1166. {
  1167. e.Cell.Row.Cells["StopReason"].Value = "";
  1168. }
  1169. }
  1170. catch (Exception ex)
  1171. {
  1172. //MessageUtil.ShowTips("您输入的时间格式不正确!");
  1173. //e.Cell.Row.Cells["LogsBeg"].Value = row.Cells["LogsBeg"].Value.ToString();
  1174. //e.Cell.Row.Cells["LogsEnd"].Value = row.Cells["LogsEnd"].Value.ToString();
  1175. return;
  1176. }
  1177. }
  1178. private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e)
  1179. {
  1180. e.RaiseErrorEvent = false;
  1181. MessageUtil.ShowTips("您输入的时间格式不正确!");
  1182. }
  1183. /// <summary>
  1184. /// 停机原因
  1185. /// </summary>
  1186. /// <param name="sender"></param>
  1187. /// <param name="e"></param>
  1188. private void cmbStopReason_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1189. {
  1190. UltraGridRow row = ultraGrid1.ActiveRow;
  1191. if (row == null) return;
  1192. string stopSallm = basecodeSamll;
  1193. if (!row.Cells["StopSmall"].Text.Equals("")) { stopSallm = row.Cells["StopSmall"].Text; }
  1194. FrmStopSamll fpdc = new FrmStopSamll(basecodeSamll, ob);
  1195. fpdc.AutoSize = true;
  1196. fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  1197. fpdc.Text = "停机原因";
  1198. fpdc.ShowDialog();
  1199. if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK)
  1200. {
  1201. //获取弹出窗体的属性值
  1202. row.Cells["StopReasonm"].Value = fpdc.Basename;
  1203. //cmbStopReason.Value = fpdc.Basename;
  1204. basecodeReason = fpdc.Basecode;
  1205. }
  1206. }
  1207. /// <summary>
  1208. /// 停机小类
  1209. /// </summary>
  1210. /// <param name="sender"></param>
  1211. /// <param name="e"></param>
  1212. private void cmbStopSmall_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1213. {
  1214. UltraGridRow row = ultraGrid1.ActiveRow;
  1215. string stoptype = "";
  1216. if (!row.Cells["StopType"].Text.Trim().Equals(""))
  1217. {
  1218. stoptype = row.Cells["StopType"].Value.ToString();
  1219. }
  1220. FrmStopSamll fpdc = new FrmStopSamll(stoptype, ob);
  1221. fpdc.AutoSize = true;
  1222. fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  1223. fpdc.Text = "停机小类";
  1224. fpdc.ShowDialog();
  1225. if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK)
  1226. {
  1227. //获取弹出窗体的属性值
  1228. row.Cells["StopSmallm"].Value = fpdc.Basename;
  1229. //cmbStopSmall.Value = fpdc.Basename;
  1230. basecodeSamll = fpdc.Basecode;
  1231. }
  1232. }
  1233. /// <summary>
  1234. /// 班次中文
  1235. /// </summary>
  1236. /// <param name="dtShift"></param>
  1237. /// <returns></returns>
  1238. private string changeShift(string dtShift)
  1239. {
  1240. switch (dtShift)
  1241. {
  1242. case "1":
  1243. dtShift = "早班";
  1244. break;
  1245. case "2":
  1246. dtShift = "中班";
  1247. break;
  1248. case "3":
  1249. dtShift = "夜班";
  1250. break;
  1251. }
  1252. return dtShift;
  1253. }
  1254. /// <summary>
  1255. /// 班组中文
  1256. /// </summary>
  1257. /// <param name="dtGroup"></param>
  1258. /// <returns></returns>
  1259. private string changeGroup(string dtGroup)
  1260. {
  1261. switch (dtGroup)
  1262. {
  1263. case "1":
  1264. dtGroup = "甲班";
  1265. break;
  1266. case "2":
  1267. dtGroup = "乙班";
  1268. break;
  1269. case "3":
  1270. dtGroup = "丙班";
  1271. break;
  1272. case "4":
  1273. dtGroup = "丁班";
  1274. break;
  1275. }
  1276. return dtGroup;
  1277. }
  1278. }
  1279. }