using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.Mcp.Control;
using Core.StlMes.Client.Mcp.Control.Base;
using Core.StlMes.Client.Mcp.VRP.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.Mcp.VRP.Report
{
public partial class FrmVrpControlLog : FrmBase
{
private string departm = "";
UltraComboEditor ucePline = new UltraComboEditor();//产线名称
private string plineCode;
int flag = 0;//分析时间错误
int flag1 = 0;//分析相差时间
public FrmVrpControlLog()
{
InitializeComponent();
}
private void FrmMilControlLog_Load(object sender, EventArgs e)
{
departm = UserInfo.GetDepartment();
plineCode = YdmBaseClass.GetPCode(departm, this.ob);//获取 用户 对应的产线
cmbDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
//TubeRoll.setUltraGridColumnInput(ultraGrid1, new string[] { "QUALIFIED_NUM", "SCRAP_NUM" });//支数
//TubeRoll.setUltraGridColumnMaxInput(ultraGrid1, new string[] { "QUALIFIED_WT", "SCRAP_WT" });//重量
//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);
splitContainer1.SplitterDistance = splitContainer1.Size.Height/2;
}
///
/// 重写基类方法
///
///
///
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()
{
UltraGridRow row = ultraGrid1.ActiveRow;
if (row == null) { 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");
//当班数据
DataTable dt=ServerHelper.GetData
("com.steering.mes.mcp.Report.FrmVrpControlLog.doQueryPlan", new object[] { date, endDate, this.UserInfo.GetUserOrder(), this.UserInfo.GetUserGroup(), plineCode, "" }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
this.ultraGrid1.DisplayLayout.Bands[0].Columns["LOGS_BEG"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["LOGS_BEG"].MaskInput = "yyyy-mm-dd hh:mm";
this.ultraGrid1.DisplayLayout.Bands[0].Columns["LOGS_END"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["LOGS_END"].MaskInput = "yyyy-mm-dd hh:mm";
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (row.Cells["PRO_TYPE"].Text.ToString().Trim().Equals("停机"))
{
row.Cells["STOP_TYPE"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
row.Cells["STOP_TYPE"].Appearance.BackHatchStyle = BackHatchStyle.None;
row.Cells["STOP_TYPE"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
row.Cells["STOP_REASON"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
row.Cells["STOP_REASON"].Appearance.BackHatchStyle = BackHatchStyle.None;
row.Cells["STOP_REASON"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
row.Cells["STOP_SMALL"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
row.Cells["STOP_SMALL"].Appearance.BackHatchStyle = BackHatchStyle.None;
row.Cells["STOP_SMALL"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
}
else
{
row.Cells["STOP_TYPE"].Appearance.BackColor = Color.Transparent;
row.Cells["STOP_TYPE"].Appearance.BackHatchStyle = BackHatchStyle.Default;
row.Cells["STOP_TYPE"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
row.Cells["STOP_REASON"].Appearance.BackColor = Color.Transparent;
row.Cells["STOP_REASON"].Appearance.BackHatchStyle = BackHatchStyle.Default;
row.Cells["STOP_REASON"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
row.Cells["STOP_SMALL"].Appearance.BackColor = Color.Transparent;
row.Cells["STOP_SMALL"].Appearance.BackHatchStyle = BackHatchStyle.Default;
row.Cells["STOP_SMALL"].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"))
{
shift = "2";
date = endDate;
}
DataTable dt2 = ServerHelper.GetData
("com.steering.mes.mcp.Report.FrmVrpControlLog.doQueryPlan", new object[] { date, endDate, shift, this.UserInfo.GetUserGroup(), plineCode, "" }, this.ob);
GridHelper.CopyDataToDatatable(ref dt2, ref dataTable2, true);
this.ultraGrid2.DisplayLayout.Bands[0].Columns["LOGS_BEG"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
this.ultraGrid2.DisplayLayout.Bands[0].Columns["LOGS_BEG"].MaskInput = "yyyy-mm-dd hh:mm";
this.ultraGrid2.DisplayLayout.Bands[0].Columns["LOGS_END"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTimeWithSpin;
this.ultraGrid2.DisplayLayout.Bands[0].Columns["LOGS_END"].MaskInput = "yyyy-mm-dd hh:mm";
foreach (UltraGridRow row in ultraGrid2.Rows)
{
if (row.Cells["PRO_TYPE"].Text.ToString().Trim().Equals("停机"))
{
row.Cells["STOP_TYPE"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
row.Cells["STOP_TYPE"].Appearance.BackHatchStyle = BackHatchStyle.None;
row.Cells["STOP_TYPE"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
row.Cells["STOP_REASON"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
row.Cells["STOP_REASON"].Appearance.BackHatchStyle = BackHatchStyle.None;
row.Cells["STOP_REASON"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
row.Cells["STOP_SMALL"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
row.Cells["STOP_SMALL"].Appearance.BackHatchStyle = BackHatchStyle.None;
row.Cells["STOP_SMALL"].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
}
else
{
row.Cells["STOP_TYPE"].Appearance.BackColor = Color.Transparent;
row.Cells["STOP_TYPE"].Appearance.BackHatchStyle = BackHatchStyle.Default;
row.Cells["STOP_TYPE"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
row.Cells["STOP_REASON"].Appearance.BackColor = Color.Transparent;
row.Cells["STOP_REASON"].Appearance.BackHatchStyle = BackHatchStyle.Default;
row.Cells["STOP_REASON"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
row.Cells["STOP_SMALL"].Appearance.BackColor = Color.Transparent;
row.Cells["STOP_SMALL"].Appearance.BackHatchStyle = BackHatchStyle.Default;
row.Cells["STOP_SMALL"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
}
}
doAnalysis();
}
///
/// 一键处理新增(分析后五分钟以内的时间间隔)
///
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["CONFIRM_FLAG"].Text.Equals("已确认"))
//{
// MessageUtil.ShowTips("已确认数据,不允许此操作!");
// return;
//}
if (!ugr.Cells["LOGS_END"].Value.Equals(""))
{
i += 1;
}
}
for (int j = 0; j < i; j++)
{
string loagEnd = ultraGrid1.Rows[j].Cells["LOGS_END"].Text.ToString();
string loagBeg = "";
if (j + 1 < i)
{
loagBeg = ultraGrid1.Rows[j + 1].Cells["LOGS_BEG"].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["LOGS_END"].Value.ToString()).ToString("yyyyMMddHHmm"));
list.Add(DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LOGS_BEG"].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.mcp.Report.FrmVrpControlLog";
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["CONFIRM_FLAG"].Text.Equals("已确认"))
//{
// MessageUtil.ShowTips("已确认数据,不允许此操作!");
// return;
//}
if (!ugr.Cells["LOGS_END"].Value.Equals(""))
{
i += 1;
}
}
for (int j = 0; j < i; j++)
{
string loagEnd = ultraGrid1.Rows[j].Cells["LOGS_END"].Text.ToString();
string loagBeg = "";
if (j + 1 < i)
{
loagBeg = ultraGrid1.Rows[j + 1].Cells["LOGS_BEG"].Text.ToString();
if (DateTime.Compare(Convert.ToDateTime(loagBeg), Convert.ToDateTime(loagEnd)) < 0)
{
ArrayList list = new ArrayList();
list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LOGS_BEG"].Value.ToString()).ToString("yyyyMMddHHmm"));
list.Add(DateTime.Parse(ultraGrid1.Rows[j].Cells["LOGS_END"].Value.ToString()).ToString("yyyyMMddHHmm"));
list.Add(DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LOGS_BEG"].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["CONTROL_ID"].Value.ToString());
pram.Add(list);
}
}
}
if (ultraGrid1.Rows.Count > 0 && ultraGrid2.Rows.Count > 0)
{
int a = ultraGrid2.Rows.Count;
string LOGS_BEG = ultraGrid1.Rows[0].Cells["LOGS_BEG"].Value.ToString();
string LOGS_END = ultraGrid2.Rows[a - 1].Cells["LOGS_END"].Value.ToString();
string CONTROL_ID = ultraGrid1.Rows[0].Cells["CONTROL_ID"].Value.ToString();
if (DateTime.Compare(Convert.ToDateTime(LOGS_BEG), Convert.ToDateTime(LOGS_END)) < 0)
{
LOGS_END = DateTime.Parse(LOGS_END).ToString("yyyyMMddHHmm");
ServerHelper.SetData("com.steering.mes.mcp.Report.FrmVrpControlLog.updateOneDate", new object[] { LOGS_END, CONTROL_ID }, this.ob);
}
}
if (MessageUtil.ShowYesNoAndQuestion("是否一键修改处理?") == DialogResult.No)
{
return;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.mcp.Report.FrmVrpControlLog";
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["CONFIRM_FLAG"].Text.Equals("已确认"))
//{
// MessageUtil.ShowTips("已确认数据,不允许此操作!");
// return;
//}
statime = DateTime.Parse(ugr.Cells["LOGS_END"].Value.ToString()).ToString("yyyyMMddHHmm");//新增开始时间
datetime1 = DateTime.Parse(ugr.Cells["LOGS_END"].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["LOGS_BEG"].Value.ToString()).ToString("yyyyMMddHHmm");//新增结束时间
datetime2 = DateTime.Parse(ugr.Cells["LOGS_BEG"].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["LOGS_BEG"].Value.ToString()).ToString("yyyyMMddHHmm"));
pram.Add(DateTime.Parse(row.Cells["LOGS_BEG"].Value.ToString()).ToString("yyyyMMddHHmm"));
}
else if (win.Popup == "之后")
{
pram.Add(DateTime.Parse(row.Cells["LOGS_END"].Value.ToString()).ToString("yyyyMMddHHmm"));
pram.Add(DateTime.Parse(row.Cells["LOGS_END"].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["LOGS_BEG"].Value.ToString()).ToString("yyyyMMddHHmm"));
pram.Add(DateTime.Parse(ugr.Cells["LOGS_BEG"].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["LOGS_END"].Value.ToString()).ToString("yyyyMMddHHmm"));
pram.Add(DateTime.Parse(ugr.Cells["LOGS_END"].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.mcp.Report.FrmVrpControlLog";
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;//最后一行记录
ArrayList list = new ArrayList();
try
{
foreach (UltraGridRow ugr in ultraGrid1.Rows)
{
if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
{
count += 1;
if (ugr.Cells["CONFIRM_FLAG"].Text.Equals("已确认"))
{
MessageUtil.ShowTips("已确认数据,不允许此操作!");
return;
}
if (ugr.Cells["PRO_TYPE"].Text.Equals("正常") && ugr.Cells["QUALIFIED_NUM"].Text.Equals("0") && ugr.Cells["SCRAP_NUM"].Text.Equals("0"))
{
MessageUtil.ShowTips("此炉的合格支数和废品支数都为0,请联系镦拔扩对应产线处理!");
return;
}
string STOP_TYPE = "";
if (!ugr.Cells["STOP_TYPE"].Text.ToString().Equals(""))
{
STOP_TYPE = ugr.Cells["STOP_TYPE"].Value.ToString();
}
string STOP_REASON = "";
if (!ugr.Cells["STOP_REASON_CODE"].Value.ToString().Equals(""))
{
STOP_REASON = ugr.Cells["STOP_REASON_CODE"].Value.ToString();// ugr.Cells["STOP_REASON"].Value.ToString();
}
string STOP_SMALL = "";
if (!ugr.Cells["STOP_SMALL_CODE"].Value.ToString().Equals(""))
{
STOP_SMALL = ugr.Cells["STOP_SMALL_CODE"].Value.ToString();// ugr.Cells["STOP_SMALL"].Value.ToString();
}
string bc = "";
if (!ugr.Cells["PRO_BC"].Text.ToString().Equals(""))
{
bc = ugr.Cells["PRO_BC"].Value.ToString();
}
string bz = "";
if (!ugr.Cells["PRO_BZ"].Text.ToString().Equals(""))
{
bz = ugr.Cells["PRO_BZ"].Value.ToString();
}
if (Convert.ToDateTime(ugr.Cells["LOGS_BEG"].Value.ToString()) > Convert.ToDateTime(ugr.Cells["LOGS_END"].Value.ToString()))
{
MessageUtil.ShowTips("开始时间不能大于等于结束时间!");
return;
}
ArrayList pram = new ArrayList();
pram.Add(DateTime.Parse(ugr.Cells["LOGS_BEG"].Value.ToString()).ToString("yyyy-MM-dd HH:mm"));
pram.Add(DateTime.Parse(ugr.Cells["LOGS_END"].Value.ToString()).ToString("yyyy-MM-dd HH:mm"));
pram.Add(plineCode);
pram.Add(STOP_TYPE);
pram.Add(STOP_REASON);
pram.Add(ugr.Cells["QUALIFIED_NUM"].Value.ToString());
pram.Add(ugr.Cells["QUALIFIED_WT"].Value.ToString());
pram.Add(ugr.Cells["SCRAP_NUM"].Value.ToString());
pram.Add(ugr.Cells["SCRAP_WT"].Value.ToString());
pram.Add(bc);
pram.Add(bz);
pram.Add(ugr.Cells["CONTROL_ID"].Value.ToString());
pram.Add(STOP_SMALL);
pram.Add(ugr.Cells["MEMO"].Value.ToString());
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.mcp.Report.FrmVrpControlLog";
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();
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 (ugr.Cells["PRO_TYPE"].Text.Equals("正常"))
{
MessageUtil.ShowTips("请选择停机数据!");
return;
}
if (ugr.Cells["CONFIRM_FLAG"].Text.Equals("已确认"))
{
MessageUtil.ShowTips("已确认数据,不允许此操作!");
return;
}
ArrayList pram = new ArrayList();
pram.Add(ugr.Cells["CONTROL_ID"].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.mcp.Report.FrmVrpControlLog";
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["LOGS_END"].Value.Equals(""))
{ i += 1; }
if (!ugr.Cells["LOGS_END"].Value.Equals(""))
{
if (Convert.ToDateTime(ugr.Cells["LOGS_BEG"].Value.ToString()) > Convert.ToDateTime(ugr.Cells["LOGS_END"].Value.ToString()))
{
ugr.RowSelectorAppearance.BackColor = Color.Red;
//ugr.Cells["LOGS_BEG"].Appearance.BackHatchStyle = BackHatchStyle.None;
//ugr.Cells["LOGS_END"].Appearance.BackColor = Color.Red;
//ugr.Cells["LOGS_END"].Appearance.BackHatchStyle = BackHatchStyle.None;
flag = 2;//分析时间错误
}
}
}
for (int j = 0; j < i; j++)
{
string loagEnd = ultraGrid1.Rows[j].Cells["LOGS_END"].Text.ToString();
string loagBeg = "";
if (j + 1 < i)
{
loagBeg = ultraGrid1.Rows[j + 1].Cells["LOGS_BEG"].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["STOP_TYPE"].Appearance.BackColor = Color.Pink;
ultraGrid1.Rows[j + 1].Cells["STOP_TYPE"].Appearance.BackHatchStyle = BackHatchStyle.None;
ultraGrid1.Rows[j].Cells["STOP_TYPE"].Appearance.BackColor = Color.Pink;
ultraGrid1.Rows[j].Cells["STOP_TYPE"].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["STOP_TYPE"].Appearance.BackColor = Color.LightGray;
// ultraGrid1.Rows[j + 1].Cells["STOP_TYPE"].Appearance.BackHatchStyle = BackHatchStyle.None;
// ultraGrid1.Rows[j].Cells["STOP_TYPE"].Appearance.BackColor = Color.LightGray;
// ultraGrid1.Rows[j].Cells["STOP_TYPE"].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["LOGS_BEG"].Appearance.BackColor = Color.Orange;
//ultraGrid1.Rows[j + 1].Cells["LOGS_BEG"].Appearance.BackHatchStyle = BackHatchStyle.None;
//ultraGrid1.Rows[j].Cells["LOGS_BEG"].Appearance.BackColor = Color.Orange;
//ultraGrid1.Rows[j].Cells["LOGS_BEG"].Appearance.BackHatchStyle = BackHatchStyle.None;
flag = 2;
}
TimeSpan timeSpan = DateTime.Parse(ultraGrid1.Rows[j + 1].Cells["LOGS_BEG"].Value.ToString()) -
DateTime.Parse(ultraGrid1.Rows[j].Cells["LOGS_END"].Value.ToString());
ultraGrid1.Rows[j + 1].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString();
}
}
//上班数据分析
i = 0;
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
if (!ugr.Cells["LOGS_BEG"].Value.Equals(""))
{ i += 1; }
if (!ugr.Cells["LOGS_END"].Value.Equals(""))
{
//i += 1;
if (Convert.ToDateTime(ugr.Cells["LOGS_BEG"].Value.ToString()) > Convert.ToDateTime(ugr.Cells["LOGS_END"].Value.ToString()))
{
ugr.RowSelectorAppearance.BackColor = Color.Red;
flag = 2;//分析时间错误
}
}
}
for (int j = 0; j < i; j++)
{
string loagEnd = ultraGrid2.Rows[j].Cells["LOGS_END"].Text.ToString();
string loagBeg = "";
if (j + 1 < i)
{
loagBeg = ultraGrid2.Rows[j + 1].Cells["LOGS_BEG"].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["STOP_TYPE"].Appearance.BackColor = Color.Pink;
ultraGrid2.Rows[j + 1].Cells["STOP_TYPE"].Appearance.BackHatchStyle = BackHatchStyle.None;
ultraGrid2.Rows[j].Cells["STOP_TYPE"].Appearance.BackColor = Color.Pink;
ultraGrid2.Rows[j].Cells["STOP_TYPE"].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["LOGS_BEG"].Value.ToString()) -
DateTime.Parse(ultraGrid2.Rows[j].Cells["LOGS_END"].Value.ToString());
ultraGrid2.Rows[j + 1].Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString();
}
}
if (ultraGrid1.Rows.Count > 0 && ultraGrid2.Rows.Count > 0)
{
string LOGS_BEG = ultraGrid1.Rows[0].Cells["LOGS_BEG"].Value.ToString();
string LOGS_END = ultraGrid2.Rows[i - 1].Cells["LOGS_END"].Value.ToString();
if (DateTime.Compare(Convert.ToDateTime(LOGS_BEG), Convert.ToDateTime(LOGS_END)) > 0)
{
if (TubeRoll.JudgeTime(Convert.ToDateTime(LOGS_BEG), Convert.ToDateTime(LOGS_END)) > 0)
{
flag1 = 1;//时间差
}
}
else if (DateTime.Compare(Convert.ToDateTime(LOGS_BEG), Convert.ToDateTime(LOGS_END)) < 0)
{
flag = 2;
}
TimeSpan timeSpan = DateTime.Parse(LOGS_BEG) - DateTime.Parse(LOGS_END);
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["LOGS_BEG"].Value.ToString().Equals(""))
{
MessageUtil.ShowTips("有开始时间为空,不允许此操作!"); return;
}
if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true && ugr.Cells["LOGS_END"].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["CONFIRM_FLAG"].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["CONFIRM_FLAG"].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["PRO_TYPE"].Text.ToString().Trim().Equals("停机"))
{
if (ugr.Cells["STOP_TYPE"].Value.Equals("") || ugr.Cells["STOP_SMALL"].Value.Equals("") || ugr.Cells["STOP_REASON"].Value.Equals(""))
{
MessageUtil.ShowTips("停机大类,停机小类,停机原因不能为空!");
return;
}
}
string shift = ugr.Cells["PRO_BC"].Value.ToString();
string group = ugr.Cells["PRO_BZ"].Value.ToString();
if (shift != this.UserInfo.GetUserOrder() || group != this.UserInfo.GetUserGroup())
{
MessageUtil.ShowTips("您登录的班次班组与要确认的数据班次班组不符,请重新确认!");
return;
}
count += 1;
ArrayList list1 = new ArrayList();
list1.Add(ugr.Cells["CONTROL_ID"].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["LOGS_BEG"].Value.ToString()).ToString("yyyyMMddHHmm"));
list1.Add(startdate);
list1.Add(endDate);
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["LOGS_BEG"].Value.ToString();
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.mcp.Report.FrmVrpControlLog";
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["CONFIRM_FLAG"].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["CONTROL_ID"].Text.ToString());
list1.Add(this.UserInfo.GetUserOrder());
list1.Add(this.UserInfo.GetUserGroup());
list1.Add(plineCode);
list1.Add(DateTime.Parse(ugr.Cells["LOGS_BEG"].Value.ToString()).ToString("yyyyMMddHHmm"));
list1.Add(startdate);
list1.Add(endDate);
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.mcp.Report.FrmVrpControlLog";
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; }
}
///
/// Grid字段修改触发事件
///
///
///
private void ultraGrid1_CellChange(object sender, CellEventArgs e)
{
UltraGridRow row = ultraGrid1.ActiveRow;
try
{
ultraGrid1.UpdateData();
if (e.Cell.Column.Key.Equals("QUALIFIED_NUM"))
{
if (e.Cell.Row.Cells["QUALIFIED_NUM"].Value == null)
{
e.Cell.Row.Cells["QUALIFIED_NUM"].Value = "0";
}
else
{
string actCount = e.Cell.Row.Cells["QUALIFIED_NUM"].Value.ToString();
if (!StringUtil.IsInt(actCount) || actCount == "0")//actCount == "" || int.Parse(actCount)==0
{
e.Cell.Row.Cells["QUALIFIED_NUM"].Value = "0";
}
}
}
if (e.Cell.Column.Key.Equals("QUALIFIED_WT"))
{
if (e.Cell.Row.Cells["QUALIFIED_WT"].Value == null)
{
e.Cell.Row.Cells["QUALIFIED_WT"].Value = "0";
}
else
{
string actWt = e.Cell.Row.Cells["QUALIFIED_WT"].Value.ToString();
if (!StringUtil.IsDouble(actWt) || actWt == "0")//actCount == "" || int.Parse(actCount)==0
{
e.Cell.Row.Cells["QUALIFIED_WT"].Value = "0";
}
}
}
if (e.Cell.Column.Key.Equals("SCRAP_NUM"))
{
if (e.Cell.Row.Cells["SCRAP_NUM"].Value == null)
{
e.Cell.Row.Cells["SCRAP_NUM"].Value = "0";
}
else
{
string scrpNum = e.Cell.Row.Cells["SCRAP_NUM"].Value.ToString();
if (!StringUtil.IsInt(scrpNum) || scrpNum == "0")//actCount == "" || int.Parse(actCount)==0
{
e.Cell.Row.Cells["SCRAP_NUM"].Value = "0";
}
}
}
if (e.Cell.Column.Key.Equals("SCRAP_WT"))
{
if (e.Cell.Row.Cells["SCRAP_WT"].Value == null)
{
e.Cell.Row.Cells["SCRAP_WT"].Value = "0";
}
else
{
string scrpwt = e.Cell.Row.Cells["SCRAP_WT"].Value.ToString();
if (!StringUtil.IsDouble(scrpwt) || scrpwt == "0")//actCount == "" || int.Parse(actCount)==0
{
e.Cell.Row.Cells["SCRAP_WT"].Value = "0";
}
}
}
if (e.Cell.Column.Key.Equals("STOP_TYPE"))
{
e.Cell.Row.Cells["STOP_SMALL"].Value = "";
e.Cell.Row.Cells["STOP_REASON"].Value = "";
}
if (e.Cell.Column.Key.Equals("STOP_SMALL"))
{
e.Cell.Row.Cells["STOP_REASON"].Value = "";
}
}
catch (Exception ex)
{
return;
}
}
private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e)
{
e.RaiseErrorEvent = false;
MessageUtil.ShowTips("您输入的时间格式不正确!");
}
///
/// 停机原因
///
///
///
private void cmbSTOP_REASON_EditorButtonClick(object sender, EditorButtonEventArgs e)
{
UltraGridRow row = ultraGrid1.ActiveRow;
if (row == null) return;
FrmStopSamll fpdc = new FrmStopSamll(row.Cells["STOP_SMALL_CODE"].Value.ToString(), 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["STOP_REASON"].Value = fpdc.Basename;
row.Cells["STOP_REASON_CODE"].Value = fpdc.Basecode;
//cmbSTOP_REASON.Value = fpdc.Basename;
}
}
///
/// 停机小类
///
///
///
private void cmbSTOP_SMALL_EditorButtonClick(object sender, EditorButtonEventArgs e)
{
UltraGridRow row = ultraGrid1.ActiveRow;
string STOP_TYPE = "";
if (!row.Cells["STOP_TYPE"].Text.Trim().Equals(""))
{
STOP_TYPE = row.Cells["STOP_TYPE"].Value.ToString();
}
FrmStopSamll fpdc = new FrmStopSamll(STOP_TYPE, 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["STOP_SMALL"].Value = fpdc.Basename;
row.Cells["STOP_SMALL_CODE"].Value = fpdc.Basecode;
//cmbSTOP_SMALL.Value = fpdc.Basename;
}
}
///
/// 班次中文
///
///
///
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;
}
private void ultraGrid1_CellChange_1(object sender, CellEventArgs e)
{
if (e.Cell.Column.Key != "CHK")
e.Cell.Row.Cells["CHK"].Value = true;
}
}
}