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.Common; 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 FrmMilControlLog : FrmBase { private string departm = ""; UltraComboEditor ucePline = new UltraComboEditor();//产线名称 private string plineCode; private string[] plineCodes = { }; private string userId = ""; //int stratday;//开始时间日期差,天,时,分 //int strathours; //int stratminutes; //int endday;//结束时间日期差,天,时,分 //int endhours; //int endminutes;toolba int flag = 0;//分析时间错误 int flag1 = 0;//分析相差时间 private string basecodeSamll = "";//停机小类值 private string basecodeReason = "";//停机原因值 public FrmMilControlLog() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmMilControlLog_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); NativeMethodNew na = new NativeMethodNew(this.ob); departm = UserInfo.GetDepartment(); userId = UserInfo.GetUserID(); plineCode = na.GetPCode(departm);//获取 用户 对应的产线 plineCodes = BaseMethod.GetPlineCode(ValidDataPurviewIds, ob); //cmbPline.DataSource = ServerHelper.GetData("com.steering.mes.signature.FrmTubeRollFileManage.queryPlineCode", new object[] { plineCode }, this.ob); //cmbPline.ValueMember = "PLINE_CODE"; //cmbPline.DisplayMember = "PLINE_NAME"; //TubeRoll.SetComboItemHeight(cmbPline); //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); //cmbDate.MaxDate = DateTime.Now; if (!plineCode.Equals("C072")) { this.ultraGrid1.DisplayLayout.Bands[0].Columns["Dept"].Hidden = true; this.ultraGrid2.DisplayLayout.Bands[0].Columns["Dept"].Hidden = true; } cmbDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); 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); DataTable dt2 = TubeRoll.GetComBaseInfo("5011", ob); cmbDept.DataSource = dt2; cmbDept.ValueMember = "BASECODE"; cmbDept.DisplayMember = "BASENAME"; TubeRoll.SetComboItemHeight(cmbDept); } /// /// 重写基类方法 /// /// /// 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": doQuery(); doAnalysis(); break; case "Confirm": doConfirm(); break; case "UpConfirm": UpConfirm(); break; case "OneKeyProces": DoOneKeyProces(); break; case "Statistical": DoStatistical(); break; case "OneKeyUpdate": DoOneKeyUpdate(); break; case "Production": DoProduction(); break; case "Export": GridHelper.ulGridToExcel(ultraGrid1, "轧管调度日志"); break; case "Close": this.Close(); break; } } /// /// 生产记录 /// private void DoProduction() { FrmProductionDetails pro = new FrmProductionDetails(cmbDate.Value.ToString("yyyyMMdd"), plineCode, this.ob); pro.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); pro.Text = "生产详细"; pro.ShowDialog(); } /// /// 查询统计数据 /// private void DoStatistical() { //string date = ""; // string endDate = ""; // 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 // { // MessageUtil.ShowTips("请选择日期!"); // return; // } //doQuery(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowTips("无数据!"); return; } //foreach (UltraGridRow urg in ultraGrid1.Rows) //{ // if (row.Cells["ConfirmFlag"].Text.Equals("未确认")) { MessageUtil.ShowTips("未确认,不允许此操作!"); return; } //} FrmStatistical fsta = new FrmStatistical(plineCode, ob); 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 = ""; date = cmbDate.Value.ToString("yyyyMMdd"); endDate = cmbDate.Value.AddDays(-1).ToString("yyyyMMdd"); //当班数据 List listSource = EntityHelper.GetData ("com.steering.mes.signature.FrmMilControlLog.doQueryPlan", new object[] { date, endDate, this.UserInfo.GetUserOrder(), this.UserInfo.GetUserGroup(), plineCodes, "" }, 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; row.Cells["Dept"].Appearance.BackColor = Color.FromArgb(255, 255, 192); row.Cells["Dept"].Appearance.BackHatchStyle = BackHatchStyle.None; row.Cells["Dept"].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; row.Cells["Dept"].Appearance.BackColor = Color.Transparent; row.Cells["Dept"].Appearance.BackHatchStyle = BackHatchStyle.Default; row.Cells["Dept"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; } } //上一个班数据 string shift = ""; if (this.UserInfo.GetUserOrder().Equals("1")) { shift = "3"; } if (this.UserInfo.GetUserOrder().Equals("2")) { shift = "1"; } if (this.UserInfo.GetUserOrder().Equals("3")) { if (plineCode.Equals("C072")) { shift = "2"; } else { shift = "0"; } date = endDate; } if (this.UserInfo.GetUserOrder().Equals("0")) { shift = "3"; } List listSource2 = EntityHelper.GetData ("com.steering.mes.signature.FrmMilControlLog.doQueryPlan", new object[] { date, endDate, shift, this.UserInfo.GetUserGroup(), plineCodes, "" }, this.ob); MilControlLogEntity2.DataSource = listSource2; GridHelper.RefreshAndAutoSize(ultraGrid2); this.ultraGrid2.DisplayLayout.Bands[0].Columns["LogsBeg"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin; this.ultraGrid2.DisplayLayout.Bands[0].Columns["LogsBeg"].MaskInput = "yyyy-mm-dd hh:mm"; this.ultraGrid2.DisplayLayout.Bands[0].Columns["LogsEnd"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin; this.ultraGrid2.DisplayLayout.Bands[0].Columns["LogsEnd"].MaskInput = "yyyy-mm-dd hh:mm"; foreach (UltraGridRow row in ultraGrid2.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; row.Cells["Dept"].Appearance.BackColor = Color.FromArgb(255, 255, 192); row.Cells["Dept"].Appearance.BackHatchStyle = BackHatchStyle.None; row.Cells["Dept"].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; row.Cells["Dept"].Appearance.BackColor = Color.Transparent; row.Cells["Dept"].Appearance.BackHatchStyle = BackHatchStyle.Default; row.Cells["Dept"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; } } } /// /// 一键处理新增(分析后五分钟以内的时间间隔) /// private void DoOneKeyProces() { ultraGrid1.UpdateData(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowTips("无数据,不允许此操作!"); return; } int minutes = int.Parse(MinTime.Value.ToString()); if (minutes == 0) { MessageUtil.ShowTips("请输入相差时间!"); } ArrayList pram = new ArrayList(); if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; } if (flag == 1 && flag1 == 0) { MessageUtil.ShowTips("分析通过,不允许此操作!"); return; } if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; } int i = 0; try { foreach (UltraGridRow ugr in ultraGrid1.Rows) { //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认")) //{ // MessageUtil.ShowTips("已确认数据,不允许此操作!"); // return; //} if (!ugr.Cells["LogsEnd"].Value.Equals("")) { i += 1; } } 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.JudgeTimeMax(Convert.ToDateTime(loagEnd), Convert.ToDateTime(loagBeg)) <= minutes && TubeRoll.JudgeTimeMax(Convert.ToDateTime(loagEnd), Convert.ToDateTime(loagBeg)) > 0) { ArrayList list = new ArrayList(); list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm")); list.Add(DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); list.Add(this.UserInfo.GetUserName()); list.Add(this.UserInfo.GetUserOrder()); list.Add(this.UserInfo.GetUserGroup()); list.Add(plineCode); pram.Add(list); } } } } if (MessageUtil.ShowYesNoAndQuestion("是否一键新增处理?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog"; ccp.MethodName = "oneKeyProcesMilControlLog"; ccp.ServerParams = new object[] { pram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("一键处理成功!")) { doQuery(); doAnalysis(); } } } catch (Exception ex) { MessageUtil.ShowTips("开始时间或结束时间不能为空!"); } } /// /// 一键修改 /// private void DoOneKeyUpdate() { ultraGrid1.UpdateData(); UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) { MessageUtil.ShowTips("无数据,不允许此操作!"); return; } ArrayList pram = new ArrayList(); if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; } if (flag == 1 && flag1 == 0) { MessageUtil.ShowTips("分析通过,不允许此操作!"); return; } //if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; } int i = 0; try { foreach (UltraGridRow ugr in ultraGrid1.Rows) { //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认")) //{ // MessageUtil.ShowTips("已确认数据,不允许此操作!"); // return; //} if (!ugr.Cells["LogsEnd"].Value.Equals("")) { i += 1; } } 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) { ArrayList list = new ArrayList(); list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm")); list.Add(DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); list.Add(this.UserInfo.GetUserName()); list.Add(this.UserInfo.GetUserOrder()); list.Add(this.UserInfo.GetUserGroup()); list.Add(plineCode); list.Add(ultraGrid1.Rows[j].Cells["ControlId"].Value.ToString()); pram.Add(list); } } } if (ultraGrid1.Rows.Count > 0 && ultraGrid2.Rows.Count > 0) { int a = ultraGrid2.Rows.Count; string logsBeg = ultraGrid1.Rows[0].Cells["LogsBeg"].Value.ToString(); string logsEnd = ultraGrid2.Rows[a - 1].Cells["LogsEnd"].Value.ToString(); string ControlId = ultraGrid1.Rows[0].Cells["ControlId"].Value.ToString(); if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) < 0) { logsEnd = DateTime.Parse(logsEnd).ToString("yyyyMMddHHmm"); ServerHelper.SetData("com.steering.mes.signature.FrmMilControlLog.updateOneDate", new object[] { logsEnd, ControlId }, this.ob); } } if (MessageUtil.ShowYesNoAndQuestion("是否一键修改处理?") == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog"; ccp.MethodName = "oneKeyUpdateMilControlLog"; ccp.ServerParams = new object[] { pram }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("一键处理成功!")) { doQuery(); doAnalysis(); } } } catch (Exception ex) { MessageUtil.ShowTips("开始时间或结束时间不能为空!"); } } /// /// 新增 /// private void doAdd() { ultraGrid1.UpdateData(); ArrayList pram = new ArrayList(); UltraGridRow row = ultraGrid1.ActiveRow; int count = 0; int statrindex = 0;//第一行记录 int endindex = 0;//最后一行记录 int indexEnd = 0;//获取Grid最后一行记录 string statime = "";//新增开始时间 string endtime = "";//新增结束时间 string datetime1 = "";//获取选中第一行结束时间 string datetime2 = "";//获取选中第二行开始时间 if (row != null) { try { foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { //if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认")) //{ // MessageUtil.ShowTips("已确认数据,不允许此操作!"); // return; //} statime = DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).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()).ToString("yyyyMMddHHmm");//新增结束时间 datetime2 = DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm"); } indexEnd = ugr.Index; } //判断选中的两行没有时间差,不许增加 int cnt = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Count(); if (datetime2 == datetime1 && cnt > 1) { MessageUtil.ShowTips("选中的两行没有时间差,不允许增加!"); return; } int index = endindex - statrindex; if (index == 0) { if (statrindex == 0)//获取第一行 { if (indexEnd == 0)//如果只有一条数据 { FrmPopupWindow win = new FrmPopupWindow(); win.AutoSize = true; win.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); win.Text = "提示"; win.ShowDialog(); if (win.DialogResult == System.Windows.Forms.DialogResult.OK) { if (win.Popup == "之前") { pram.Add(DateTime.Parse(row.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); pram.Add(DateTime.Parse(row.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); } else if (win.Popup == "之后") { pram.Add(DateTime.Parse(row.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm")); pram.Add(DateTime.Parse(row.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm")); } else { return; } } } else { foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { pram.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); pram.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); } } } } else if (statrindex == indexEnd)//获取最后一行 { foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { pram.Add(DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm")); pram.Add(DateTime.Parse(ugr.Cells["LogsEnd"].Value.ToString()).ToString("yyyyMMddHHmm")); } } } else { if (count == 0 || count > 2 || count < 2 && index < 2) { MessageUtil.ShowTips("请选择数据且选择相邻两条数据新增!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No) { return; } pram.Add(statime); pram.Add(endtime); } } else { if (count == 0 || count > 2 || count < 2 && index < 2) { MessageUtil.ShowTips("请选择数据且选择相邻两条数据新增!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No) { return; } pram.Add(statime); pram.Add(endtime); } } catch (Exception ex) { MessageUtil.ShowTips("开始时间或结束时间不能为空!"); return; } } else//Grid 为空 { if (MessageUtil.ShowYesNoAndQuestion("当前班次无数据是否新增?") == DialogResult.No) { return; } pram.Add(cmbDate.Value.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmm")); pram.Add(cmbDate.Value.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmm")); //pram.Add(DateTime.Now.ToString("yyyyMMddHHmm")); //pram.Add(DateTime.Now.ToString("yyyyMMddHHmm")); } 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(); doAnalysis(); } } } /// /// 修改 /// 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; if (ugr.Cells["ConfirmFlag"].Text.Equals("已确认")) { MessageUtil.ShowTips("已确认数据,不允许此操作!"); return; } if (ugr.Cells["ProType"].Text.Equals("正常") && ugr.Cells["QualifiedNum"].Text.Equals("0") && ugr.Cells["ScrapNum"].Text.Equals("0")) { MessageUtil.ShowTips("此炉的生产支数和废品支数都为0,请联系【连轧】做【交接班】或【结炉】处理!"); return; } //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 dept = ""; if (!ugr.Cells["Dept"].Text.ToString().Equals("")) { dept = ugr.Cells["Dept"].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); pram.Add(ugr.Cells["Memo"].Value.ToString()); pram.Add(dept); 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 ,"0"}; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("修改成功!")) { doQuery(); doAnalysis(); } } } 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 (userId != "250001" && userId != "1680001" && userId != "2580001" && userId != "4600001" && userId != "5080001") { if (ugr.Cells["ProType"].Text.Equals("正常")) { MessageUtil.ShowTips("请选择停机数据!"); return; } } if (ugr.Cells["ConfirmFlag"].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(); doAnalysis(); } } } /// ///分析 /// private void doAnalysis() { flag = 1; flag1 = 0; int i = 0; try { //当班数据分析 foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (!ugr.Cells["LogsEnd"].Value.Equals("")) { i += 1; } if (!ugr.Cells["LogsEnd"].Value.Equals("")) { 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)) > 0) { 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(); } } //上班数据分析 i = 0; foreach (UltraGridRow ugr in ultraGrid2.Rows) { if (!ugr.Cells["LogsBeg"].Value.Equals("")) { i += 1; } 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; flag = 2;//分析时间错误 } } } for (int j = 0; j < i; j++) { string loagEnd = ultraGrid2.Rows[j].Cells["LogsEnd"].Text.ToString(); string loagBeg = ""; if (j + 1 < i) { loagBeg = ultraGrid2.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)) > 0) { ultraGrid2.Rows[j + 1].Cells["StopType"].Appearance.BackColor = Color.Pink; ultraGrid2.Rows[j + 1].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None; ultraGrid2.Rows[j].Cells["StopType"].Appearance.BackColor = Color.Pink; ultraGrid2.Rows[j].Cells["StopType"].Appearance.BackHatchStyle = BackHatchStyle.None; flag1 = 1;//时间差 } } else if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0) { ultraGrid2.Rows[j].RowSelectorAppearance.BackColor = Color.Red; flag = 2; } TimeSpan timeSpan = DateTime.Parse(ultraGrid2.Rows[j + 1].Cells["LogsBeg"].Value.ToString()) - DateTime.Parse(ultraGrid2.Rows[j].Cells["LogsEnd"].Value.ToString()); ultraGrid2.Rows[j + 1].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString(); } } if (ultraGrid1.Rows.Count > 0 && ultraGrid2.Rows.Count > 0) { string logsBeg = ultraGrid1.Rows[0].Cells["LogsBeg"].Value.ToString(); string logsEnd = ultraGrid2.Rows[i - 1].Cells["LogsEnd"].Value.ToString(); if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) > 0) { if (TubeRoll.JudgeTime(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) > 0) { flag1 = 1;//时间差 } } else if (DateTime.Compare(Convert.ToDateTime(logsBeg), Convert.ToDateTime(logsEnd)) < 0) { flag = 2; } TimeSpan timeSpan = DateTime.Parse(logsBeg) - DateTime.Parse(logsEnd); ultraGrid1.Rows[0].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString(); } } catch (Exception ex) { // MessageUtil.ShowTips(ex.Message); 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() { UltraGridRow uow = ultraGrid1.ActiveRow; if (uow == null) { MessageUtil.ShowTips("无数据!"); return; } ArrayList list = new ArrayList(); string date = DateTime.Now.ToString(); int count = 0; if (flag == 0) { MessageUtil.ShowTips("未分析,不允许此操作!"); return; } if (flag1 == 1) { MessageUtil.ShowTips("有停机记录未新增,不允许此操作!"); return; } if (flag == 2) { MessageUtil.ShowTips("分析时间错误,不允许此操作!"); return; } foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true && ugr.Cells["LogsBeg"].Value.ToString().Equals("")) { MessageUtil.ShowTips("有开始时间为空,不允许此操作!"); return; } if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true && ugr.Cells["LogsEnd"].Value.ToString().Equals("")) { MessageUtil.ShowTips("有结束时间为空,不允许此操作!"); return; } } ultraGrid1.UpdateData(); int seqmin1 = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Count(); if (seqmin1 < 1) { MessageUtil.ShowTips("没有选中要确认的数据!"); return; } if (seqmin1 > 0 && ultraGrid1.Rows.Count > 0) { int seqmin = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Min(); for (int i = 0; i < seqmin; i++) { if (ultraGrid1.Rows[i].Cells["ConfirmFlag"].Value.ToString().Trim().Equals("未确认")) { MessageBox.Show("前面有未确认的数据,请先确认!"); return; } } } //if (flag2 == 1) { MessageUtil.ShowTips("有开始时间为空,不允许此操作!"); return; } //if (flag2 == 2) { MessageUtil.ShowTips("有结束时间为空,不允许此操作!"); return; } //判断上班是否有未确认的数据 if (ultraGrid2.Rows.Count() < 1) { MessageBox.Show("上班有停机记录未新增!"); return; } foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["ConfirmFlag"].Value.ToString().Trim().Equals("未确认")) { MessageBox.Show("上班有未确认的数据,请先确认!"); return; } } string startdate = ""; string endDate = ""; if (chkDate.Checked) { startdate = cmbDate.Value.ToString("yyyyMMdd1800"); } else { MessageUtil.ShowTips("请选择日期!"); return; //startdate = cmbDate.Value.ToString("199901012100"); //endDate = cmbEndDate.Value.ToString("203901012100"); } foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { if (ugr.Cells["ProType"].Text.ToString().Trim().Equals("停机")) { if (ugr.Cells["StopType"].Value.Equals("") || ugr.Cells["StopSmall"].Value.Equals("") || ugr.Cells["StopReason"].Value.Equals("")) { MessageUtil.ShowTips("停机大类,停机小类,停机原因不能为空!"); return; } } string shift = ugr.Cells["ProBc"].Value.ToString(); string group = ugr.Cells["ProBz"].Value.ToString(); if (shift != this.UserInfo.GetUserOrder() || group != this.UserInfo.GetUserGroup()) { MessageUtil.ShowTips("您登录的班次班组与要确认的数据班次班组不符,请重新确认!"); return; } count += 1; ArrayList list1 = new ArrayList(); list1.Add(ugr.Cells["ControlId"].Text.ToString()); list1.Add(this.UserInfo.GetUserName()); list1.Add(date); list1.Add(this.UserInfo.GetUserOrder()); list1.Add(this.UserInfo.GetUserGroup()); list1.Add(plineCode); list1.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); list1.Add(startdate); list1.Add(endDate); list1.Add(ugr.Cells["JudgeStoveNo"].Text.ToString()); list.Add(list1); } } if (count == 0) { MessageUtil.ShowTips("请选中要确认的数据!"); return; } string intCount = "0";//是否选择确认 if (MessageUtil.ShowYesNoAndQuestion("是否只确认选中行数据?") == DialogResult.No) { intCount = "0"; if (count == 2) { MessageUtil.ShowTips("请选择一条数据!"); return; } } else { intCount = "1"; } //if (MessageUtil.ShowYesNoAndQuestion("是否确认?") == DialogResult.No) //{ // return; //} UltraGridRow ugr1 = ultraGrid1.ActiveRow; if (ugr1 != null) { string logbeg = ugr1.Cells["LogsBeg"].Value.ToString(); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmMilControlLog"; ccp.MethodName = "confirmMilControlLog"; ccp.ServerParams = new object[] { list, intCount }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("确认成功!")) { doQuery(); doAnalysis(); } } } /// ///取消确认 /// private void UpConfirm() { UltraGridRow uow = ultraGrid1.ActiveRow; if (uow == null) { MessageUtil.ShowTips("无数据!"); return; } ultraGrid1.UpdateData(); int seqmax1 = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Count(); if (seqmax1 < 1) { MessageUtil.ShowTips("没有选中要确认的数据!"); return; } if (seqmax1 > 0 && ultraGrid1.Rows.Count() > 0) { int seqmax = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").Select(a => a.Index).Max(); for (int i = seqmax + 1; i < ultraGrid1.Rows.Count(); i++) { if (ultraGrid1.Rows[i].Cells["ConfirmFlag"].Value.ToString().Trim().Equals("已确认")) { MessageBox.Show("后面有已确认的数据,请先取消确认!"); return; } } } ArrayList list = new ArrayList(); string date = DateTime.Now.ToString(); int count = 0; string startdate = ""; string endDate = ""; if (chkDate.Checked) { startdate = cmbDate.Value.ToString("yyyyMMdd1800"); } else { MessageUtil.ShowTips("请选择日期!"); return; //startdate = cmbDate.Value.ToString("199901012100"); //endDate = cmbEndDate.Value.ToString("203901012100"); } foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true) { count += 1; ArrayList list1 = new ArrayList(); list1.Add(ugr.Cells["ControlId"].Text.ToString()); list1.Add(this.UserInfo.GetUserOrder()); list1.Add(this.UserInfo.GetUserGroup()); list1.Add(plineCode); list1.Add(DateTime.Parse(ugr.Cells["LogsBeg"].Value.ToString()).ToString("yyyyMMddHHmm")); list1.Add(startdate); list1.Add(endDate); list1.Add(ugr.Cells["JudgeStoveNo"].Text.ToString()); list.Add(list1); } } if (count == 0) { MessageUtil.ShowTips("请选中要取消确认的数据!"); return; } string intCount = "0";//是否选择取消确认 if (MessageUtil.ShowYesNoAndQuestion("是否只取消确认选中行数据?") == DialogResult.No) { intCount = "0"; if (count == 2) { MessageUtil.ShowTips("请选择一条数据!"); return; } } else { intCount = "1"; } //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, intCount }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("取消确认成功!")) { doQuery(); doAnalysis(); } } } private void chkDate_CheckedChanged(object sender, EventArgs e) { if (chkDate.Checked) { cmbDate.Enabled = true; } else { cmbDate.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; } } /// /// 班次中文 /// /// /// private string changeShift(string dtShift) { switch (dtShift) { case "1": dtShift = "早班"; break; case "2": dtShift = "中班"; break; case "3": dtShift = "夜班"; break; } return dtShift; } /// /// 班组中文 /// /// /// private string changeGroup(string dtGroup) { switch (dtGroup) { case "1": dtGroup = "甲班"; break; case "2": dtGroup = "乙班"; break; case "3": dtGroup = "丙班"; break; case "4": dtGroup = "丁班"; break; } return dtGroup; } } }