private void DealProcessComplete(string ProcessCode, string CompleteFlag, string RMES_ID) { //点击按钮是执行事件 string complete_flag = ""; RMESEventArgs args = new RMESEventArgs(); bool completed = false; int selected_row = -1; Color rowColor = Color.Gray; string gird_rmes_id; for (int i = 0; i < gridProcessList.Rows.Count; i++) { if (gridProcessList.Rows[i].Cells["colRmesID"].Value != null) { gird_rmes_id = gridProcessList.Rows[i].Cells["colRmesID"].Value.ToString(); if (gird_rmes_id == RMES_ID) { selected_row = i; break; } } } if (selected_row < 0) { return; } complete_flag = gridProcessList.Rows[selected_row].Cells["colCompleteFlag"].Value.ToString(); if (gridProcessList.Rows[selected_row].Cells["colProcessCode"].Value == null) { MessageBox.Show("只能对工序进行操作"); return; } if (selected_row > 0 && CompleteFlag == "0")//工序执行开始 { //complete_flag = gridProcessList.Rows[selected_row - 1].Cells["colCompleteFlag"].Value.ToString(); //obj_process_code = gridProcessList.Rows[selected_row - 1].Cells["colProcessCode"].Value; //if (obj_process_code != null && complete_flag == "R") //complete_flag != "Y" //{ // MessageBox.Show("前一序未完成!"); // return; //} //caoly 20140425 改成只要有未完成工序,就不能开始新的工序;可以挑着工序开始 List <SNProcessTempEntity> temp = DB.GetInstance().Fetch <SNProcessTempEntity>("where sn=@0 and complete_flag='R'", sn); if (temp.Count > 0) { MessageBox.Show("有未完成工序,请先完成该工序!"); return; } } else if (CompleteFlag == "1" || CompleteFlag == "2") { complete_flag = gridProcessList.Rows[selected_row].Cells["colCompleteFlag"].Value.ToString(); if (complete_flag != "R") { MessageBox.Show("此工序尚未开始!"); return; } } else if (CompleteFlag == "3") { if (complete_flag != "P") { MessageBox.Show("此工序未进行暂停操作!"); return; } } //处理工序状态操作 gird_rmes_id = gridProcessList.Rows[selected_row].Cells["colRmesID"].Value.ToString(); SNProcessTempFactory.HandleProcessComplete(gird_rmes_id, LoginInfo.StationInfo.RMES_ID, CompleteFlag); //处理按钮标题显示 gridProcessList.Rows[selected_row].Cells["colCompleteFlag"].Value = CompleteFlag == "0" ? "R" : "Y"; if (CompleteFlag == "0" || CompleteFlag == "3") { gridProcessList.Rows[selected_row].Cells["colCompleteFlag"].Value = "R"; } else if (CompleteFlag == "1") { gridProcessList.Rows[selected_row].Cells["colCompleteFlag"].Value = "Y"; } else if (CompleteFlag == "2") { gridProcessList.Rows[selected_row].Cells["colCompleteFlag"].Value = "P"; DateTime dt1 = DateTime.Parse(gridProcessList.Rows[selected_row].Cells["colStartTime"].Value.ToString()); DateTime dt2 = System.DateTime.Now; string span_dt = (dt2 - dt1).TotalMinutes.ToString("00.00"); gridProcessList.Rows[selected_row].Cells["colWorkTime"].Value = span_dt; gridProcessList.Rows[selected_row].Cells["colEndTime"].Value = dt2; } DataGridViewButtonCell vCell = gridProcessList.Rows[selected_row].Cells["colCmdStart"] as DataGridViewButtonCell; DataGridViewButtonCell cell_pause = gridProcessList.Rows[selected_row].Cells["colCmdPause"] as DataGridViewButtonCell; //处理行显示颜色 if (CompleteFlag == "0") { rowColor = Color.Yellow; } else if (CompleteFlag == "1") { rowColor = Color.FromArgb(255, 0, 255, 0); } else if (CompleteFlag == "2") { rowColor = Color.Blue; } for (int j = 0; j < gridProcessList.Columns.Count; j++) { gridProcessList.Rows[selected_row].Cells[j].Style.BackColor = rowColor; } if (CompleteFlag == "0") { vCell.Value = "完成"; } else if (CompleteFlag == "1") { vCell.Value = "结束"; } else if (CompleteFlag == "2") { cell_pause.Value = "继续"; } else if (CompleteFlag == "3") { cell_pause.Value = "暂停"; } if (CompleteFlag == "0") { gridProcessList.Rows[selected_row].Cells["colStartTime"].Value = System.DateTime.Now.ToString(); } else { gridProcessList.Rows[selected_row].Cells["colEndTime"].Value = System.DateTime.Now.ToString(); } completed = selected_row + 1 == gridProcessList.Rows.Count - 1 ? true : false; if (completed) { args.MessageHead = "CCP"; args.MessageBody = "Rmes.WinForm.ctrlProcessShow^B"; UiFactory.CallDataChanged(this, args); } }
private void DealProcessComplete(string ProcessCode, string CompleteFlag) { //点击按钮是执行事件 string complete_flag = ""; RMESEventArgs args = new RMESEventArgs(); bool completed = false; int selected_row = -1; string grid_process_code, gird_rmes_id; object obj_process_code; for (int i = 0; i < gridProcessList.Rows.Count; i++) { if (gridProcessList.Rows[i].Cells["colProcessCode"].Value != null) { grid_process_code = gridProcessList.Rows[i].Cells["colProcessCode"].Value.ToString(); if (grid_process_code == ProcessCode) { selected_row = i; break; } } } if (selected_row < 0) { return; } if (gridProcessList.Rows[selected_row].Cells["colProcessCode"].Value == null) { MessageBox.Show("只能对工序进行操作"); return; } if (selected_row > 0 && CompleteFlag == "0") { //complete_flag = gridProcessList.Rows[selected_row - 1].Cells["colCompleteFlag"].Value.ToString(); //obj_process_code = gridProcessList.Rows[selected_row - 1].Cells["colProcessCode"].Value; //if (obj_process_code != null && complete_flag == "R") //complete_flag != "Y" //{ // MessageBox.Show("前一序未完成!"); // return; //} //caoly 20140425 改成只要有未完成工序,就不能开始新的工序;可以挑着工序开始 List <SNProcessTempEntity> temp = DB.GetInstance().Fetch <SNProcessTempEntity>("where sn=@0 and complete_flag='R'", sn); if (temp.Count > 0) { MessageBox.Show("有未完成工序,请先完成该工序!"); return; } } else if (CompleteFlag == "1") { complete_flag = gridProcessList.Rows[selected_row].Cells["colCompleteFlag"].Value.ToString(); if (complete_flag != "R") { MessageBox.Show("此工序尚未开始!"); return; } } gird_rmes_id = gridProcessList.Rows[selected_row].Cells["colRmesID"].Value.ToString(); SNProcessTempFactory.HandleProcessComplete(gird_rmes_id, LoginInfo.StationInfo.RMES_ID, CompleteFlag); gridProcessList.Rows[selected_row].Cells["colCompleteFlag"].Value = CompleteFlag == "0" ? "R" : "Y"; DataGridViewButtonCell vCell = gridProcessList.Rows[selected_row].Cells["colCmdStart"] as DataGridViewButtonCell; for (int j = 0; j < gridProcessList.Columns.Count; j++) { gridProcessList.Rows[selected_row].Cells[j].Style.BackColor = CompleteFlag == "0" ? Color.Yellow : Color.FromArgb(255, 0, 255, 0); } vCell.Value = CompleteFlag == "0" ? "完成" : "结束"; if (CompleteFlag == "0") { gridProcessList.Rows[selected_row].Cells["colStartTime"].Value = System.DateTime.Now.ToString(); } else { gridProcessList.Rows[selected_row].Cells["colEndTime"].Value = System.DateTime.Now.ToString(); } completed = selected_row + 1 == gridProcessList.Rows.Count - 1 ? true : false; if (completed) { args.MessageHead = "CCP"; args.MessageBody = "Rmes.WinForm.ctrlProcessShow^B"; UiFactory.CallDataChanged(this, args); } }