| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Mcp.Control.Base;
- using Core.StlMes.Client.Mcp.Control.Common;
- using Core.StlMes.Client.Mcp.Control.Entity;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using System.Collections;
- namespace Core.StlMes.Client.Mcp.Treatment.Report
- {
- public partial class FrmHttControlLogUpdate : FrmBase
- {
- private string date = "";
- private string endDate = "";
- private string departm = "";
- private int flag = 0; //分析时间错误
- private int flag1 = 0; //分析相差时间
- private string station = ""; //工序点
- private string ProcessCode = "";
- private HttControlShiftEntity httControlShiftEntity;
- private string plineCode;
- private UltraComboEditor ucePline = new UltraComboEditor(); //产线名称
- public FrmHttControlLogUpdate()
- {
- InitializeComponent();
- }
- private void FrmHttControlLogUpdate_Load(object sender, EventArgs e)
- {
- departm = UserInfo.GetDepartment();
- //plineCode = YdmBaseClass.GetPCode(departm, this.ob);//获取 用户 对应的产线
- if (UserInfo.GetUserOrder().Equals("3"))
- {
- cmbDate.Value = DateTime.Parse(DateTime.Now.AddDays(0.5d).ToString("yyyy-MM-dd"));
- cmbDate2.Value = DateTime.Parse(DateTime.Now.AddDays(0.5d).ToString("yyyy-MM-dd"));
- }
- else
- {
- cmbDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
- cmbDate2.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
- }
- EntityHelper.ShowGridCaption<HttControlLogEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- ultraGrid1.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select;
- ProcessCode = this.CustomInfo.ToString2();
- if (ProcessCode == "") ProcessCode = "F";
- var plineCodes = comm.InitDropPlinePower(ProcessCode, comPlineCode, ValidDataPurviewIds, ob);
- if (plineCodes.Length > 0) comPlineCode.SelectedIndex = 0;
- var dt2 = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getBaseInfo",
- new object[] { "600701" }, ob);
- if (dt2.Rows.Count > 0)
- {
- }
- var list = new ValueList();
- var list2 = new ValueList();
- string FailCode = "";
- if (ProcessCode == "F")
- {
- FailCode = "6006";
- ultraSTATION2.Visible = false;
- }
- else
- {
- FailCode = "7025";
- ultraSTATION1.Visible = false;
- }
- var list1 = new ValueList();
- var list3 = new ValueList();
- var dt = TubeRoll.GetComBaseInfo(FailCode, ob);
- foreach (DataRow row in dt.Rows)
- {
- list1.ValueListItems.Add(row["BASECODE"].ToString(), row["BASENAME"].ToString());
- list3.ValueListItems.Add(row["BASECODE"].ToString(), row["BASENAME"].ToString());
- }
- ultraGrid1.DisplayLayout.Bands[0].Columns["StopType"].ValueList = list1;
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- doQuery();
- break;
- case "Update":
- doUpdate();
- break;
- case "Export":
- if (ProcessCode == "F")
- {
- GridHelper.ulGridToExcel(ultraGrid1, "热处理调度停机日志");
- }
- if (ProcessCode == "G")
- {
- GridHelper.ulGridToExcel(ultraGrid1, "加工线调度停机日志");
- }
- break;
- case "Close":
- Close();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void doQuery()
- {
- if (ProcessCode == "F")
- {
- station = ultraSTATION1.Value.ToString();
- }
- if (ProcessCode == "G")
- {
- station = ultraSTATION2.Value.ToString();
- }
- date = cmbDate.Value.ToString("yyyyMMdd");
- endDate = cmbDate2.Value.ToString("yyyyMMdd");
- List<HttControlLogEntity> listSource = EntityHelper.GetData<HttControlLogEntity>
- ("com.steering.mes.mcp.Report.FrmHttControlLog.doQueryStop", new object[] { date, endDate, plineCode, station }, this.ob);
- httControlLogEntityBindingSource.DataSource = listSource;
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsBeg"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsBeg"].MaskInput = "yyyy-mm-dd hh:mm";
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsEnd"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["LogsEnd"].MaskInput = "yyyy-mm-dd hh:mm";
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void doUpdate()
- {
- ultraGrid1.UpdateData();
- try
- {
- var list =
- httControlLogEntityBindingSource.DataSource as List<HttControlLogEntity>;
- if (list == null)
- {
- MessageUtil.ShowTips("请选择要修改的数据!");
- return;
- }
- list = list.Where(p => p.Chk).Select(p => p.Clone()).ToList();
- if (!list.Any())
- {
- MessageUtil.ShowTips("请选择要修改的数据!");
- return;
- }
- if (list.Any(p => p.StopReason.ToString() == ""))
- {
- MessageUtil.ShowTips("请选择停机原因!");
- return;
- }
- //if (list.Any(p => p.ConfirmFlag != "未确认"))
- //{
- // MessageUtil.ShowTips("请选择未确认的数据!");
- // return;
- //}
- for (var i = 0; i < list.Count; i++)
- {
- DateTime dtStart, dtEnd;
- if (DateTime.TryParse(list[i].LogsBeg, out dtStart))
- list[i].LogsBeg = dtStart.ToString("yyyyMMddHHmm");
- if (DateTime.TryParse(list[i].LogsEnd, out dtEnd))
- list[i].LogsEnd = dtEnd.ToString("yyyyMMddHHmm");
- }
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.mcp.Report.FrmHttControlLog";
- ccp.MethodName = "updateMilControlLogStop";
- ccp.ServerParams = new object[]
- {
- list.Select(JSONFormat.Format).ToList()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("修改成功!"))
- doQuery();
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips(ex.Message);
- }
- }
- private void chkDate_CheckedChanged(object sender, EventArgs e)
- {
- if (chkDate.Checked) cmbDate.Enabled = true;
- else cmbDate.Enabled = false;
- }
- private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e)
- {
- e.RaiseErrorEvent = false;
- MessageUtil.ShowTips("您输入的时间格式不正确!");
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- var entity = e.Row.ListObject as HttControlLogEntity;
- if (entity == null) return;
- var list1 = new ValueList();
- var dt = TubeRoll.GetComBaseInfo(entity.StopType, ob);
- foreach (DataRow row in dt.Rows)
- list1.ValueListItems.Add(row["BASECODE"].ToString(), row["BASENAME"].ToString());
- e.Row.Cells["StopSmall"].ValueList = list1;
- var list2 = new ValueList();
- var dt2 = TubeRoll.GetComBaseInfo(entity.StopSmall, ob);
- foreach (DataRow row in dt2.Rows)
- list2.ValueListItems.Add(row["BASECODE"].ToString(), row["BASENAME"].ToString());
- e.Row.Cells["StopReason"].ValueList = list2;
- }
- private void ultraGrid1_CellChange_1(object sender, CellEventArgs e)
- {
- try
- {
- if (ultraGrid1.ActiveRow != null)
- ultraGrid1.ActiveRow.Cells["Chk"].Value = true;
- if (((e.Cell.Column.Key == "LogsEnd") || (e.Cell.Column.Key == "LogsBeg")) && e.Cell.Text.Contains("_"))
- {
- return;
- }
- if ((e.Cell.Column.Key == "Memo")) return;
- ultraGrid1.UpdateData();
- if (e.Cell.Column.Key == "StopType")
- {
- var list1 = new ValueList();
- var dt = TubeRoll.GetComBaseInfo(e.Cell.Value.ToString(), ob);
- foreach (DataRow row in dt.Rows)
- list1.ValueListItems.Add(row["BASECODE"].ToString(), row["BASENAME"].ToString());
- e.Cell.Row.Cells["StopSmall"].ValueList = list1;
- e.Cell.Row.Cells["StopSmall"].Value = "";
- e.Cell.Row.Cells["StopReason"].Value = "";
- }
- if (e.Cell.Column.Key == "StopSmall")
- {
- var list2 = new ValueList();
- var dt2 = TubeRoll.GetComBaseInfo(e.Cell.Value.ToString(), ob);
- foreach (DataRow row in dt2.Rows)
- list2.ValueListItems.Add(row["BASECODE"].ToString(), row["BASENAME"].ToString());
- e.Cell.Row.Cells["StopReason"].ValueList = list2;
- e.Cell.Row.Cells["StopReason"].Value = "";
- }
- }
- catch (Exception)
- {
- }
- }
- private double DateDiff(DateTime DateTime1, DateTime DateTime2)
- {
- double dateDiff = 0;
- try
- {
- var ts1 = new TimeSpan(DateTime1.Ticks);
- var ts2 = new TimeSpan(DateTime2.Ticks);
- var ts = ts1.Subtract(ts2);
- dateDiff = ts.TotalMinutes;
- }
- catch
- {
- }
- return dateDiff;
- }
- private void comPlineCode_ValueChanged(object sender, EventArgs e)
- {
- plineCode = comPlineCode.SelectedItem.DataValue.ToString();
- doQuery();
- }
- private void ultraGrid3_AfterRowInsert(object sender, RowEventArgs e)
- {
- e.Row.Cells["Chk"].Value = true;
- e.Row.Cells["ControlId"].Value = ultraGrid1.ActiveRow.Cells["ControlId"].Value;
- }
- private void ultraGrid3_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- var entity = e.Row.ListObject as HttControlLogDetailEntity;
- if (entity == null) return;
- }
- private void cmsCopy_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- UltraGrid ug = (sender as ContextMenuStrip).SourceControl as UltraGrid;
- if (ug == null || ug.ActiveCell == null)
- {
- return;
- }
- if (e.ClickedItem.Name == "tsmCopy")
- {
- Clipboard.SetText(ug.ActiveCell.Text);
- }
- else
- {
- if (ug.ActiveCell.Activation == Activation.AllowEdit && ultraGrid1.ActiveRow != null && ultraGrid1.ActiveRow.Cells["ConfirmFlag"].Value.ToString() == "未确认")
- {
- string text = Clipboard.GetText();
- try
- {
- ug.ActiveCell.Value = text;
- }
- catch (Exception)
- {
- }
- }
- }
- }
- }
- }
|