using com.steering.mes.zgmil.entity; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.ZGMil.Entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.ZGMil.Signature { public partial class FrmMilControlLogPub : FrmBase { private string departm = ""; UltraComboEditor ucePline = new UltraComboEditor();//产线名称 private string[] plineCode; int flag = 0;//分析时间错误 int flag1 = 0;//分析相差时间 private string basecodeSamll = "";//停机小类值 private string basecodeReason = "";//停机原因值 public FrmMilControlLogPub() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmMilControlLogPub_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); NativeMethodNew na = new NativeMethodNew(this.ob); //departm = UserInfo.GetDepartment(); //plineCode = na.GetPCode(departm);//获取 用户 对应的产线 plineCode = na.GetPCodePline(this.ValidDataPurviewIds);//获取产线方法 TubeRoll.InitComboEditorWithParm(cmbPlineE, "com.steering.mes.signature.FrmTubeRollFileManage.GetPCode", "PlineCode", this.ob, false, this.ValidDataPurviewIds); TubeRoll.BindColumn(ucePline, "PlineCode", this.Controls, this.ultraGrid1, 0); TubeRoll.InitComboEditorWithParm(cmbPline, "com.steering.mes.signature.FrmTubeRollFileManage.GetPCode", "PlineCode", this.ob, false, this.ValidDataPurviewIds); cmbPline.DataSource = ServerHelper.GetData("com.steering.mes.signature.FrmTubeRollFileManage.GetPCode", new object[] { this.ValidDataPurviewIds }, this.ob); cmbPline.ValueMember = "PLINE_CODE"; cmbPline.DisplayMember = "PLINE_NAME"; //TubeRoll.SetComboItemHeight(cmbPline); cmbPline.SelectedIndex = 0; //cmbPlineE.DataSource = ServerHelper.GetData("com.steering.mes.signature.FrmTubeRollFileManage.queryPlineCode", new object[] { plineCode }, this.ob); //cmbPlineE.ValueMember = "PLINE_CODE"; //cmbPlineE.DisplayMember = "PLINE_NAME"; //TubeRoll.SetComboItemHeight(cmbPlineE); cmbEndDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 20:59:59")); cmbDate.Value = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 21:00:00")); //cmbPline.Value = na.GetPCodePline(this.ValidDataPurviewIds); TubeRoll.setUltraGridColumnInput(ultraGrid1, new string[] { "QualifiedNum","ScrapNum" });//支数 TubeRoll.setUltraGridColumnMaxInput(ultraGrid1, new string[] { "QualifiedWt","ScrapWt" });//重量 //TubeRoll.SetComboItemHeight(cmbPline); TubeRoll.SetComboItemHeight(cmbBc); TubeRoll.SetComboItemHeight(cmbBz); DataTable dt = TubeRoll.GetComBaseInfo("5006", ob); cmbStop.DataSource = dt; cmbStop.ValueMember = "BASECODE"; cmbStop.DisplayMember = "BASENAME"; TubeRoll.SetComboItemHeight(cmbStop); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Add": doAdd(); break; case "Update": doUpdate(); break; case "Delete": doDelete(); break; case "Analysis": doAnalysis(); break; case"Confirm": doConfirm(); break; case "UpConfirm": UpConfirm(); break; case "Statistical": DoStatistical(); break; case "Export": GridHelper.ulGridToExcel(ultraGrid1, "轧管调度日志"); break; case "Close": this.Close(); break; } } /// /// 查询统计数据 /// private void DoStatistical() { doQuery(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; foreach (UltraGridRow urg in ultraGrid1.Rows) { if (urg.Cells["ConfirmFlag"].Text.Equals("未确认")) { MessageUtil.ShowTips("未确认,不允许此操作!"); return; } } string plinNoc = ""; string strbc = ""; string strbz = ""; if (cmbPline.Text.Equals("")) { MessageUtil.ShowTips("机组不能为空!"); return; } else { plinNoc = cmbPline.Value.ToString(); } if (cmbBz.Text.Equals("")) { MessageUtil.ShowTips("班组不能为空!"); return; } else { strbz = cmbBz.Value.ToString(); } if (cmbBc.Text.Equals("")) { MessageUtil.ShowTips("班次不能为空!"); return; } else { strbc = cmbBc.Value.ToString(); } //FrmStatisticalPub fsta = new FrmStatisticalPub(plinNoc, ob, strbc, strbz); //fsta.AutoSize = true; //fsta.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); //fsta.Text = "统计查询"; //fsta.ShowDialog(); } /// /// 查询 /// private void doQuery() { ArrayList list = new ArrayList(); string date = ""; string endDate = ""; string plineNo = ""; string bc = ""; string bz = ""; if (chkDate.Checked) { if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0) { MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!"); return; } else { date = cmbDate.Value.ToString("yyyyMMddHHmm"); endDate = cmbEndDate.Value.ToString("yyyyMMddHHmm"); } } else { date = cmbDate.Value.ToString("199901010000"); endDate = cmbEndDate.Value.ToString("203901012359"); } if (chkpline.Checked) { if (cmbPline.Text.Equals("")) { MessageUtil.ShowTips("请选择机组!"); return; } else { plineNo = cmbPline.Value.ToString(); } } if (chkBz.Checked) { if (cmbBz.Text.Equals("")) { MessageUtil.ShowTips("请选择班组!"); return; } else { bz = cmbBz.Value.ToString(); } } if (chkBc.Checked) { if (cmbBc.Text.Equals("")) { MessageUtil.ShowTips("请选择班次!"); return; } else { bc = cmbBc.Value.ToString(); } } List listSource = EntityHelper.GetData ("com.steering.mes.signature.FrmMilControlLog.doQueryPlan", new object[] { date, endDate, bc, bz, plineNo,"" }, this.ob); MilControlLogEntity.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"; foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.Cells["ProType"].Text.ToString().Trim().Equals("停机")) { row.Cells["StopType"].Appearance.BackColor = Color.FromArgb(255, 255, 192); row.Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None; row.Cells["StopType"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; row.Cells["StopReasonm"].Appearance.BackColor = Color.FromArgb(255, 255, 192); row.Cells["StopReasonm"].Appearance.BackHatchStyle = BackHatchStyle.None; row.Cells["StopReasonm"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; row.Cells["StopSmallm"].Appearance.BackColor = Color.FromArgb(255, 255, 192); row.Cells["StopSmallm"].Appearance.BackHatchStyle = BackHatchStyle.None; row.Cells["StopSmallm"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; } else { row.Cells["StopType"].Appearance.BackColor = Color.Transparent; row.Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.Default; row.Cells["StopType"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; row.Cells["StopReasonm"].Appearance.BackColor = Color.Transparent; row.Cells["StopReasonm"].Appearance.BackHatchStyle = BackHatchStyle.Default; row.Cells["StopReasonm"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; row.Cells["StopSmallm"].Appearance.BackColor = Color.Transparent; row.Cells["StopSmallm"].Appearance.BackHatchStyle = BackHatchStyle.Default; row.Cells["StopSmallm"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; } } } /// /// 新增 /// private void doAdd() { ultraGrid1.UpdateData(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowTips("无数据!"); return; } int count = 0; int statrindex = 0;//第一行记录 int endindex = 0;//最后一行记录 string statime = "";//新增开始时间 string endtime = "";//新增结束时间 string datetime1 = "";//获取选中第一行结束时间 string datetime2 = "";//获取选中第二行开始时间 foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { statime = DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).AddMinutes(1).ToString("yyyyMMddHHmm");//新增开始时间 datetime1 = DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm"); statrindex = ugr.Index; break; } } foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { count += 1; endindex = ugr.Index; endtime = DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).AddMinutes(-1).ToString("yyyyMMddHHmm");//新增结束时间 datetime2 = DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"); } } int index = endindex - statrindex; if (double.Parse(datetime1) >= double.Parse(datetime2)) { MessageUtil.ShowTips("选中第一行数据结束时间不能大于等于选中第二行开始时间,请确认?"); return; } if (count == 0 || count > 2 || count < 2 && index < 2) { MessageUtil.ShowTips("请选择数据且选择相邻两条数据新增!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No) { return; } ArrayList pram = new ArrayList(); pram.Add(statime); pram.Add(endtime); pram.Add(this.UserInfo.GetUserName()); pram.Add(this.UserInfo.GetUserOrder()); pram.Add(this.UserInfo.GetUserGroup()); pram.Add(plineCode); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog"; ccp.MethodName = "addMilControlLog"; ccp.ServerParams = new object[] { pram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("新增成功!")) { doQuery(); } } } /// /// 修改 /// private void doUpdate() { ultraGrid1.UpdateData(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowTips("无数据!"); return; } int count = 0; int statrindex = 0;//选择行记录 int endindex = 0;//最后一行记录 //if (flag == false) { MessageUtil.ShowTips("未分析或分析后数据不通过!"); return; } ArrayList list = new ArrayList(); try { foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { count += 1; //string plineCode1 = ""; //if (!ugr.Cells["PlineCode"].Text.ToString().Equals("")) //{ // plineCode1 = ugr.Cells["PlineCode"].Value.ToString(); //} string stopType = ""; if (!ugr.Cells["StopType"].Text.ToString().Equals("")) { stopType = ugr.Cells["StopType"].Value.ToString(); } string stopReason = ""; if (!ugr.Cells["StopReasonm"].Text.ToString().Equals("")) { stopReason = basecodeReason;// ugr.Cells["StopReason"].Value.ToString(); } string stopSmall = ""; if (!ugr.Cells["StopSmallm"].Text.ToString().Equals("")) { stopSmall = basecodeSamll;// ugr.Cells["StopSmall"].Value.ToString(); } string bc = ""; if (!ugr.Cells["ProBc"].Text.ToString().Equals("")) { bc = ugr.Cells["ProBc"].Value.ToString(); } string bz = ""; if (!ugr.Cells["ProBz"].Text.ToString().Equals("")) { bz = ugr.Cells["ProBz"].Value.ToString(); } if (Convert.ToDateTime(ugr.Cells["LogsBeg"].Value.ToString()) >= Convert.ToDateTime(ugr.Cells["LogsEnd"].Value.ToString())) { MessageUtil.ShowTips("开始时间不能大于等于结束时间!"); return; } ArrayList pram = new ArrayList(); pram.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyy-MM-dd HH:mm")); pram.Add(DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyy-MM-dd HH:mm")); pram.Add(plineCode); pram.Add(stopType); pram.Add(stopReason); pram.Add(ugr.Cells["QualifiedNum"].Value.ToString()); pram.Add(ugr.Cells["QualifiedWt"].Value.ToString()); pram.Add(ugr.Cells["ScrapNum"].Value.ToString()); pram.Add(ugr.Cells["ScrapWt"].Value.ToString()); pram.Add(bc); pram.Add(bz); pram.Add(ugr.Cells["ControlId"].Value.ToString()); pram.Add(stopSmall); list.Add(pram); } } int index = endindex - statrindex; if (count == 0 || count > 1) { MessageUtil.ShowTips("请选择一条需要修改的数据!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog"; ccp.MethodName = "updateMilControlLog"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("修改成功!")) { doQuery(); } } } catch (Exception ex) { MessageUtil.ShowTips("开始时间或结束时间不能为空!"); } } /// /// 删除 /// private void doDelete() { ultraGrid1.UpdateData(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowTips("无数据!"); return; } int count = 0; ArrayList list = new ArrayList(); foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { count += 1; if (ugr.Cells["ProType"].Text.Equals("正常")) { MessageUtil.ShowTips("请选择停机数据!"); return; } ArrayList pram = new ArrayList(); pram.Add(ugr.Cells["ControlId"].Value.ToString()); list.Add(pram); } } if (count == 0) { MessageUtil.ShowTips("请选择要删除的停机数据!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否删除?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog"; ccp.MethodName = "deleteMilControlLog"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("删除成功!")) { doQuery(); } } } /// ///分析 /// private void doAnalysis() { flag = 1; int i = 0; try { foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (!ugr.Cells["LogsEnd"].Value.Equals("")) { i += 1; if (Convert.ToDateTime(ugr.Cells["LogsBeg"].Value.ToString()) >= Convert.ToDateTime(ugr.Cells["LogsEnd"].Value.ToString())) { ugr.RowSelectorAppearance.BackColor = Color.Red; //ugr.Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None; //ugr.Cells["LogsEnd"].Appearance.BackColor = Color.Red; //ugr.Cells["LogsEnd"].Appearance.BackHatchStyle = BackHatchStyle.None; flag = 2;//分析时间错误 } } } for (int j = 0; j < i; j++) { string loagEnd = ultraGrid1.Rows[j].Cells["LogsEnd"].Text.ToString(); string loagBeg = ""; if (j + 1 < i) { loagBeg = ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Text.ToString(); if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) > 0) { if (TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) >=3) { ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.Pink; ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None; ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackColor = Color.Pink; ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None; flag1 = 1;//时间差 } //else if (TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) <= 5 && TubeRoll.JudgeTime(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd))>=3) //{ // ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.LightGray; // ultraGrid1.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None; // ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackColor = Color.LightGray; // ultraGrid1.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None; // flag = 2; //} } else if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0) { ultraGrid1.Rows[j].RowSelectorAppearance.BackColor = Color.Red; ultraGrid1.Rows[j + 1].RowSelectorAppearance.BackColor = Color.Red; //ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Appearance.BackColor = Color.Orange; //ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None; //ultraGrid1.Rows[j].Cells["LogsBeg"].Appearance.BackColor = Color.Orange; //ultraGrid1.Rows[j].Cells["LogsBeg"].Appearance.BackHatchStyle = BackHatchStyle.None; flag = 2; } TimeSpan timeSpan = DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()) - DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString()); ultraGrid1.Rows[j+1].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString(); } } } catch (Exception ex) { MessageUtil.ShowTips("开始时间或结束时间不能为空!"); } } private string DateDiff(DateTime DateTime1, DateTime DateTime2) { string dateDiff = null; try { TimeSpan ts1 = new TimeSpan(DateTime1.Ticks); TimeSpan ts2 = new TimeSpan(DateTime2.Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration(); dateDiff = ts.Minutes.ToString(); } catch { } return dateDiff; } /// ///确认 /// private void doConfirm() { string startdate = "1999-01-01"; string endDate = "2999-01-01"; UltraGridRow uow = ultraGrid1.ActiveRow; if (uow == null) return; ArrayList list = new ArrayList(); string date = DateTime.Now.ToString(); int count = 0; if (flag != 1) { MessageUtil.ShowTips("未分析或分析后数据不通过!"); return; } foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (!ugr.Cells["LogsEnd"].Value.Equals("")) { count += 1; ArrayList list1 = new ArrayList(); list1.Add(ugr.Cells["ControlId"].Text.ToString()); list1.Add(this.UserInfo.GetUserName()); list1.Add(date); list.Add(list1); } } if (chkDate.Checked) { startdate = cmbDate.Value.ToString("yyyyMMddHHmm"); endDate = cmbEndDate.Value.ToString("yyyyMMddHHmm"); } else { startdate = cmbDate.Value.ToString("199901010000"); endDate = cmbEndDate.Value.ToString("203901012359"); } ArrayList pram = new ArrayList(); pram.Add(startdate); pram.Add(endDate); pram.Add(plineCode); pram.Add(this.UserInfo.GetUserOrder()); pram.Add(this.UserInfo.GetUserGroup()); if (MessageUtil.ShowYesNoAndQuestion("是否确认?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog"; ccp.MethodName = "confirmMilControlLog"; ccp.ServerParams = new object[] { list, count.ToString(), pram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("确认成功!")) { doQuery(); } } } /// ///取消确认 /// private void UpConfirm() { string startdate = "1999-01-01"; string endDate = "2999-01-01"; UltraGridRow uow = ultraGrid1.ActiveRow; if (uow == null) return; ArrayList list = new ArrayList(); string date = DateTime.Now.ToString(); int count = 0; foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (!ugr.Cells["LogsEnd"].Value.Equals("")) { count += 1; ArrayList list1 = new ArrayList(); list1.Add(ugr.Cells["ControlId"].Text.ToString()); list.Add(list1); } } if (chkDate.Checked) { startdate = cmbDate.Value.ToString("yyyyMMddHHmm"); endDate = cmbEndDate.Value.ToString("yyyyMMddHHmm"); } else { startdate = cmbDate.Value.ToString("199901010000"); endDate = cmbEndDate.Value.ToString("203901012359"); } ArrayList pram = new ArrayList(); pram.Add(startdate); pram.Add(endDate); pram.Add(plineCode); pram.Add(this.UserInfo.GetUserOrder()); pram.Add(this.UserInfo.GetUserGroup()); if (MessageUtil.ShowYesNoAndQuestion("是否取消确认?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog"; ccp.MethodName = "upConfirmMilControlLog"; ccp.ServerParams = new object[] { list, count.ToString(), pram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("取消确认成功!")) { doQuery(); } } } private void chkDate_CheckedChanged(object sender, EventArgs e) { if (chkDate.Checked) { cmbDate.Enabled = true; cmbEndDate.Enabled = true; } else { cmbDate.Enabled = false; cmbEndDate.Enabled = false; } if (chkBc.Checked) { cmbBc.Enabled = true; } else { cmbBc.Enabled = false; } if (chkBz.Checked) { cmbBz.Enabled = true; } else { cmbBz.Enabled = false; } if (chkpline.Checked) { cmbPline.Enabled = true; } else { cmbPline.Enabled = false; } } /// /// Grid字段修改触发事件 /// /// /// private void ultraGrid1_CellChange(object sender, CellEventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; //string stratime = row.Cells["LogsBeg"].Value.ToString(); //string endtime = row.Cells["LogsEnd"].Value.ToString(); try { //string updateStratime = ""; //string updateEndtime = ""; ultraGrid1.UpdateData(); //if (e.Cell.Column.Key.Equals("LogsEnd")) //{ // if (Convert.ToBoolean(e.Cell.Row.Cells["CHK"].Text) == true) // { // if (e.Cell.Value == null || e.Cell.Value.ToString().Trim().Equals("")) // { // return; // } // else // { // updateEndtime = e.Cell.Row.Cells["LogsEnd"].Value.ToString(); // TimeSpan midTime = DateTime.Parse(updateEndtime) - DateTime.Parse(endtime); // stratday = midTime.Days; // strathours = midTime.Hours; // stratminutes = midTime.Minutes; // int i = e.Cell.Row.Index;//h获取选中行序号 // UltraGridRow urg = ultraGrid1.Rows.AsQueryable().Where(a => a.Index == i + 1).First();//获取选择行下一行序号 // DateTime time = DateTime.Parse(urg.Cells["LogsBeg"].Value.ToString()).AddDays(stratday).AddHours(strathours).AddMinutes(stratminutes); // urg.Cells["LogsBeg"].Value = time; // } // } // else // { // MessageUtil.ShowTips("请选择需要修改的数据!"); // e.Cell.Row.Cells["LogsEnd"].Value = row.Cells["LogsEnd"].Value.ToString(); // return; // } //} //if (e.Cell.Column.Key.Equals("LogsBeg")) //{ // if (Convert.ToBoolean(e.Cell.Row.Cells["CHK"].Text) == true) // { // if (e.Cell.Value == null || e.Cell.Value.ToString().Trim().Equals("")) // { // return; // } // else // { // updateStratime = e.Cell.Row.Cells["LogsBeg"].Value.ToString(); // TimeSpan midTime = DateTime.Parse(updateStratime) - DateTime.Parse(stratime); // endday = midTime.Days; // endhours = midTime.Hours; // endminutes = midTime.Minutes; // int i = e.Cell.Row.Index;//h获取选中行序号 // UltraGridRow urg = ultraGrid1.Rows.AsQueryable().Where(a => a.Index == i -1).First();//获取选择行上一行序号 // //if (urg.Index < 0) return; // DateTime time = DateTime.Parse(urg.Cells["LogsEnd"].Value.ToString()).AddDays(endday).AddHours(endhours).AddMinutes(endminutes); // urg.Cells["LogsEnd"].Value = time; // } // } // else // { // MessageUtil.ShowTips("请选择需要修改的数据!"); // e.Cell.Row.Cells["LogsBeg"].Value = row.Cells["LogsBeg"].Value.ToString(); // return; // } //} if (e.Cell.Column.Key.Equals("QualifiedNum")) { if (e.Cell.Row.Cells["QualifiedNum"].Value == null) { e.Cell.Row.Cells["QualifiedNum"].Value = "0"; } else { string actCount = e.Cell.Row.Cells["QualifiedNum"].Value.ToString(); if (!StringUtil.IsInt(actCount) || actCount == "0")//actCount == "" || int.Parse(actCount)==0 { e.Cell.Row.Cells["QualifiedNum"].Value = "0"; } } } if (e.Cell.Column.Key.Equals("QualifiedWt")) { if (e.Cell.Row.Cells["QualifiedWt"].Value == null) { e.Cell.Row.Cells["QualifiedWt"].Value = "0"; } else { string actWt = e.Cell.Row.Cells["QualifiedWt"].Value.ToString(); if (!StringUtil.IsDouble(actWt) || actWt == "0")//actCount == "" || int.Parse(actCount)==0 { e.Cell.Row.Cells["QualifiedWt"].Value = "0"; } } } if (e.Cell.Column.Key.Equals("ScrapNum")) { if (e.Cell.Row.Cells["ScrapNum"].Value == null) { e.Cell.Row.Cells["ScrapNum"].Value = "0"; } else { string scrpNum = e.Cell.Row.Cells["ScrapNum"].Value.ToString(); if (!StringUtil.IsInt(scrpNum) || scrpNum == "0")//actCount == "" || int.Parse(actCount)==0 { e.Cell.Row.Cells["ScrapNum"].Value = "0"; } } } if (e.Cell.Column.Key.Equals("ScrapWt")) { if (e.Cell.Row.Cells["ScrapWt"].Value == null) { e.Cell.Row.Cells["ScrapWt"].Value = "0"; } else { string scrpwt = e.Cell.Row.Cells["ScrapWt"].Value.ToString(); if (!StringUtil.IsDouble(scrpwt) || scrpwt == "0")//actCount == "" || int.Parse(actCount)==0 { e.Cell.Row.Cells["ScrapWt"].Value = "0"; } } } if (e.Cell.Column.Key.Equals("StopType")) { e.Cell.Row.Cells["StopSmall"].Value = ""; e.Cell.Row.Cells["StopReason"].Value = ""; } if (e.Cell.Column.Key.Equals("StopSmall")) { e.Cell.Row.Cells["StopReason"].Value = ""; } } catch (Exception ex) { //MessageUtil.ShowTips("您输入的时间格式不正确!"); //e.Cell.Row.Cells["LogsBeg"].Value = row.Cells["LogsBeg"].Value.ToString(); //e.Cell.Row.Cells["LogsEnd"].Value = row.Cells["LogsEnd"].Value.ToString(); return; } } private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e) { e.RaiseErrorEvent = false; MessageUtil.ShowTips("您输入的时间格式不正确!"); } /// /// 停机原因 /// /// /// private void cmbStopReason_EditorButtonClick(object sender, EditorButtonEventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; string stopSallm = basecodeSamll; if (!row.Cells["StopSmall"].Text.Equals("")) { stopSallm = row.Cells["StopSmall"].Text; } FrmStopSamll fpdc = new FrmStopSamll(basecodeSamll, ob); fpdc.AutoSize = true; fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fpdc.Text = "停机原因"; fpdc.ShowDialog(); if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK) { //获取弹出窗体的属性值 row.Cells["StopReasonm"].Value = fpdc.Basename; //cmbStopReason.Value = fpdc.Basename; basecodeReason = fpdc.Basecode; } } /// /// 停机小类 /// /// /// private void cmbStopSmall_EditorButtonClick(object sender, EditorButtonEventArgs e) { UltraGridRow row=ultraGrid1.ActiveRow; string stoptype = ""; if (!row.Cells["StopType"].Text.Trim().Equals("")) { stoptype = row.Cells["StopType"].Value.ToString(); } FrmStopSamll fpdc = new FrmStopSamll(stoptype, ob); fpdc.AutoSize = true; fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fpdc.Text = "停机小类"; fpdc.ShowDialog(); if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK) { //获取弹出窗体的属性值 row.Cells["StopSmallm"].Value = fpdc.Basename; //cmbStopSmall.Value = fpdc.Basename; basecodeSamll = fpdc.Basecode; } } } }