You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
967 lines
36 KiB
967 lines
36 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.Linq;
|
|
using System.Linq;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Views.BandedGrid;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.Report.GridReport;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Runtime.InteropServices;
|
|
using ICSSoft.Frame.DataConnect;
|
|
using ICSSoft.Frame.DataCollect;
|
|
using ICSSoft.Frame.DataConnect.Action;
|
|
using System.Collections;
|
|
using ICSSoft.Frame.Helper;
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormDataAcquise : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
|
|
private FramDataContext _domainDataProvider = null;
|
|
private ActionCheckStatus actionCheckStatus = new ActionCheckStatus();
|
|
private ICSRES Resource;
|
|
|
|
private DataSet dsone;
|
|
private DataSet dstwo;
|
|
private DataTable dtzhu;
|
|
private DataTable dtone;
|
|
private DataTable dttwo;
|
|
private DataTable dtthree;
|
|
//资源
|
|
public string res = "";
|
|
[DllImport("user32")]
|
|
public static extern int SetParent(int hWndChild, int hWndNewParent);
|
|
|
|
private ICSBaseModel _ICSBaseModel = null;
|
|
private DataCollectFacade _DataCollectFacade = null;
|
|
private ProductInfo product;
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
String guid = AppConfig.GetGuid();
|
|
private DataTable dataSource = null;
|
|
FormDataShow datashow;
|
|
|
|
private double iNG = 0;
|
|
|
|
private Hashtable listActionCheckStatus = new Hashtable();
|
|
|
|
#region 构造函数
|
|
public FormDataAcquise()
|
|
{
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
this.IsMdiContainer = true;
|
|
|
|
dsone = new DataSet();
|
|
dstwo = new DataSet();
|
|
|
|
|
|
|
|
_domainDataProvider = new FramDataContext(AppConfig.AppConnectString);
|
|
|
|
_DataCollectFacade = new DataCollectFacade(this._domainDataProvider);
|
|
|
|
_ICSBaseModel = new ICSBaseModel(this._domainDataProvider);
|
|
}
|
|
public FormDataAcquise(string resource)
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
this.IsMdiContainer = true;
|
|
dsone = new DataSet();
|
|
dstwo = new DataSet();
|
|
res = resource;
|
|
txtInfo.Text = "当前资源是:" + res;
|
|
foreach (DevExpress.XtraGrid.Columns.GridColumn col in gridCK.Columns)
|
|
{
|
|
col.OptionsColumn.AllowEdit = col.Name == colActNum.Name || col.Name == colunQua.Name;
|
|
}
|
|
|
|
_domainDataProvider = new FramDataContext(AppConfig.AppConnectString);
|
|
|
|
_DataCollectFacade = new DataCollectFacade(this._domainDataProvider);
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 退出r0
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
datashow.Close();
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
|
|
}
|
|
|
|
#endregion[
|
|
#region 移动窗体
|
|
private const int WM_NCHITTEST = 0x84;
|
|
private const int HTCLIENT = 0x1;
|
|
private const int HTCAPTION = 0x2;
|
|
//首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
|
|
//系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
|
|
//假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
|
|
//同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
|
|
|
|
//重写窗体,使窗体可以不通过自带标题栏实现移动
|
|
protected override void WndProc(ref System.Windows.Forms.Message m)
|
|
{
|
|
|
|
|
|
//当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
|
|
//当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
|
|
//这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
|
|
//注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
|
|
switch (m.Msg)
|
|
{
|
|
case WM_NCHITTEST:
|
|
base.WndProc(ref m);
|
|
if ((int)m.Result == HTCLIENT)
|
|
m.Result = (IntPtr)HTCAPTION;
|
|
return;
|
|
}
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
if (m.Msg != 0xA3)
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 列表
|
|
private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
}
|
|
#endregion
|
|
#region 分页
|
|
private void rptPage_PageIndexChanged(object Sender, EventArgs e)
|
|
{
|
|
|
|
//DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
|
|
////DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
|
|
//grdDetail.DataSource = data;
|
|
}
|
|
#endregion
|
|
|
|
private void FormDataAcquise_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FormResourceLogin frl = new FormResourceLogin(this);
|
|
frl.ShowDialog();
|
|
txtInfo.Text = "当前登陆资源是:" + res;
|
|
|
|
Resource = this._domainDataProvider.ICSRES.SingleOrDefault(a => a.RESCODE == this.res && a.WorkPoint == AppConfig.WorkPointCode);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
private void txtRcard_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar == '-')
|
|
e.Handled = true;
|
|
if (e.KeyChar == 13)
|
|
{
|
|
this.Validate();
|
|
if (txtRCard.Text.Trim() == string.Empty)
|
|
{
|
|
txtMo.Text = String.Empty;
|
|
txtItemCode.Text = String.Empty;
|
|
txtItemName.Text = String.Empty;
|
|
txtRCard.Focus();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
//根据产品序列号找到工单,产品信息
|
|
if (GetMoItem())
|
|
{
|
|
string sql = @"select OPCODE
|
|
from ICSOP2RES
|
|
where RESCODE='" + res + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
string op = data.Rows[0]["OPCODE"].ToString();
|
|
txtOP.Text = "工序是:" + op;
|
|
|
|
string sql2 = @"select ROUTECODE
|
|
from ICSMO2ROUTE
|
|
where MOCODE='" + txtMo.Text + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql2 = string.Format(sql2);
|
|
DataTable data2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql2).Tables[0];
|
|
string route = data2.Rows[0]["ROUTECODE"].ToString();
|
|
txtRoute.Text = "途程是:" + route;
|
|
|
|
//绑定显示当前工单生产信息
|
|
Blindone();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private bool GetMoItem()
|
|
{
|
|
string sql = @"select b.MOCODE as mocode,b.ITEMCODE as itemcode,c.INVNAME as itemdesc,a.RCARD
|
|
from ICSMO2RCARD a
|
|
left join ICSMO b on a.MOCODE=b.MOCODE
|
|
left join ICSINVENTORY c on b.ITEMCODE=c.INVCODE
|
|
where RCARD='" + txtRCard.Text.Trim() + "' ";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
if (dt.Rows[0]["mocode"].ToString() != "")
|
|
{
|
|
txtMo.Text = dt.Rows[0]["mocode"].ToString();
|
|
}
|
|
if (dt.Rows[0]["itemcode"].ToString() != "")
|
|
{
|
|
txtItemCode.Text = dt.Rows[0]["itemcode"].ToString();
|
|
}
|
|
if (dt.Rows[0]["itemdesc"].ToString() != "")
|
|
{
|
|
txtItemName.Text = dt.Rows[0]["itemdesc"].ToString();
|
|
}
|
|
|
|
SetMsg(Color.White, "");
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
SetMsg(Color.Red, "序列号不存在,请重新输入!");
|
|
this.txtRCard.Text = "";
|
|
this.txtRCard.Focus();
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
private void txtRcard_Validated(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
private void Blindone()
|
|
{
|
|
//绑定
|
|
if (dsone!=null)
|
|
{
|
|
dsone.Reset();
|
|
}
|
|
dtzhu = null;
|
|
dtone = null;
|
|
dtzhu = MainTable().Copy();
|
|
dtone = OneTable().Copy();
|
|
dtzhu.TableName = "one";
|
|
dtone.TableName = "two";
|
|
if (dsone != null)
|
|
{
|
|
dsone.Tables.Add(dtzhu);
|
|
dsone.Tables.Add(dtone);
|
|
}
|
|
DataRelation dr = new DataRelation("Level1", new DataColumn[] { dsone.Tables[0].Columns["CKGROUP"] }, new DataColumn[] { dsone.Tables[1].Columns["CKGROUP"] });
|
|
dsone.Relations.Add(dr);
|
|
grdDetail.DataSource = dtzhu;
|
|
grvCKGView.BestFitColumns();
|
|
gridERGDetail.BestFitColumns();
|
|
|
|
}
|
|
private void Blindtwo()
|
|
{
|
|
//绑定
|
|
if (dstwo != null)
|
|
{
|
|
dstwo.Reset();
|
|
}
|
|
dttwo = null;
|
|
dtthree = null;
|
|
dttwo = TwoTable().Copy();
|
|
dtthree = ThreeTable().Copy();
|
|
dttwo.TableName = "three";
|
|
dtthree.TableName = "four";
|
|
if (dstwo != null)
|
|
{
|
|
dstwo.Tables.Add(dttwo);
|
|
dstwo.Tables.Add(dtthree);
|
|
}
|
|
DataRelation dr = new DataRelation("Level2", new DataColumn[] { dstwo.Tables[0].Columns["ECGCODE"] }, new DataColumn[] { dstwo.Tables[1].Columns["ECGCODE"] });
|
|
dstwo.Relations.Add(dr);
|
|
gridERDetail.DataSource = dttwo;
|
|
gridERGDetail.BestFitColumns();
|
|
gridER.BestFitColumns();
|
|
|
|
}
|
|
|
|
#region 检验类型
|
|
public DataTable MainTable()
|
|
{
|
|
string sql = @"select
|
|
cast( 0 as bit) as isSelect,
|
|
a.CKGROUP,
|
|
b.CKGROUPDESC
|
|
from ICSMODELOP2CKGROUP a
|
|
left join ICSOQCCKGROUP b on a.CKGROUP=b.CKGROUP
|
|
where a.ITEMCODE='{0}' and a.OPCODE in(select OPCODE from ICSOP2RES where RESCODE='{1}')";
|
|
sql = string.Format(sql,txtItemCode.Text,res);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#region 检验项目
|
|
public DataTable OneTable()
|
|
{
|
|
string sql = @"select cast( 0 as bit) as XuHao,cast( 0 as bit) as unQua,cast(0 as decimal(18,2)) as ActNum,a.CKITEMCODE,a.CKITEMDESC,a.SetValueMin,a.SetValueMax,b.CKGROUP as CKGROUP
|
|
from ICSOQCCKLIST a
|
|
left join ICSOQCCKGROUP2LIST b on a.CKITEMCODE=b.CKITEMCODE
|
|
where b.CKGROUP in(select a.CKGROUP
|
|
from ICSMODELOP2CKGROUP a
|
|
left join ICSOQCCKGROUP b on a.CKGROUP=b.CKGROUP
|
|
where a.ITEMCODE='{0}' and a.OPCODE in(select OPCODE from ICSOP2RES where RESCODE='{1}'))";
|
|
sql = string.Format(sql, txtItemCode.Text, res);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#region 不良代码组
|
|
public DataTable TwoTable()
|
|
{
|
|
string sql = @"select cast( 0 as bit) as selectone,a.ECGCODE as ECGCODE,b.ECGDESC as ECGDESC
|
|
from ICSMODEL2ECG a
|
|
left join ICSECG b on a.ECGCODE=b.ECGCODE
|
|
where a.MODELCODE in (select INVCLASS from ICSINVENTORY where INVCODE='{0}') ";
|
|
sql = string.Format(sql, txtItemCode.Text);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#region 不良代码
|
|
public DataTable ThreeTable()
|
|
{
|
|
string sql = @"select cast( 0 as bit) as selecttwo,a.ECGCODE as ECGCODE,b.ECODE as ECODE,b.ECDESC as ECDESC
|
|
from ICSECG2EC a
|
|
left join ICSEC b on a.ECODE=b.ECODE
|
|
where a.ECGCODE in (select ECGCODE
|
|
from ICSMODEL2ECG
|
|
where MODELCODE in (select INVCLASS from ICSINVENTORY where INVCODE='{0}'))";
|
|
sql = string.Format(sql, txtItemCode.Text);
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
private void txtbuliang_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
Blindtwo();
|
|
}
|
|
|
|
private void txtliang_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
dstwo.Reset();
|
|
dttwo = null;
|
|
dtthree = null;
|
|
}
|
|
|
|
private void grvDetail_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
|
{
|
|
if (e.Column == colisSelect)
|
|
{
|
|
if (e.Value == null)
|
|
{ return; }
|
|
bool? isSelect = e.Value as bool?;
|
|
|
|
string ckgroup = grvCKGView.GetRowCellValue(grvCKGView.FocusedRowHandle, colCKGROUP).ToString();
|
|
|
|
DataRow[] drs = dtone.Select("CKGROUP = '" + ckgroup + "'");
|
|
foreach (DataRow dr in drs)
|
|
{
|
|
dr["XuHao"] = isSelect;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void txtUnLiang_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar == 13)
|
|
this.Validate();
|
|
}
|
|
|
|
private void txtUnLiang_Validated(object sender, EventArgs e)
|
|
{
|
|
string buLiang = txtERSCode.Text.Trim();
|
|
if (!buLiang.Equals(""))
|
|
{
|
|
DataRow[] drs = dtthree.Select("ECSCODE='" + buLiang + "'");
|
|
if (!(drs.Count() == 0))
|
|
{
|
|
foreach (DataRow dr in drs)
|
|
{
|
|
dr["selecttwo"] = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void txtMo_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btnExit_Click_1(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
#region 保存按钮的主逻辑
|
|
Messages messages = new Messages();
|
|
|
|
try
|
|
{
|
|
int m = 0;
|
|
for (int i = 0; i < gridCK.RowCount; i++)
|
|
{
|
|
string sel = gridCK.GetRowCellValue(i, colXuHao).ToString();
|
|
if (sel == "True")
|
|
{
|
|
m++;
|
|
}
|
|
}
|
|
if (m == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("无可要保存的良品数据,请选择数据!");
|
|
return;
|
|
}
|
|
|
|
this._domainDataProvider.Connection.Open();
|
|
this._domainDataProvider.Transaction = this._domainDataProvider.Connection.BeginTransaction();
|
|
|
|
ActionOnLineHelper onLine = new ActionOnLineHelper(this._domainDataProvider);
|
|
|
|
string rCard = this.txtRCard.Text.Trim();
|
|
messages.AddMessages(CheckProduct(rCard));
|
|
actionCheckStatus = new ActionCheckStatus();
|
|
actionCheckStatus.ProductInfo = product;
|
|
|
|
|
|
if (actionCheckStatus.ProductInfo != null)
|
|
{
|
|
actionCheckStatus.ProductInfo.Resource = Resource;
|
|
}
|
|
|
|
string strMoCode = this.txtMo.Text.Trim();
|
|
actionCheckStatus.MO = this._domainDataProvider.ICSMO.SingleOrDefault(a => a.MOCODE == strMoCode && a.WorkPoint == AppConfig.WorkPointCode);
|
|
|
|
if (listActionCheckStatus.ContainsKey(strMoCode))
|
|
{
|
|
actionCheckStatus = (ActionCheckStatus)listActionCheckStatus[strMoCode];
|
|
actionCheckStatus.ProductInfo = product;
|
|
actionCheckStatus.ActionList = new ArrayList();
|
|
}
|
|
else
|
|
{
|
|
actionCheckStatus.NeedUpdateSimulation = false;
|
|
actionCheckStatus.NeedFillReport = false;
|
|
listActionCheckStatus.Add(strMoCode, actionCheckStatus);
|
|
}
|
|
|
|
|
|
//判断检验项目选中后是否填入测试值
|
|
if (!CheckIsDoAllCheckList())
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, "填入测试值"));
|
|
}
|
|
|
|
if (messages.IsSuccess())
|
|
{
|
|
|
|
messages.AddMessages(CheckInfo());
|
|
}
|
|
|
|
if (!messages.IsSuccess())
|
|
{
|
|
throw new Exception(messages.ToString());
|
|
}
|
|
|
|
//良品采集
|
|
if (messages.IsSuccess() && this.rdGood.Checked)
|
|
{
|
|
messages.AddMessages(GetProduct(rCard));
|
|
|
|
messages.AddMessages(RunGood(actionCheckStatus, this.GetTestData().ToArray(), rCard));
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
if (!messages.IsSuccess())
|
|
{
|
|
throw new Exception(messages.ToString());
|
|
}
|
|
}
|
|
//不良品采集
|
|
if (messages.IsSuccess() && this.rdNG.Checked)
|
|
{
|
|
messages.AddMessages(CheckErrorCodes());
|
|
if (messages.IsSuccess())
|
|
{
|
|
messages.AddMessages(GetProduct(rCard));
|
|
|
|
messages.AddMessages(RunNG(actionCheckStatus, this.GetTestData().ToArray(), rCard));
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (!messages.IsSuccess())
|
|
{
|
|
throw new Exception(messages.ToString());
|
|
}
|
|
}
|
|
|
|
this._domainDataProvider.SubmitChanges();
|
|
this._domainDataProvider.Transaction.Commit();
|
|
this._domainDataProvider.Connection.Close();
|
|
SetMsg(Color.Blue, "序列号:" + rCard + "采集成功!");
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this._domainDataProvider.Transaction.Rollback();
|
|
this._domainDataProvider.Connection.Close();
|
|
SetMsg(Color.Red, ex.Message);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
private Messages CheckInfo()
|
|
{
|
|
Messages messages = new Messages();
|
|
//判断是否是第一道工序,如果是则做归属工单 如果不是则做过站操作
|
|
ICSITEMROUTE2OP itemRoute2Op = _DataCollectFacade.GetMORouteFirstOperation(this.txtMo.Text.Trim());
|
|
|
|
//根据资源找到对应的工序
|
|
ICSOP2RES op2res = _ICSBaseModel.GetOperationByResource(res);
|
|
if (itemRoute2Op.OPCODE == op2res.OPCODE)
|
|
{
|
|
|
|
//先判断是不良品回流,如果是,则不走GOMO,如果不是则走GOMO
|
|
if ((CheckIsExistInICSTS(txtRCard.Text) == null))
|
|
{
|
|
messages.AddMessages(RunGOMO(actionCheckStatus, this.txtRCard.Text.Trim()));
|
|
|
|
if (!messages.IsSuccess())
|
|
{
|
|
listActionCheckStatus.Clear();
|
|
}
|
|
}
|
|
else if (CheckIsExistInICSTS(txtRCard.Text).TSSTATUS != "tsstatus_reflow")
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("当前工序未完成维修")));
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (GetSimulationByRCard(txtRCard.Text) == null)
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("该序列号未归属工单")));
|
|
|
|
}
|
|
//当前工序如果不是第一站工序
|
|
//判断是否有不良品回流
|
|
if (CheckIsExistInICSTS(txtRCard.Text) != null)
|
|
{
|
|
if (op2res.OPCODE == CheckIsExistInICSTS(txtRCard.Text).FRMOPCODE)
|
|
{
|
|
|
|
if (CheckIsExistInICSTS(txtRCard.Text).TSSTATUS != "tsstatus_reflow")
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("当前工序未完成维修")));
|
|
//return;
|
|
}
|
|
|
|
if ((GetSimulationByRCard(txtRCard.Text).OPCODE != op2res.OPCODE) && CheckIsExistInICSTS(txtRCard.Text).FRMOPCODE ==
|
|
GetSimulationByRCard(txtRCard.Text).OPCODE && (CheckIsExistInICSTS(txtRCard.Text).TSSTATUS != "tsstatus_reflow"))
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("工序" + CheckIsExistInICSTS(txtRCard.Text).FRMOPCODE + "未完成维修")));
|
|
//return;
|
|
}
|
|
}
|
|
|
|
}
|
|
return messages;
|
|
}
|
|
#region 处理函数
|
|
//获得产品信息
|
|
private Messages GetProduct(string rcard)
|
|
{
|
|
Messages productmessages = new Messages();
|
|
ActionOnLineHelper dataCollect = new ActionOnLineHelper(this._domainDataProvider);
|
|
|
|
productmessages.AddMessages(dataCollect.GetIDInfo(rcard));
|
|
if (productmessages.IsSuccess())
|
|
{
|
|
product = (ProductInfo)productmessages.GetData().Values[0];
|
|
}
|
|
else
|
|
{
|
|
product = new ProductInfo();
|
|
}
|
|
return productmessages;
|
|
}
|
|
|
|
//获得产品信息
|
|
private Messages GetProduct()
|
|
{
|
|
Messages productmessages = new Messages();
|
|
ActionOnLineHelper dataCollect = new ActionOnLineHelper(this._domainDataProvider);
|
|
|
|
//获取转换后序列号
|
|
string runingCard = _DataCollectFacade.GetRuningCard(this.txtRCard.Text.Trim().ToUpper(), string.Empty);
|
|
|
|
productmessages.AddMessages(dataCollect.GetIDInfo(runingCard));
|
|
if (productmessages.IsSuccess())
|
|
{
|
|
product = (ProductInfo)productmessages.GetData().Values[0];
|
|
}
|
|
else
|
|
{
|
|
product = new ProductInfo();
|
|
}
|
|
|
|
return productmessages;
|
|
}
|
|
|
|
// 根据产品信息,决定部分控件的状态
|
|
private Messages CheckProduct(string rcard)
|
|
{
|
|
Messages messages = new Messages();
|
|
try
|
|
{
|
|
messages.AddMessages(GetProduct(rcard));
|
|
|
|
if (product.LastSimulation != null)
|
|
{
|
|
btnSave.Enabled = true;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(e));
|
|
|
|
}
|
|
return messages;
|
|
}
|
|
|
|
// GOOD指令采集
|
|
private Messages RunGood(ActionCheckStatus actionCheckStatus, object[] testDataObjectList, string rCard)
|
|
{
|
|
Messages messages = new Messages();
|
|
|
|
IAction dataCollectModule = new ActionFactory(this._domainDataProvider).CreateAction(ActionType.DataCollectAction_GOOD);
|
|
messages.AddMessages(((IActionWithStatus)dataCollectModule).Execute(new ActionEventArgs(ActionType.DataCollectAction_GOOD, rCard,
|
|
AppConfig.UserCode,
|
|
this.res, product, testDataObjectList), actionCheckStatus));
|
|
|
|
if (messages.IsSuccess())
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("$CS_GOODSUCCESS,$CS_Param_ID: {0}", rCard)));
|
|
}
|
|
return messages;
|
|
}
|
|
|
|
// NG指令采集
|
|
private Messages RunNG(ActionCheckStatus actionCheckStatus, object[] testDataObjectList, string rCard)
|
|
{
|
|
Messages messages = new Messages();
|
|
|
|
object[] ErrorCodes = GetNGData().ToArray();//取不良代码组+不良代码
|
|
|
|
IAction dataCollectModule = new ActionFactory(this._domainDataProvider).CreateAction(ActionType.DataCollectAction_NG);
|
|
messages.AddMessages(((IActionWithStatus)dataCollectModule).Execute(
|
|
new TSActionEventArgs(ActionType.DataCollectAction_NG,
|
|
rCard,
|
|
AppConfig.UserCode,
|
|
this.res,
|
|
product,
|
|
ErrorCodes,
|
|
null,
|
|
"", testDataObjectList), actionCheckStatus));
|
|
if (messages.IsSuccess())
|
|
{
|
|
iNG = iNG + 1;
|
|
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, string.Format("$CS_NGSUCCESS,$CS_Param_ID: {0}", rCard)));
|
|
}
|
|
return messages;
|
|
}
|
|
|
|
//工单归属采集
|
|
private Messages RunGOMO(ActionCheckStatus actionCheckStatus, string rCard)
|
|
{
|
|
Messages messages = new Messages();
|
|
ActionOnLineHelper onLine = new ActionOnLineHelper(this._domainDataProvider);
|
|
|
|
actionCheckStatus.ProductInfo = product;
|
|
|
|
|
|
//参数定义
|
|
GoToMOActionEventArgs args = new GoToMOActionEventArgs(ActionType.DataCollectAction_GoMO,rCard.Trim(),
|
|
AppConfig.UserCode,
|
|
this.res, product, this.txtMo.Text.Trim());
|
|
|
|
//Laws Lu,执行工单采集并收集返回信息
|
|
if (messages.IsSuccess())
|
|
{
|
|
messages.AddMessages(onLine.Action(args, actionCheckStatus));
|
|
}
|
|
|
|
if (messages.IsSuccess())
|
|
{
|
|
messages.Add(new ICSSoft.Frame.DataConnect.Message(MessageType.Success, "$CS_GOMOSUCCESS $CS_Param_ID:" + rCard.Trim().ToString()));
|
|
this.txtRCard.SelectAll();
|
|
this.txtRCard.Focus();
|
|
}
|
|
|
|
return messages;
|
|
}
|
|
|
|
//判断是否是最后一道工序
|
|
private bool IsLastOP(string moCode, string routeCode, string opCode)
|
|
{
|
|
if (routeCode == string.Empty)
|
|
return false;
|
|
return _DataCollectFacade.OPIsMORouteLastOP(moCode, routeCode, opCode);
|
|
}
|
|
|
|
|
|
//判断是否所有的检验项目都勾选,并设置结果
|
|
private bool CheckIsDoAllCheckList()
|
|
{
|
|
//for (int i = 0; i < this.grvCKGView.row.Count; i++)
|
|
//{
|
|
// if (this.ultraGridCheckList.Rows[i].HasChild(false))
|
|
// {
|
|
// for (int j = 0; j < this.ultraGridCheckList.Rows[i].ChildBands[0].Rows.Count; j++)
|
|
// {
|
|
// if (this.ultraGridCheckList.Rows[i].ChildBands[0].Rows[j].Cells["Checked"].Value == "false")
|
|
// {
|
|
// return false;
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
return true;
|
|
}
|
|
public ICSTS CheckIsExistInICSTS(string rcard)
|
|
{
|
|
string sql2 = @"select *
|
|
from ICSTS
|
|
where RCARD='" + rcard + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
var objs = this._domainDataProvider.ExecuteQuery<ICSTS>(sql2).ToList();
|
|
if (objs == null || objs.Count < 1)
|
|
return null;
|
|
else
|
|
return (ICSTS)objs[0];
|
|
}
|
|
|
|
// private bool tsstatus_reflow()
|
|
// {
|
|
// string sql2 = @"select *
|
|
// from ICSTS
|
|
// where RCARD='" + txtRCard.Text + "' and TSSTATUS='tsstatus_reflow' and WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
// sql2 = string.Format(sql2);
|
|
// DataTable data2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql2).Tables[0];
|
|
// if (data2.Rows.Count > 0)
|
|
// {
|
|
// return true;
|
|
// }
|
|
|
|
// return false;
|
|
// }
|
|
|
|
|
|
public ICSSimulation GetSimulationByRCard(string rCard)
|
|
{
|
|
string sql = @"select * from ICSSimulation
|
|
where RCARD = '" + rCard + "' order by MTIME desc";
|
|
var objs = this._domainDataProvider.ExecuteQuery<ICSSimulation>(sql).ToList();
|
|
if (objs == null || objs.Count < 1)
|
|
return null;
|
|
else
|
|
return (ICSSimulation)objs[0];
|
|
}
|
|
private Messages CheckErrorCodes()
|
|
{
|
|
Messages megs = new Messages();
|
|
//if (ucErrorCodeSelectNew.GetSelectedErrorCodeList() == null || ucErrorCodeSelectNew.GetSelectedErrorCodeList().Length == 0)
|
|
// megs.Add(new UserControl.Message(MessageType.Error, "$CS_Please_Select_ErrorCode"));
|
|
return megs;
|
|
}
|
|
|
|
|
|
private List<ICSTESTDATA> GetTestData()
|
|
{
|
|
List<ICSTESTDATA> datalist = new List<ICSTESTDATA>();
|
|
|
|
#region 测试数据
|
|
|
|
for (int i = 0; i < gridCK.RowCount; i++)
|
|
{
|
|
int shiftDay = 0;
|
|
string sel = gridCK.GetRowCellValue(i, colXuHao).ToString();
|
|
if (sel == "True")
|
|
{
|
|
ICSBaseModel model = new ICSBaseModel(this._domainDataProvider);
|
|
ICSRES res1 = (ICSRES)model.GetResource(res);
|
|
if (res != null)
|
|
{
|
|
ICSTP currTimePeriod = (ICSTP)model.GetTimePeriod(res1.SHIFTTYPECODE, FormatHelper.TODateInt(AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss")));
|
|
shiftDay = model.GetShiftDay(currTimePeriod, DateTime.Now);
|
|
}
|
|
ICSTESTDATA test = new ICSTESTDATA();
|
|
test.GUID = AppConfig.GetGuid();
|
|
test.RCARD = txtRCard.Text;
|
|
test.MOCODE = txtMo.Text;
|
|
test.SHIFTDAY = shiftDay;
|
|
test.ITEMCODE = txtItemCode.Text;
|
|
test.ICSMESEntityList_serial = "0";
|
|
test.DEVICENO = "";
|
|
test.CKGROUP = gridCK.GetRowCellValue(i, colziCKGROUP).ToString();
|
|
test.CKITEMCODE = gridCK.GetRowCellValue(i, colCKITEMCODE).ToString();
|
|
test.PARAM = "";
|
|
test.USL = Convert.ToDecimal(gridCK.GetRowCellValue(i, colSetValueMax).ToString());
|
|
test.LSL = Convert.ToDecimal(gridCK.GetRowCellValue(i, colSetValueMin).ToString());
|
|
test.TESTINGVALUE = gridCK.GetRowCellValue(i, colActNum).ToString();
|
|
test.TESTINGRESULT = gridCK.GetRowCellValue(i, colunQua).ToString();
|
|
test.TESTINGTIME = DateTime.Now;
|
|
test.MUSER = AppConfig.UserCode;
|
|
test.MUSERName = AppConfig.UserName;
|
|
test.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
test.WorkPoint = AppConfig.WorkPointCode;
|
|
datalist.Add(test);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
return datalist;
|
|
}
|
|
|
|
private List<ICSTESTDATA> GetSelectedErrorCodeList()
|
|
{
|
|
return new List<ICSTESTDATA>();
|
|
}
|
|
#endregion
|
|
|
|
|
|
private void SetMsg(Color color, string Msg)
|
|
{
|
|
txtMessages.Text = Msg;
|
|
txtMessages.ForeColor = color;
|
|
}
|
|
|
|
private void ClearPageData()
|
|
{
|
|
txtMo.Text = String.Empty;
|
|
txtItemCode.Text = String.Empty;
|
|
txtItemName.Text = String.Empty;
|
|
|
|
}
|
|
|
|
//不良品选中数据
|
|
private List<ICSECG2EC> GetNGData()
|
|
{
|
|
List<ICSECG2EC> datalist = new List<ICSECG2EC>();
|
|
for (int i = 0; i < gridER.RowCount; i++)
|
|
{
|
|
if (gridER.GetRowCellValue(i, colselecttwo).ToString() == "True")
|
|
{
|
|
ICSECG2EC data = new ICSECG2EC();
|
|
data.ECODE = gridER.GetRowCellValue(i, colECSCODE).ToString();
|
|
data.ECGCODE = gridER.GetRowCellValue(i,colECSGCODEZI).ToString();
|
|
datalist.Add(data);
|
|
}
|
|
}
|
|
return datalist;
|
|
}
|
|
|
|
private void grvCKGView_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e)
|
|
{
|
|
gridCK = grvCKGView.GetDetailView(e.RowHandle, e.RelationIndex) as DevExpress.XtraGrid.Views.Grid.GridView;
|
|
}
|
|
|
|
private void gridERGDetail_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e)
|
|
{
|
|
gridER = gridERGDetail.GetDetailView(e.RowHandle, e.RelationIndex) as DevExpress.XtraGrid.Views.Grid.GridView;
|
|
}
|
|
|
|
private void gridERGDetail_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
|
{
|
|
if (e.Column == colselectone)
|
|
{
|
|
if (e.Value == null)
|
|
{ return; }
|
|
bool? isSelect = e.Value as bool?;
|
|
|
|
string ckgroup = gridERGDetail.GetRowCellValue(gridERGDetail.FocusedRowHandle, colECGCODE).ToString();
|
|
|
|
DataRow[] drs = dtthree.Select("ECGCode = '" + ckgroup + "'");
|
|
foreach (DataRow dr in drs)
|
|
{
|
|
dr["selecttwo"] = isSelect;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|