|
|
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.Text.RegularExpressions; using Newtonsoft.Json; using System.Net; using System.Configuration; using Newtonsoft.Json.Linq; namespace ICSSoft.Frame.APP { public partial class FormICSProductionReport : DevExpress.XtraEditors.XtraForm {
private FramDataContext _domainDataProvider = null; private string sqltxt = ""; private string sqlconn = ""; //String guid = AppConfig.GetGuid();
private DataTable dataSource = null; //string ID = "";
string ItemCode = string.Empty; string ItemName = string.Empty; string INVDESC = string.Empty; string RCVCode = string.Empty; string LotNo = string.Empty; Decimal TotalQty = 0; Decimal YLOTQTY = 0; Decimal UYLOTQTY = 0; string OPCode = string.Empty; string lotno = ""; private const string PAUSE = "暂停"; private const string CANCELPAUSE = "取消暂停"; private const string START = "开工"; private const string END = "完工"; private string Status; private string routeCode; private string EQPType; private string partCode = ""; private string partSpec = "";
string RouteCode = string.Empty; private const string STARTSTATUS = "COLLECT_BEGIN"; private const string ENDSTATUS = "COLLECT_END"; String guid = ""; FormICSECGUIModel ecgUIModel; int Flag; DataTable palINVdt = new DataTable(); //DataTable grvdt = new DataTable();
//DataTable connectgrvdt = new DataTable();
int MainKniefQTY = 0; string MOSEQ = ""; bool InvControl = false; bool MouldContorl = false; string OPCodeCurrent = ""; string OPCodeNext = ""; string opseq=""; DataTable dataUpOPDetail = new DataTable();
#region 构造函数
public FormICSProductionReport() { InitializeComponent(); this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); this.WindowState = FormWindowState.Maximized; initType(); this.txtLotNo.Focus(); panelMap.Dock = DockStyle.Fill; panelOP.Dock = DockStyle.Fill; //panel8WebMap.Dock = DockStyle.Fill;
this.label23.Visible = false; panelMap.BringToFront(); //panel8WebMap.BringToFront();
this.txtReturnMateralSave.Visible = false;
labelControl1.Visible = false; txtSBItemCode.Visible = false; labelControl2.Visible = false; txtSBItemCodeQty.Visible = false;
} #endregion
#region 构造函数
public FormICSProductionReport(string _ItemCode, string _ItemName, string _INVDESC, string _RCVCode, string _LotNo, Decimal _TotalQty, Decimal _YLOTQTY, Decimal _UYLOTQTY) { InitializeComponent(); this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); this.WindowState = FormWindowState.Maximized; //txtMOCode.Text = ItemCode = _ItemCode;
//txtItemName.Text = ItemName = _ItemName;
txtLotNo.Text = LotNo = _LotNo; //txtItemINVDESC.Text = INVDESC = _INVDESC;
//txtTotalQty.Text = _TotalQty.ToString();
TotalQty = _TotalQty; RCVCode = _RCVCode;
Decimal YLOTQTY = _YLOTQTY; Decimal UYLOTQTY = _UYLOTQTY; //init();
BandData(ItemCode, LotNo, OPCode);
} #endregion
#region 初始化查询条件
private void init() { #region
string sql = @"SELECT a.CKListCode ,
b.CKITENAME , a.CKGROUP, a.CKITEMCODE, a.VALUEMAX , a.VALUEMIN , a.UNIT, a.AQL, a.InspectionStandard, IQC.S1,IQC.S2,IQC.S3,IQC.S4,IQC.S5,IQC.S6,IQC.S7,IQC.S8,IQC.S9,IQC.S10,IQC.CCResult FROM ICSOQCCKGROUP2LIST a LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE LEFT JOIN ICSOQCCKGROUP2LISTCheckResult IQC ON IQC.CKListCode=a.CKListCode AND a.CKITEMCODE =IQC.CKITEMCODE AND IQC.RCVCode='" + RCVCode + "' AND IQC.LotNo='" + LotNo + "' AND IQC.VALUEMAX=A.VALUEMAX AND IQC.VALUEMIN=A.VALUEMIN " +
" WHERE a.CKITEMCODE = '" + ItemCode + "' AND IQC.CheckoutAttribute = '量化'";//AND a.IsUse = '1'
sql = string.Format(sql, AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) {
if (dt != null && dt.Rows.Count > 0) { bool istrue = false; foreach (DataRow item in dt.Rows) { string resultCC = item["CCResult"].ToString(); if (resultCC == "NG") { istrue = false; break; } if (resultCC == "OK") { istrue = true; } }
}
} else { string sqlUn = @"SELECT a.CKListCode ,
b.CKITENAME , a.CKGROUP, a.CKITEMCODE, a.VALUEMAX , a.VALUEMIN , a.UNIT, a.AQL, a.InspectionStandard,'' S1,'' S2,'' S3,'' S4,'' S5,'' S6,'' S7,'' S8,'' S9,'' S10 FROM ICSOQCCKGROUP2LIST a LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = '尺寸'";
sqlUn = string.Format(sqlUn, AppConfig.WorkPointCode); DataTable dtun = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlUn).Tables[0]; //gridControlcc.DataSource = dtun;
}
#endregion
string sql2 = @"SELECT a.CKListCode CKListCode1 ,
b.CKITENAME CKITENAME1 , a.CKGROUP, a.CKITEMCODE, a.VALUEMAX , a.VALUEMIN , a.UNIT, a.AQL , a.InspectionStandard ,IQC.Qualified,IQC.UnQualified,IQC.WGResult FROM ICSOQCCKGROUP2LIST a LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE LEFT JOIN ICSOQCCKGROUP2LISTCheckResult IQC ON IQC.CKListCode=a.CKListCode AND a.CKITEMCODE =IQC.CKITEMCODE AND IQC.RCVCode='" + RCVCode + "' AND IQC.LotNo='" + LotNo + "' AND A.AQL=IQC.AQL AND A.InspectionStandard=IQC.InspectionStandard " +
" WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND IQC.CheckoutAttribute = '外观'"; sql2 = string.Format(sql2, AppConfig.WorkPointCode); DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
if (dt2 != null && dt2.Rows.Count > 0) { //gridControl1.DataSource = dt2;
if (dt2 != null && dt2.Rows.Count > 0) { bool istrue = false; foreach (DataRow item in dt2.Rows) { string resultCC = item["WGResult"].ToString(); if (resultCC == "NG") { istrue = false; break; } if (resultCC == "OK") { istrue = true; } }
} } else { string sql2Un = @"SELECT a.CKListCode CKListCode1 ,
b.CKITENAME CKITENAME1 , a.CKGROUP, a.CKITEMCODE, a.VALUEMAX , a.VALUEMIN , a.UNIT, a.AQL , a.InspectionStandard ,'' Qualified,'' UnQualified FROM ICSOQCCKGROUP2LIST a LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = '外观'";
sql2Un = string.Format(sql2Un, AppConfig.WorkPointCode); DataTable dt2Un = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2Un).Tables[0]; //gridControl1.DataSource = dt2Un;
} }
private void initType() { #region 暂停
string sql2 = @"SELECT DISTINCT EnumValue [暂停类型编码] ,EnumText [暂停类型] FROM Sys_EnumValues WHERE EnumKey='00022'
UNION SELECT '' [暂停类型编码],'' [暂停类型] FROM Sys_EnumValues ";
sql2 = string.Format(sql2, AppConfig.WorkPointCode); DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0]; txtStopType.Properties.ValueMember = "暂停类型"; txtStopType.Properties.DisplayMember = "暂停类型"; txtStopType.Properties.DataSource = dt2; txtStopType.Properties.NullText = "";//空时的值
txtStopType.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtStopType.Properties.ValidateOnEnterKey = true;//回车确认
txtStopType.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtStopType.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtStopType.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion
//this.txtLotNo.SelectAll();
}
private void init_() { #region
string sql = @"SELECT a.CKListCode ,
b.CKITENAME , a.CKGROUP, a.CKITEMCODE, a.VALUEMAX , a.VALUEMIN , a.UNIT, a.AQL, a.InspectionStandard FROM ICSOQCCKGROUP2LIST a LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = '尺寸'";
sql = string.Format(sql, AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; //gridControlcc.DataSource = dt;
#endregion
string sql2 = @"SELECT a.CKListCode CKListCode1 ,
b.CKITENAME CKITENAME1 , a.CKGROUP, a.CKITEMCODE, a.VALUEMAX , a.VALUEMIN , a.UNIT, a.AQL , a.InspectionStandard FROM ICSOQCCKGROUP2LIST a LEFT JOIN ICSOQCCKLIST b ON a.CKListCode = b.CKITEMCODE WHERE a.CKITEMCODE = '" + ItemCode + "' AND a.IsUse = '1' AND a.CheckoutAttribute = '外观'";
sql2 = string.Format(sql2, AppConfig.WorkPointCode); DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0]; //gridControl1.DataSource = dt2;
} #endregion
#region 根据存货编码查询列表信息
private void BandData(string itemCode, string LotNo, string OPCode) { try { string sql = @"SELECT EnumName FROM Sys_EnumKey WHERE EnumKey='00006'"; //sql = string.Format(sql, itemCode);
string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
if (string.IsNullOrWhiteSpace(connectionString)) return; object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql); if (name == null || string.IsNullOrWhiteSpace(name.ToString())) return; //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + itemCode + OpCode + ".pdf";
string fileName = name.ToString() + itemCode + "\\" + itemCode + LotNo + OPCode + ".pdf";
if (!string.IsNullOrEmpty(fileName)) {
axAcroPDF.LoadFile(fileName); axAcroPDF.setShowToolbar(false); axAcroPDF.setShowScrollbars(false); axAcroPDF.setPageMode("thumbs"); axAcroPDF.setLayoutMode("SinglePage"); axAcroPDF.setView("Fit"); axAcroPDF.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); }
}
#endregion
#region 操作权限
public DataTable RightOfExute() { DataTable rData = new DataTable(); rData.Columns.Add("BtnName"); rData.Columns.Add("ActionName"); //查看权限(必须有)
DataRow seeRow = rData.NewRow(); seeRow["BtnName"] = "see"; seeRow["ActionName"] = "查看"; rData.Rows.Add(seeRow);
List<Control> ControlList = new List<Control>(); //ControlList.Add(simpleButton2);
//ControlList.Add(simpleButton3);
//ControlList.Add(btnOutPut);
foreach (Control ctr in ControlList) {
if (ctr.GetType() == typeof(SimpleButton)) { DataRow dr = rData.NewRow(); dr["BtnName"] = ctr.Name; dr["ActionName"] = ctr.Text; rData.Rows.Add(dr); } }
rData.AcceptChanges(); return rData; } public DataTable RightOfData()// 数据权限
{ DataTable rData = new DataTable(); rData.Columns.Add("BodyName"); rData.Columns.Add("ControlName"); rData.Columns.Add("ControlCaption");
rData.AcceptChanges(); return rData; } #endregion
#region 退出
private void btnClose_Click(object sender, EventArgs e) { AppConfig.CloseFormShow(this.Text); this.Close(); }
private void btnExit_Click(object sender, EventArgs e) { 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 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 string tempTableName = "";
//private void btnFilter_Click(object sender, EventArgs e)
//{
// FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
// filter.OldTempTableName = tempTableName;
// if (filter.ShowDialog() == DialogResult.OK)
// {
// DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
// try
// {
// _wait.Show();
// tempTableName = filter.NewTempTableName;
// sqltxt = filter.SqlText;
// sqlconn = filter.FilterConnectString;
// dataSource = filter.FilterData.Tables[0];
// grdDetail.DataSource = dataSource;
// grvDetail.BestFitColumns();
// rptPage.RecordNum = dataSource.Rows.Count;
// rptPage.PageSize = 499;
// rptPage.PageIndex = 1;
// rptPage.ReLoad();
// rptPage.PageSize = 500;
// rptPage.PageIndex = 1;
// rptPage.ReLoad();
// _wait.Close();
// }
// catch (Exception ex)
// {
// MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
// _wait.Close();
// }
// }
//}
#endregion
#region 绑定数据源
private void btnConfig_Click(object sender, EventArgs e) { //if (AppConfig.UserCode.ToLower() != "demo")
//{
// ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
// return;
//}
//FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
//fdata.ShowDialog();
} #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
#region 过滤方法
private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e) { //AppConfig.DropTemTable(tempTableName);
} #endregion
#region 全选
private void btnSelectAll_Click(object sender, EventArgs e) { //grvDetail.PostEditor();
//this.Validate();
//for (int i = 0; i < grvDetail.RowCount; i++)
//{
// grvDetail.SetRowCellValue(i, colisSelect, "Y");
//}
} #endregion
#region 全消
private void btnCancelAll_Click(object sender, EventArgs e) { //grvDetail.PostEditor();
//this.Validate();
//for (int i = 0; i < grvDetail.RowCount; i++)
//{
// grvDetail.SetRowCellValue(i, colisSelect, "");
//}
} #endregion
#region 刷新
private void btnFalsh_Click(object sender, EventArgs e) { //FormICSCREW_Load(null, null);
//txtMOCode.Text = ItemCode;
//txtItemName.Text = ItemName;
txtLotNo.Text = LotNo; //txtItemINVDESC.Text = INVDESC;
//txtTotalQty.Text = TotalQty.ToString();
//init_();
} #endregion
//private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
//{
// AppConfig.DropTemTable(tempTableName);
//}
#region 页面加载
private void FormICSCREW_Load(object sender, EventArgs e) { //btnFilter_Click(sender, e);
//button1.Enabled = false;
} #endregion
#region 导入模板下载
#endregion
#region 导入
#endregion
#region 保存
#endregion
private bool CheckIsDecmil(string KeyValue) { try { Decimal.Parse(KeyValue); return true; } catch (Exception ex) { return false; } }
// private void txtUserCode_TextChanged(object sender, EventArgs e)
// {
// #region
// string chksql = @"SELECT UserCode,UserName,StartFlag FROM Sys_User WHERE UserCode='{0}' AND WorkPointCode='{1}' and StartFlag='1' ";
// chksql = string.Format(chksql, this.txtUserCode.Text.Trim(), AppConfig.WorkPointCode);
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
// if (dt.Rows.Count == 0)
// {
// ICSBaseSimpleCode.AppshowMessageBox("该人员不存在或者账号已经停用!!");
// return;
// }
// //else
// //{
// // if (dt.Rows[0]["EATTRIBUTE6"].ToString() == "")
// // {
// // ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!");
// // return;
// // }
// //}
// #endregion
// string LotNo = txtLotNo.Text.Trim();
// string sql = @"SELECT DISTINCT
// a.ID,
// a.LOTNO,
// a.LOTQTY,
// b.MOCODE,
// b.ITEMCODE,
// a.VenderLotNO,
// c.INVNAME AS ItemName,
// d.LOTStatus,
// CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' ELSE 'KG' END AS Status
// FROM
// ICSITEMLot a WITH (nolock)
// LEFT JOIN ICSMO b WITH (nolock) ON a.TransNO = b.MOCODE AND a.TransLine=b.MOSEQ
// LEFT JOIN ICSINVENTORY c WITH (nolock) ON b.ITEMCODE = c.INVCODE
// LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON a.LOTNO = d.LOTNO
// WHERE
// a.LOTNO = '{0}'";
// sql = string.Format(sql, LotNo);
// DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
// if (data.Rows.Count > 0)
// {
// foreach (DataRow dr in data.Rows)
// {
// txtLotNo.Text = dr["LOTNO"].ToString();
// txtItemCode.Text = dr["ITEMCODE"].ToString();
// txtItemName.Text = dr["ItemName"].ToString();
// }
// }
// }
// private void txtLotNo_TextChanged(object sender, EventArgs e)
// {
// #region
// string chksql = @"select LotNO ,b.ISSMT from ICSITEMLot a
// LEFT JOIN ICSINVENTORY b ON a.ItemCODE=b.INVCODE
// where LotNO='{0}' AND a.WorkPoint='{1}'";
// chksql = string.Format(chksql, txtLotNo.Text.Trim(), AppConfig.WorkPointCode);
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
// if (dt.Rows.Count == 0)
// {
// ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号不存在!!");
// return;
// }
// else
// {
// if (dt.Rows[0]["LotNO"].ToString() == "")
// {
// ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!");
// return;
// }
// if (dt.Rows[0]["ISSMT"].ToString() == "1")
// {
// ICSBaseSimpleCode.AppshowMessageBox("该批次产品只能单件报工!!");
// return;
// }
// }
// #endregion
// string LotNo = txtLotNo.Text.Trim();
// string sql = @"SELECT DISTINCT
// a.ID,
// a.LOTNO,
// a.LOTQTY,
// b.MOCODE,
// b.ITEMCODE,
// a.VenderLotNO,
// c.INVNAME AS ItemName,
// d.LOTStatus,
// CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' ELSE 'KG' END AS Status
// FROM
// ICSITEMLot a WITH (nolock)
// LEFT JOIN ICSMO b WITH (nolock) ON a.TransNO = b.MOCODE AND a.TransLine=b.MOSEQ
// LEFT JOIN ICSINVENTORY c WITH (nolock) ON b.ITEMCODE = c.INVCODE
// LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON a.LOTNO = d.LOTNO
// WHERE
// a.LOTNO = '{0}'";
// sql = string.Format(sql, LotNo);
// DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
// if (data.Rows.Count > 0)
// {
// foreach (DataRow dr in data.Rows)
// {
// txtLotNo.Text = dr["LOTNO"].ToString();
// txtItemCode.Text = dr["ITEMCODE"].ToString();
// txtItemName.Text = dr["ItemName"].ToString();
// txtMOCode.Text = dr["MOCODE"].ToString();
// }
// }
// }
//private void txtOPCode_TextChanged(object sender, EventArgs e)
//{
// OPCodeCurrent = this.txtOPCode.Text;
//}
//private void txtMachineCode_TextChanged(object sender, EventArgs e)
//{
//}
private void txtLotNo_KeyPress(object sender, KeyPressEventArgs e)
{ try { #region`
if (e.KeyChar == (char)Keys.Enter) { txtOPCode.Enabled = true; txtUserCode.ReadOnly = false; txtEQPCode.ReadOnly = false; foreach (Control control in tableLayoutPanel2.Controls) { if (control is TextBox && control.Name != "txtLotNo") { TextBox box = control as TextBox; box.Text = ""; } }
#region
// string chksql = @"select LotNO ,a.LOTQTY,b.ISSMT from ICSITEMLot a
// LEFT JOIN ICSINVENTORY b ON a.ItemCODE=b.INVCODE
// where LotNO='{0}' AND a.WorkPoint='{1}'";
string chksql = @"select LotNO ,a.LOTQTY,b.ISSMT from ICSITEMLot a
LEFT JOIN ICSINVENTORY b ON a.MCODE=b.INVCODE where LotNO='{0}' AND a.WorkPoint='{1}'";
chksql = string.Format(chksql, txtLotNo.Text.Trim(), AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0]; if (dt.Rows.Count == 0) { ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号不存在!!"); return; } else { if (dt.Rows[0]["LotNO"].ToString() == "") { ICSBaseSimpleCode.AppshowMessageBox("产品跟踪单号未绑定零件号,请先绑定再发料!!"); return; } if (dt.Rows[0]["ISSMT"].ToString() == "1") { ICSBaseSimpleCode.AppshowMessageBox("该批次产品只能单件报工!!"); return; } } #endregion
string LotNo = txtLotNo.Text.Trim(); txtLONTQty.Text = dt.Rows[0]["LOTQTY"].ToString();
string sql = @"SELECT DISTINCT
a.ID, a.LOTNO, b.MOPLANQTY, a.LOTQTY,d.NGQTY,D.GOODQTY, b.MOCODE,b.MOSEQ, b.ITEMCODE, a.VenderLotNO, c.INVNAME AS ItemName, d.LOTStatus,b.MOPLANQTY,a.EATTRIBUTE5, CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' ELSE 'KG' END AS Status FROM ICSITEMLot a WITH (nolock) LEFT JOIN ICSMO b WITH (nolock) ON a.TransNO = b.MOCODE AND a.TransLine=b.MOSEQ LEFT JOIN ICSINVENTORY c WITH (nolock) ON b.ITEMCODE = c.INVCODE LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON a.LOTNO = d.LOTNO WHERE a.LOTNO = '{0}'";
sql = string.Format(sql, LotNo); DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; string NGQTY = string.Empty; string GOODQTY = string.Empty; string MOQTY = string.Empty;
Decimal _NGQTY = 0; Decimal _LOTQTY = 0; Decimal _GOODQTY = 0; Decimal _MOQTY = 0;
if (data.Rows.Count > 0) { foreach (DataRow dr in data.Rows) { //新增返修条码判断逻辑
txtLotNo.Text = dr["LOTNO"].ToString(); txtItemCode.Text = dr["ITEMCODE"].ToString(); txtItemName.Text = dr["ItemName"].ToString(); this.txtMOCode.Text = dr["MOCODE"].ToString(); NGQTY = dr["NGQTY"].ToString(); GOODQTY = dr["GOODQTY"].ToString(); this.txtMOQty.Text = dr["MOPLANQTY"].ToString();
if (!string.IsNullOrWhiteSpace(GOODQTY)) { _GOODQTY = Decimal.Parse(GOODQTY); } if (!string.IsNullOrWhiteSpace(NGQTY)) { _NGQTY = Decimal.Parse(NGQTY); } if (!string.IsNullOrWhiteSpace(dr["LOTQTY"].ToString())) { _LOTQTY = Decimal.Parse(dr["LOTQTY"].ToString()); } //this.txtLONTQty.Text = (_LOTQTY - _NGQTY - _GOODQTY).ToString();
MOSEQ = dr["MOSEQ"].ToString();
} lotno = this.txtLotNo.Text.Trim(); ItemCode = txtItemCode.Text.Trim(); txtOPCode.SelectAll(); txtOPCode.Focus(); //新增 自动带出当前追踪单进行中的工序
string opcodenew = GetLotNoOp(lotno); if (opcodenew != "") { txtOPCode.Text = opcodenew; txtOPCode_KeyPress(null, new KeyPressEventArgs((char)Keys.Enter)); if (txtMessage.ForeColor == Color.Red) return; txtUserCode.Text = AppConfig.UserCode; txtUserCode_KeyPress(null, new KeyPressEventArgs((char)Keys.Enter)); if (txtMessage.ForeColor == Color.Red) return;
}
SetMessage("", Color.Blue); //button1.Enabled = true;
} else { txtItemCode.Text = ""; txtItemName.Text = ""; txtLotNo.SelectAll(); txtLotNo.Focus(); SetMessage("产品跟踪单号不存在!", Color.Red); this.btnOPOption.Enabled = false; //button1.Enabled = false;
}
SetMessage("产品跟踪单扫码成功!", Color.Blue); this.btnOPOption.Enabled = true;
return; } #endregion
} catch (Exception ex) { SetMessage(ex.Message, Color.Red); } }
private void txtOPCode_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar == (char)Keys.Enter) { string OpCode = txtOPCode.Text.Trim(); OPCodeCurrent = OpCode; string LOTNO = txtLotNo.Text.Trim();
string sql = @"
SELECT DISTINCT a.ID,d.BeginTime, a.OPCode, a.OPDESC,d.LOTQTY, D.NGQTY,D.GOODQTY, b.RouteCode,f.OPSEQ, b.EQPCode, b.EQPName,d.LOTStatus,d.EATTRIBUTE2, CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' WHEN 'COLLECT_END' THEN 'KG' ELSE '' END AS Status, Type,ISNULL(b.EATTRIBUTE1,0) AS EATTRIBUTE1 FROM ICSOP a WITH (nolock) LEFT JOIN ICSMO2User b WITH(nolock) ON a.OPCODE = b.OPCODE LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON b.LOTNO = d.LOTNO and b.OPCODE=d.OPCODE LEFT JOIN ICSEquipment e WITH(nolock) ON b.EQPCode=e.EQPCode LEFT JOIN ICSITEMROUTE2OPLot f ON f.lotno=b.lotno and f.OPCODE=a.OPCODE WHERE b.OPCODE = '{0}' AND b.LOTNO = '{1}'
";
sql = string.Format(sql, OpCode, LOTNO); DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
if (data.Rows.Count > 0) { foreach (DataRow dr in data.Rows) { txtOPCode.Text = dr["OPCODE"].ToString(); txtOPName.Text = dr["OPDESC"].ToString(); RouteCode = dr["RouteCode"].ToString(); txtStopType.Text = dr["EATTRIBUTE2"].ToString(); opseq = dr["OPSEQ"].ToString(); //工序完成
if (dr["Status"].ToString() == "KG") { string OPSEQ = dr["OPSEQ"].ToString();
int _OPSEQ = Int32.Parse(OPSEQ) - 10; if (_OPSEQ == 0) { SetMessage("该工序已经完工,请扫描下道工序!", Color.Red); this.btnOPOption.Enabled = false; return; }
bool isOK = CheckIsOK(_OPSEQ); if (!isOK) { SetMessage("上道工序检验结果不合格,不能开工!", Color.Red); this.btnOPOption.Enabled = false; return; } SetMessage("当前工序已经完工,请扫描下道工序!", Color.Red); this.btnOPOption.Enabled = false; return; //Decimal _LOTQTY = 0;
//Decimal _GOODQTY = 0;
//Decimal _NGQTY = 0;
//if (!string.IsNullOrWhiteSpace(dr["LOTQTY"].ToString()))
//{
// _LOTQTY = Decimal.Parse(dr["LOTQTY"].ToString());
//}
//if (!string.IsNullOrWhiteSpace(dr["GOODQTY"].ToString()))
//{
// _GOODQTY = Decimal.Parse(dr["GOODQTY"].ToString());
//}
//if (!string.IsNullOrWhiteSpace(dr["NGQTY"].ToString()))
//{
// _NGQTY = Decimal.Parse(dr["NGQTY"].ToString());
//}
//if (_LOTQTY <= _GOODQTY + _NGQTY && _LOTQTY > 0)
//{
// SetMessage("当前工序所有数量已经完工,请扫描下道工序!", Color.Red);
// this.btnOPOption.Enabled = false;
// return;
//}
// string sql_ = @"SELECT DISTINCT
// d.LOTQTY,
// D.NGQTY,
// D.GOODQTY,
// a.ID,
// a.OPCODE,
// a.OPDESC
// FROM ICSOP a WITH (nolock)
// LEFT JOIN ICSMO2User b WITH (nolock) ON a.OPCODE = b.OPCODE
// LEFT JOIN ICSLOTSIMULATION d WITH (nolock) ON b.LOTNO = d.LOTNO
// AND b.OPCODE = d.OPCODE
// LEFT JOIN ICSROUTE2OP f ON f.ROUTECODE = b.RouteCode
// AND f.OPCODE = a.OPCODE
// WHERE f.OPSEQ = '" + _OPSEQ + "' AND b.LOTNO = '" + LOTNO + "' AND d.CollectStatus = 'COLLECT_END' ";
// DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql_).Tables[0];
// if (_data != null && _data.Rows.Count > 0)
// {
// //txtLONTQty.Text = _data.Rows[0]["GOODQTY"].ToString();
// //txtLONTQty.Text = _data.Rows[0]["LOTQTY"].ToString();
// //txtUPOPAllQty.Text = _data.Rows[0]["GOODQTY"].ToString();
// }
// else
// {
// SetMessage("上道工序还没有已经完工,请先扫描上道工序!", Color.Red);
// this.btnOPOption.Enabled = false;
// return;
// }
//this.btnOPOption.Enabled = true;
} else if (dr["Status"].ToString() == "WG") { string NGQTY = dr["NGQTY"].ToString(); string GOODQTY = dr["GOODQTY"].ToString(); string LOTStatus = dr["LOTStatus"].ToString(); if (LOTStatus == "暂停") { this.btnPauseBegin.Text = "取消暂停"; }
Decimal _GOODQTY = 0; Decimal _NGQTY = 0; Decimal _LOTQTY = 0;
if (!string.IsNullOrWhiteSpace(GOODQTY)) { _GOODQTY = Decimal.Parse(GOODQTY); } if (!string.IsNullOrWhiteSpace(NGQTY)) { _NGQTY = Decimal.Parse(NGQTY); } if (!string.IsNullOrWhiteSpace(dr["LOTQTY"].ToString())) { _LOTQTY = Decimal.Parse(dr["LOTQTY"].ToString()); } //this.txtLONTQty.Text = (_LOTQTY - _NGQTY - _GOODQTY).ToString();
//Decimal LsaterLontQty = _LOTQTY - _NGQTY - _GOODQTY;
//if (LsaterLontQty <= 0)
//{
// SetMessage("当前工序所有数量已经完工,请扫描下道工序!", Color.Red);
// this.btnOPOption.Enabled = false;
// return;
//}
string OPSEQ = dr["OPSEQ"].ToString(); if (OPSEQ == "10") { //上工序总数
//txtMOQty.Text = "";
} else { int _OPSEQ = Int32.Parse(OPSEQ) - 10; string sql_ = @"SELECT sum(a.LOTQTY) FROM ICSLOTONWIP a
LEFT JOIN ICSROUTE2OP b ON a.ROUTECODE=b.ROUTECODE AND a.OPCODE=b.OPCODE WHERE LOTNO='" + LOTNO + "' AND b.OPSEQ='" + _OPSEQ + "' ";
DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql_).Tables[0]; if (_data != null && _data.Rows.Count > 0) { //txtMOQty.Text = _data.Rows[0][0].ToString();
//this.txtLONTQty.Text = _data.Rows[0][0].ToString();
} bool isOK = CheckIsOK(_OPSEQ); if (!isOK) { SetMessage("上道工序检验结果不合格,不能开工!", Color.Red); this.btnOPOption.Enabled = false; return; } } string sqlAll = @"SELECT SUM( a.GOODQTY) GOODQTY, SUM( a.NGQTY) NGQTY FROM ICSLOTONWIP a
LEFT JOIN ICSROUTE2OP b ON a.ROUTECODE=b.ROUTECODE AND a.OPCODE=b.OPCODE WHERE LOTNO='" + LOTNO + "' AND b.OPCODE='" + OpCode + "' ";
DataTable _dataAll = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlAll).Tables[0];
if (_dataAll != null && _dataAll.Rows.Count > 0) { //txtThisOPOKQty.Text = _dataAll.Rows[0][0].ToString();
//txtThisOPNGQty.Text = _dataAll.Rows[0][1].ToString();
} } else { string OPSEQ = dr["OPSEQ"].ToString(); int _OPSEQ = Int32.Parse(OPSEQ) - 10; if (_OPSEQ == 0) { SetMessage("工序扫码成功!", Color.Blue); this.btnOPOption.Enabled = true; txtUserCode.SelectAll(); txtUserCode.Focus();
#region 根据批批号和员工条码获取当前采集状态
if (sender == null) {
string statussql = @"SELECT
a.ACTIONRESULT,a.UserCodeEnd,b.CollectStatus,b.MUSER, b.LOTStatus FROM ICSLOTONWIP a LEFT JOIN ICSLOTSIMULATION b ON a.LOTNO=b.LOTNO AND a.OPCODE=b.OPCODE AND a.UserCodeBegin=b.MUSER WHERE a.LOTNO = '" + txtLotNo.Text + "' AND a.OPCODE = '" + txtOPCode.Text + "' ORDER BY a.MTIME DESC ";
// AND a.UserCodeBegin = '" + txtUserCode.Text + "'
DataTable statusdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, statussql).Tables[0]; if (statusdt.Rows.Count == 0) { btnOPOption.Text = "开工"; btnPauseBegin.Text = "暂停"; } else { if (statusdt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN") { btnOPOption.Text = "完工"; initCheck(); } else { btnOPOption.Text = "开工"; } if (statusdt.Rows[0]["LOTStatus"].ToString() == "暂停") { btnPauseBegin.Text = "取消暂停"; } else { btnPauseBegin.Text = "暂停"; } } #endregion
} try { GetPLMCKDATA(ItemCode, RouteCode, opseq); } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); return; }
return; }
bool isOK = CheckIsOK(_OPSEQ); if (!isOK) { SetMessage("上道工序检验结果不合格,不能开工!", Color.Red); this.btnOPOption.Enabled = false; return; } Decimal _LOTQTY = 0; Decimal _GOODQTY = 0; Decimal _NGQTY = 0;
if (!string.IsNullOrWhiteSpace(dr["LOTQTY"].ToString())) { _LOTQTY = Decimal.Parse(dr["LOTQTY"].ToString()); } if (!string.IsNullOrWhiteSpace(dr["GOODQTY"].ToString())) { _GOODQTY = Decimal.Parse(dr["GOODQTY"].ToString()); } if (!string.IsNullOrWhiteSpace(dr["NGQTY"].ToString())) { _NGQTY = Decimal.Parse(dr["NGQTY"].ToString()); }
string sql_ = @"SELECT DISTINCT
d.LOTQTY, D.NGQTY, D.GOODQTY, a.ID, a.OPCODE, a.OPDESC FROM ICSOP a WITH (nolock) LEFT JOIN ICSMO2User b WITH (nolock) ON a.OPCODE = b.OPCODE LEFT JOIN ICSLOTSIMULATION d WITH (nolock) ON b.LOTNO = d.LOTNO AND b.OPCODE = d.OPCODE LEFT JOIN ICSROUTE2OP f ON f.ROUTECODE = b.RouteCode AND f.OPCODE = a.OPCODE WHERE f.OPSEQ = '" + _OPSEQ + "' AND b.LOTNO = '" + LOTNO + "' AND d.CollectStatus = 'COLLECT_END' ";
DataTable _data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql_).Tables[0]; if (_data != null && _data.Rows.Count > 0) { txtLONTQty.Text = _data.Rows[0]["GOODQTY"].ToString(); //txtMOQty.Text = _data.Rows[0]["GOODQTY"].ToString();
} else { //20200618
//SetMessage("上道工序还没有完工,请先扫描上道工序!", Color.Red);
//this.btnOPOption.Enabled = false;
//return;
}
//if (string.IsNullOrWhiteSpace(dr["BeginTime"].ToString()))
//{
// SetMessage("工序扫码成功!", Color.Blue);
// this.btnOPOption.Enabled = true;
// txtUserCode.SelectAll();
// txtUserCode.Focus();
// //initCheck();
// return;
//}
} } txtUserCode.SelectAll(); txtUserCode.Focus();
SetMessage("工序扫描成功!", Color.Blue); this.btnOPOption.Enabled = true; IsWriteAll();
#region 根据批批号和员工条码获取当前采集状态
if (sender == null) { string statussql = @"SELECT
a.ACTIONRESULT,a.UserCodeEnd,b.CollectStatus,b.MUSER, b.LOTStatus FROM ICSLOTONWIP a LEFT JOIN ICSLOTSIMULATION b ON a.LOTNO=b.LOTNO AND a.OPCODE=b.OPCODE AND a.UserCodeBegin=b.MUSER WHERE a.LOTNO = '" + txtLotNo.Text + "' AND a.OPCODE = '" + txtOPCode.Text + "' ORDER BY a.MTIME DESC ";
// AND a.UserCodeBegin = '" + txtUserCode.Text + "'
DataTable statusdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, statussql).Tables[0]; if (statusdt.Rows.Count == 0) { btnOPOption.Text = "开工"; btnPauseBegin.Text = "暂停"; } else { if (statusdt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN") { btnOPOption.Text = "完工"; initCheck(); } else { btnOPOption.Text = "开工"; } if (statusdt.Rows[0]["LOTStatus"].ToString() == "暂停") { btnPauseBegin.Text = "取消暂停"; } else { btnPauseBegin.Text = "暂停"; } } #endregion
} try { GetPLMCKDATA(ItemCode, RouteCode, opseq); } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); return; } //initCheck();
} else { txtOPName.Text = ""; txtEQPCode.Text = ""; txtMachineName.Text = ""; txtOPCode.SelectAll(); txtOPCode.Focus(); SetMessage("该批次工序对应的派工信息不存在!", Color.Red); this.btnOPOption.Enabled = false; } } } catch (Exception ex) { SetMessage(ex.Message, Color.Red); this.btnOPOption.Enabled = false; } }
private void IsWriteAll() { if (!string.IsNullOrEmpty(txtOPName.Text) && !string.IsNullOrEmpty(txtUserName.Text) && !string.IsNullOrEmpty(txtMachineName.Text)) { txtOPCode.Enabled = true; txtUserCode.ReadOnly = true; txtEQPCode.ReadOnly = true; } }
private void initCheck() { string _OQCSql = @"SELECT a.SetValueMax,a.SetValueMin,a.CKGROUPCode,b.CKGROUPDESC,b.CKGROUPDNAME,'' Remark,'' CheckResult,standvalue as standresult,CAST (ISNULL(0, 0) AS BIT) AS OK,CAST (ISNULL(0, 0) AS BIT) AS NG,ptype, a.id FROM ICSOQCCKLIST a
LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP WHERE INVCode='" + txtItemCode.Text + "' AND a.CKGROUPATTR='量化' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH='工序检验' ";//0906
DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0]; _OQCdt.PrimaryKey = new DataColumn[] { _OQCdt.Columns["id"] }; List<DataRow> list = _OQCdt.AsEnumerable().Where(a => Convert.ToDecimal(a["ptype"]) > 1).ToList();
if (list.Count > 0) { foreach (DataRow row in list) { int num = Convert.ToInt32(row["ptype"]); for (int i = 0; i < num; i++) { DataRow newrow = _OQCdt.NewRow(); newrow["SetValueMax"] = row["SetValueMax"]; newrow["SetValueMin"] = row["SetValueMin"]; newrow["CKGROUPCode"] = row["CKGROUPCode"]; newrow["CKGROUPDESC"] = row["CKGROUPDESC"]; newrow["CKGROUPDNAME"] = row["CKGROUPDNAME"]; newrow["Remark"] = row["Remark"]; newrow["CheckResult"] = row["CheckResult"]; newrow["standresult"] = row["standresult"]; newrow["OK"] = row["OK"]; newrow["NG"] = row["NG"]; newrow["ptype"] = "1"; newrow["id"] = AppConfig.GetGuid(); _OQCdt.Rows.Add(newrow); } _OQCdt.Rows.Remove(row);
}
} gridControlcc.DataSource = _OQCdt;
string _OQCWGSql = @"SELECT a.CKGROUPATTR,a.CKGROUPMETH,a.CKGROUPCode CKGROUPCode1,b.CKGROUPDESC CKGROUPDESC1,b.CKGROUPDNAME,'' AS Remark1,CAST (ISNULL(0, 0) AS BIT) AS OK ,
CAST (ISNULL(0, 0) AS BIT) AS NG,ptype,a.id FROM ICSOQCCKLIST a LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP WHERE INVCode='" + txtItemCode.Text + "' AND a.CKGROUPATTR='外观' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH='工序检验' ";//0906
DataTable _OQCWGdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCWGSql).Tables[0]; _OQCWGdt.PrimaryKey = new DataColumn[] { _OQCWGdt.Columns["id"] }; list = _OQCWGdt.AsEnumerable().Where(a => Convert.ToDecimal(a["ptype"]) > 1).ToList();
if (list.Count > 0) { foreach (DataRow row in list) { int num = Convert.ToInt32(row["ptype"]); for (int i = 0; i < num; i++) { DataRow newrow = _OQCWGdt.NewRow(); newrow["CKGROUPATTR"] = row["CKGROUPATTR"]; newrow["CKGROUPMETH"] = row["CKGROUPMETH"]; newrow["CKGROUPCode1"] = row["CKGROUPCode1"]; newrow["CKGROUPDESC1"] = row["CKGROUPDESC1"]; newrow["CKGROUPDNAME"] = row["CKGROUPDNAME"]; newrow["Remark1"] = row["Remark1"]; newrow["OK"] = row["OK"]; newrow["ptype"] = "1"; newrow["id"] = AppConfig.GetGuid(); _OQCWGdt.Rows.Add(newrow); } _OQCWGdt.Rows.Remove(row);
}
}
gridControl2.DataSource = _OQCWGdt; }
private bool CheckIsOK(int OPSEQ) { bool isfalse = false; string _OQCSql ="";
_OQCSql = @"SELECT DISTINCT ACTION FROM ICSLOTONWIP bb WITH (nolock)
LEFT JOIN ICSLOTONWIPCHECK CC ON BB.ID=CC.ONWIPID INNER JOIN ICSITEMROUTE2OPLot a WITH (nolock) ON bb.lotno=a.lotno and bb.opcode=a.opcode WHERE bb.LotNo='" + txtLotNo.Text + "' AND a.OPSEQ='" + OPSEQ + "' AND CC.RESULT='不合格' ";
DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0];
if (_OQCdt != null && _OQCdt.Rows.Count > 0) { isfalse = false; //foreach (DataRow item in _OQCdt.Rows)
//{
// if (item["CCorWGResult"].ToString() == "NG")
// {
// isfalse = false;
// SetMessage("上道工序检验结果不合格,不能开工!", Color.Red);
// this.btnOPOption.Enabled = false;
// return isfalse;
// }
//}
} else { isfalse = true; } return isfalse; }
private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) {
string chksql = @"SELECT UserCode,UserName,StartFlag FROM Sys_User WHERE UserCode='{0}' AND WorkPointCode='{1}' and StartFlag='1' "; chksql = string.Format(chksql, this.txtUserCode.Text.Trim(), AppConfig.WorkPointCode); DataTable chkdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, chksql).Tables[0];
if (chkdt.Rows.Count == 0) { ICSBaseSimpleCode.AppshowMessageBox("该人员不存在或者账号已经停用!!"); this.btnOPOption.Enabled = false; return; }
if (txtLotNo.Text.Trim() != "") { string JNsql = @"SELECT DISTINCT a.OPCODE, a.UserCode
FROM ICSOP2User a WHERE 1 = 1 AND a.UserCode='" + this.txtUserCode.Text + "' AND a.OPCODE='" + this.txtOPCode.Text + "' ORDER BY a.OPCODE ";
DataTable JNdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, JNsql).Tables[0]; if (JNdt.Rows.Count == 0 || JNdt == null) { SetMessage("该人员:" + this.txtUserCode.Text + "对应工序:" + txtOPCode.Text + ",不存在,请先维护!", Color.Red); this.btnOPOption.Enabled = false; return; }
string LotNo = txtLotNo.Text.Trim(); string UserCode = txtUserCode.Text.Trim(); string sql = @"SELECT UserCode,UserName,StartFlag FROM Sys_User WHERE UserCode='{0}' AND WorkPointCode='{1}' and StartFlag='1' "; sql = string.Format(sql, UserCode, AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0]; if (dt.Rows.Count == 0) { SetMessage("员工条码不存在,请确认后重新输入!", Color.Red); this.btnOPOption.Enabled = false; txtUserCode.SelectAll(); txtUserCode.Focus(); return; } else {
txtUserName.Text = dt.Rows[0]["UserName"].ToString(); #region 根据批批号和员工条码获取当前采集状态
string statussql = @"SELECT
a.ACTIONRESULT,a.UserCodeEnd,b.CollectStatus,b.MUSER, b.LOTStatus FROM ICSLOTONWIP a LEFT JOIN ICSLOTSIMULATION b ON a.LOTNO=b.LOTNO AND a.OPCODE=b.OPCODE AND a.UserCodeBegin=b.MUSER WHERE a.LOTNO = '" + txtLotNo.Text + "' AND a.OPCODE = '" + txtOPCode.Text + "' ORDER BY a.MTIME DESC ";
// AND a.UserCodeBegin = '" + txtUserCode.Text + "'
statussql = string.Format(statussql, LotNo, UserCode); DataTable statusdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, statussql).Tables[0]; if (statusdt.Rows.Count == 0) { btnOPOption.Text = "开工"; btnPauseBegin.Text = "暂停"; } else { if (statusdt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN") { btnOPOption.Text = "完工"; initCheck(); } else { btnOPOption.Text = "开工"; } if (statusdt.Rows[0]["LOTStatus"].ToString() == "暂停") { btnPauseBegin.Text = "取消暂停"; } else { btnPauseBegin.Text = "暂停"; } } #endregion
} txtEQPCode.SelectAll(); txtEQPCode.Focus(); SetMessage("员工条码扫描成功!", Color.Blue); IsWriteAll(); this.btnOPOption.Enabled = true;
return; } else { string UserCode = txtUserCode.Text.Trim(); string sql = @"SELECT UserCode,UserName,StartFlag FROM Sys_User WHERE UserCode='{0}' AND WorkPointCode='{1}' and StartFlag='1' "; sql = string.Format(sql, UserCode, AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0]; if (dt.Rows.Count == 0) { SetMessage("员工条码不存在,请确认后重新输入!", Color.Red); this.btnOPOption.Enabled = false; txtUserCode.SelectAll(); txtUserCode.Focus(); return; } else {
txtUserName.Text = dt.Rows[0]["UserName"].ToString(); SetMessage("员工条码扫描成功!", Color.Blue); txtEQPCode.SelectAll(); txtEQPCode.Focus(); } } } }
//消息提示
private void SetMessage(string Msg, Color color) { txtMessage.Text = Msg; txtMessage.ForeColor = color; }
public class SearchPart { /// <summary>
/// 关键字
/// </summary>
public string ItemCode { get; set; } public int size { get; set; } /// <summary>
/// 可以通过扩展字段参数,指定需要额外获取的字段清单
/// </summary>
public string extra { get; set; } public string routecode { get; set; } public string opseq { get; set; } }
#region 开工
//消息提示
private void SetMsg(Color color, string Msg) { txtMessage.Text = Msg; txtMessage.ForeColor = color; } #region 检查输入数据
public string check() { string msg = ""; if (txtUserName.Text.Trim() == "") { msg += "请重新扫描员工条码!\n"; } if (txtLotNo.Text.Trim() == "") { msg += "请重新扫描产品批号!\n"; } if (txtOPCode.Text.Trim() == "") { msg += "请重新扫描工序条码!\n"; } if (txtUserCode.Text.Trim() == "") { msg += "请重新扫描人员条码!\n"; } if (txtEQPCode.Text.Trim() == "") { msg += "请重新扫描设备条码!\n"; } if (txtMachineName.Text.Trim() == "") { msg += "请重新扫描设备条码!\n"; } return msg; } #endregion
/// 0906获取单据号
public static string GetSerialCode(string connectString, string tbName, string colName, string Pre, int numLen) { string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}"; sql = string.Format(sql, new object[] { "",tbName, colName, Pre, numLen}); return DBHelper.ExecuteScalar(connectString, CommandType.Text, sql).ToString(); }
//0913不合格传入NCR
private void SendNCR(List<string> codeList, string strResult, decimal QTY, string itemcode, string mocode, string OPCODE, string LotNo) {//
try { string codeStr = ""; foreach (string str in codeList) { codeStr += str + ","; } codeStr = codeStr.TrimEnd(','); string NewCartonNo = "NCR" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd"); NewCartonNo = GetSerialCode(AppConfig.FrameConnectString, "ICSNCRDoc", "SecDocNO", NewCartonNo, 3); ICSSecDocType secDocType = ICSSecDocTypeBLL.select("QC_Collect", AppConfig.FrameConnectString);
#region 20210816
//获取对应的接收人和抄送人
//ICSSecDocTypeStep docTypeStep = ICSSecDocTypeStepBLL.selectStepBySeq(secDocType.guid, "1", AppConfig.FrameConnectString);
//string ToUserList = "";
//ToUserList = ICSNCRDocBLL.QualityEngineer(CKType, AppConfig.AppConnectString);
#endregion
//string CCUserList = ICSNCRDocBLL.QualityEngineer("经理", AppConfig.AppConnectString);
//string sql = @"SELECT a.ProjectCode FROM ICSMO a WHERE a.MOCODE='{0}'";
//sql = string.Format(sql, mocode);
//DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
string ProjectCode = ""; //if (dt != null && dt.Rows.Count > 0)
//{
// ProjectCode = dt.Rows[0]["ProjectCode"].ToString();
//}
ICSNCRDoc SecDoc = new ICSNCRDoc(); SecDoc.SecDocNO = NewCartonNo; SecDoc.SecDocType = secDocType.guid; SecDoc.SecDocStatus = "已发送"; SecDoc.SecDocSeq = 1; SecDoc.SecDocCreateUser = AppConfig.UserCode; SecDoc.SecDocCreateUserName = AppConfig.UserName; SecDoc.SecDocCreateTime = AppConfig.GetSeverDateTime(""); //SecDoc.ErrorType = CKType;
SecDoc.ErrorType = "自检";//modify on 20230317 NCRtype修改
SecDoc.EQPCode = ""; SecDoc.ItemCode = itemcode; SecDoc.ProjectCode = ProjectCode; SecDoc.TimeLimit = "1"; SecDoc.ContentDesc = strResult; // SecDoc.EATTRIBUTE2 = CKType;
//SecDoc.ToUserList = ToUserList;
//SecDoc.CCUserList = CCUserList;
//SecDoc.ToUserList = ToUserList;
//SecDoc.CCUserList = CCUserList;
SecDoc.LOTNO = LotNo; SecDoc.OPCode = OPCODE; SecDoc.SecDocOKTime = Convert.ToDateTime("1990-01-01"); SecDoc.Qty = QTY; SecDoc.SrcDocInfo = LotNo;
ICSNCRDoc NCR = new ICSNCRDoc(); // NCR = ICSNCRDocBLL.selectBySrcDocInfo(codeStr, AppConfig.AppConnectString);
NCR = null;//modify on 20200418
if (NCR == null) { ICSNCRDocBLL.CreateNCR(SecDoc, AppConfig.AppConnectString); } else { MessageBox.Show(codeStr + "已产生NCR单号:" + NCR.SecDocNO + ",不能新增NCR单"); }
} catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary>
/// 点击开工/完工
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOPOption_Click(object sender, EventArgs e) { SetMsg(Color.Blue, ""); var FXSTATUS = false; string msg = check(); if (msg != "") { SetMsg(Color.Red, msg); return; }
///////////////////////////////////////////////////0906
List<string> codeList = new List<string>(); string strResult = ""; decimal QTY = 1;//批次数量
///////////////////////////////////////////////////0906
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在处理...请稍等..."); try { _wait.Show(); string OpCode = txtOPCode.Text.Trim(); string LOTNO = txtLotNo.Text.Trim(); string sql = @"SELECT DISTINCT
a.ID, a.OPCODE, a.OPDESC, b.RouteCode, b.EQPCode, b.EQPName,d.LOTStatus, CASE d.CollectStatus WHEN 'COLLECT_BEGIN' THEN 'WG' ELSE 'KG' END AS Status, E.Type,ISNULL(b.EATTRIBUTE1,0) AS EATTRIBUTE1,f.eattribute5 FROM ICSOP a WITH (nolock) LEFT JOIN ICSMO2User b WITH(nolock) ON a.OPCODE = b.OPCODE LEFT JOIN ICSLOTSIMULATION d WITH(nolock) ON b.LOTNO = d.LOTNO and b.OPCODE=d.OPCODE LEFT JOIN ICSEquipment e WITH(nolock) ON b.EQPCode=e.EQPCode LEFT JOIN ICSITEMLOT f on d.lotno=f.lotno WHERE b.OPCODE = '{0}' AND b.LOTNO = '{1}'";
sql = string.Format(sql, OpCode, LOTNO); DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (data.Rows.Count > 0) { foreach (DataRow dr in data.Rows) { if (dr["EATTRIBUTE1"].ToString() == "1") { txtOPName.Text = ""; txtEQPCode.Text = ""; txtMachineName.Text = ""; Status = ""; routeCode = ""; EQPType = ""; txtOPCode.SelectAll(); txtOPCode.Focus(); _wait.Close(); SetMsg(Color.Red, "所扫描的工序为委外工序,无法开工,请确认!"); return; } } } //返修条码提示
sql = "select eattribute5 from icsitemlot where lotno='"+ LOTNO+"'"; data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (data.Rows.Count > 0 && data.Rows[0]["eattribute5"].ToString() == "返修中") { if (ICSBaseSimpleCode.AppshowMessageBoxRepose("该条码是返修条码,是否返修完成?") != DialogResult.OK) { _wait.Close(); return; } else { FXSTATUS = true; } } #region simulation
ICSLOTSIMULATION simulationNew = new ICSLOTSIMULATION(); simulationNew.MUSER = txtUserCode.Text.Trim(); simulationNew.LOTNO = txtLotNo.Text.Trim(); simulationNew.OPCODE = txtOPCode.Text.Trim(); simulationNew.EQPCODE = txtEQPCode.Text.Trim(); simulationNew.SHELFNO = ""; if (FXSTATUS) simulationNew.SHELFNO = "返修完成";
#endregion
List<ICSOQCCKGROUP2LISTCheckResult> entityList = new List<ICSOQCCKGROUP2LISTCheckResult>(); ICSQualityCKDATA QualityCKDATA = new ICSQualityCKDATA(); if (btnOPOption.Text.Trim().Equals(START)) { simulationNew.EATTRIBUTE1 = "COLLECT_BEGIN"; } else { //0826注释
//if (gridViewCC.DataRowCount == 0 || gridView2.DataRowCount == 0)
//{
// SetMsg(Color.Red, "没有维护自检信息,请确认!");
// _wait.Close();
// return;
//}
#region 完工 检验上道工序是否有不合格的
QualityCKDATA.EATTRIBUTE3 = "";//参与人
QualityCKDATA.LOTNO =""; QualityCKDATA.OPCode = this.txtOPCode.Text.Trim(); QualityCKDATA.MOCODE = txtMOCode.Text.Trim(); QualityCKDATA.CKUserCode = txtUserCode.Text.Trim(); QualityCKDATA.Type = "GX"; if ((txtCCResult.Text == "OK"||gridViewCC.RowCount<=0) && (txtWGResult.Text == "OK"|| gridView2.RowCount <= 0)) { QualityCKDATA.CKResult = "1"; } else { QualityCKDATA.CKResult = "0"; //QualityCKDATA.LOTNO = txtLotNo.Text;
} if (gridViewCC.RowCount <= 0) {
} else { for (int k = 0; k < gridViewCC.RowCount; k++) { ICSOQCCKGROUP2LISTCheckResult entity = new ICSOQCCKGROUP2LISTCheckResult(); #region MyRegion
Decimal OKQty = 0; Decimal NGQty = 0;
if (gridViewCC.RowCount > 0) { if (string.IsNullOrWhiteSpace(txtCCResult.Text)) { ICSBaseSimpleCode.AppshowMessageBox("尺寸还没有检验!!!"); _wait.Close(); return; } if (string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString())) { ICSBaseSimpleCode.AppshowMessageBox("存在未填写的检验值!请确认!"); _wait.Close(); return; } string ok = gridViewCC.GetRowCellValue(k, CCOK).ToString(); string ng = gridViewCC.GetRowCellValue(k, CCNG).ToString(); if ((string.IsNullOrEmpty(ok) && string.IsNullOrEmpty(ng) || (ok == "False" && ng == "False"))) { ICSBaseSimpleCode.AppshowMessageBox("存在检验项目未勾选合格或不合格!请确认!"); _wait.Close(); return; } } //entity.CKITEMCODE = txtUserName.Text;// gridViewCC.GetRowCellValue(k, colCKITEMCODE).ToString();
///0826 设置尺寸检验------------------------------------------------------------------
entity.CKListCode = gridViewCC.GetRowCellValue(k, colCKGROUPCode).ToString(); entity.RCVCode = RCVCode; entity.INVDESC = INVDESC; entity.CheckoutAttribute = "量化"; entity.GXorWWCheck = "GX"; entity.VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()); entity.VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()); entity.CheckResultValue = gridViewCC.GetRowCellValue(k, colCheckResult).ToString(); if (txtCCResult.Text == "OK") { entity.Qualified = Decimal.Parse(txtLONTQty.Text);//合格数
} else { entity.UnQualified = Decimal.Parse(txtLONTQty.Text); ;//不合格数
} entity.CCorWGResult = txtCCResult.Text; entity.LotNo = txtLotNo.Text; entity.UserCode = this.txtUserCode.Text; entity.MOCode = this.txtMOCode.Text; entity.OPCode = this.txtOPCode.Text; entityList.Add(entity); } } if (gridView2.RowCount <= 0) { } else { for (int k = 0; k < gridView2.RowCount; k++) { ICSOQCCKGROUP2LISTCheckResult entity = new ICSOQCCKGROUP2LISTCheckResult(); #region MyRegion
if (gridView2.RowCount > 0) { if (string.IsNullOrWhiteSpace(txtWGResult.Text)) {
ICSBaseSimpleCode.AppshowMessageBox("外观还没有检验!!!"); _wait.Close(); return; } } #endregion
//entity.CKITEMCODE = txtUserName.Text;// gridViewCC.GetRowCellValue(k, colCKITEMCODE).ToString();
entity.CKListCode = gridView2.GetRowCellValue(k, colCKGROUPCode1).ToString(); entity.RCVCode = RCVCode; entity.INVDESC = INVDESC; entity.GXorWWCheck = "GX"; entity.CheckoutAttribute = "外观"; entity.CCorWGResult = txtWGResult.Text;
entity.AQL = gridView2.GetRowCellValue(k, colCKGROUPATTR).ToString(); entity.InspectionStandard = gridView2.GetRowCellValue(k, colCKGROUPMETH).ToString();
if (gridView2.GetRowCellValue(k, colOK).ToString() == "True") { entity.IsOK = 1; } if (gridView2.GetRowCellValue(k, colNG).ToString() == "True") { //entity.IsOK = 1;
entity.IsOK = 0; } //else
//{
// entity.IsOK = 0;
//}
if (txtWGResult.Text == "OK") { entity.Qualified = Decimal.Parse(txtLONTQty.Text);//合格数
} else { entity.UnQualified = Decimal.Parse(txtLONTQty.Text); ;//不合格数
} entity.LotNo = txtLotNo.Text; entity.UserCode = this.txtUserCode.Text; entity.MOCode = this.txtMOCode.Text; entity.OPCode = this.txtOPCode.Text; entityList.Add(entity); #endregion
} } #endregion
simulationNew.EATTRIBUTE1 = "COLLECT_END"; } ICSCollectBLL.Save(AppConfig.AppConnectString, simulationNew); SetMsg(Color.Blue, btnOPOption.Text.Trim() + "成功!"); if (entityList != null && btnOPOption.Text == "完工") { ICSDataCollectionBLL.AddAndEditList(QualityCKDATA, entityList, AppConfig.AppConnectString, false); } ////////////////////////////////////////////////////////////////////0906判退到NCR
if (QualityCKDATA.CKResult == "0") { string itemcode = txtItemCode.Text; string OPCODE = txtOPCode.Text; string MOCODE = txtMOCode.Text; QTY = Convert.ToDecimal(txtLONTQty.Text); LotNo = txtLotNo.Text; if (!codeList.Contains(LotNo)) { strResult += "产品追踪单:" + LotNo + " " + CCNCRMes() + " " + WWNCRMes(); codeList.Add(LotNo); } SendNCR(codeList, strResult, QTY, itemcode, MOCODE, OpCode, LotNo); ////////////////////////////////////0906判退到NCR
} ClearTxt(); if (btnOPOption.Text.Trim().Equals(START)) { btnOPOption.Text = END; } else { btnOPOption.Text = START; } _wait.Close(); txtOPCode.Enabled = true; txtUserCode.ReadOnly = false; txtEQPCode.ReadOnly = false; } catch (Exception ex) { _wait.Close(); SetMsg(Color.Red, ex.Message); } }
#endregion
#region 任务暂停、取消暂停
private void btnPauseBegin_Click(object sender, EventArgs e) { if (btnPauseBegin.Text.Trim().Equals(PAUSE)) { Pause(); } else { CancelPause(); } } #region 取消暂停
private void CancelPause() { try {
if (txtLotNo.Text.Trim() == "" || txtOPCode.Text.Trim() == "" || txtUserCode.Text.Trim() == "" || txtEQPCode.Text.Trim() == "") { SetMsg(Color.Red, "请先扫描批次信息!"); return; }
#region simulation
ICSLOTSIMULATION simulationNew = new ICSLOTSIMULATION(); simulationNew.MUSER = txtUserCode.Text.Trim(); simulationNew.MUSERName = txtUserName.Text.Trim(); simulationNew.LOTNO = txtLotNo.Text.Trim(); simulationNew.OPCODE = txtOPCode.Text.Trim(); simulationNew.EQPCODE = txtEQPCode.Text.Trim(); #endregion
ICSCollectBLL.CancelPause(AppConfig.AppConnectString, simulationNew); SetMsg(Color.Blue, "取消暂停成功!"); btnPauseBegin.Text = PAUSE; //clear();
//ClearTxt();
this.txtStopType.Text = ""; this.txtStopCode.Text = "";
} catch (Exception ex) { SetMsg(Color.Red, ex.Message); } } //private void clear()
//{
// try
// {
// txtUserCode.Text = "";
// txtUserName.Text = "";
// txtItemCode.Text = "";
// txtLotNO.Text = "";
// txtLotNo.Text = "";
// txtMoCode.Text = "";
// txtItemName.Text = "";
// txtOpCode.Text = "";
// txtOpName.Text = "";
// txtKeyPart.Text = "";
// txtEQPCode.Text = "";
// txtEQPName.Text = "";
// txtInvLotFurnace.Text = "";
// txtEQPCode.Text = "";
// txtRealEQPName.Text = "";
// txtMemo.Text = "";
// }
// catch (Exception ex)
// {
// SetMsg(Color.Red, ex.Message);
// }
//}
#endregion
private void Pause() { try { if (string.IsNullOrWhiteSpace(this.txtStopType.Text)) { SetMsg(Color.Red, "请先选择暂停类型!"); return; } if (txtLotNo.Text.Trim() == "" || txtOPCode.Text.Trim() == "" || txtUserCode.Text.Trim() == "" || txtEQPCode.Text.Trim() == "") { SetMsg(Color.Red, "请先扫描批次信息!"); return; }
#region simulation
ICSLOTSIMULATION simulationNew = new ICSLOTSIMULATION(); simulationNew.MUSER = txtUserCode.Text.Trim(); simulationNew.MUSERName = txtUserName.Text.Trim(); simulationNew.LOTNO = txtLotNo.Text.Trim(); simulationNew.OPCODE = txtOPCode.Text.Trim(); simulationNew.EQPCODE = txtEQPCode.Text.Trim();
simulationNew.EATTRIBUTE2 = txtStopCode.Text.Trim();
#endregion
ICSCollectBLL.Pause(AppConfig.AppConnectString, simulationNew); SetMsg(Color.Blue, "暂停成功!");
btnPauseBegin.Text = CANCELPAUSE; } catch (Exception ex) { SetMsg(Color.Red, ex.Message); } } #endregion
#region 工序结束
private void button4_Click_bak(object sender, EventArgs e) {
} #endregion
#region 退出
private void button5_Click(object sender, EventArgs e) { AppConfig.CloseFormShow(this.Text); this.Close(); } #endregion
public void FormClear() { foreach (Control control in panel1.Controls) { if (control is TextBox) { ((TextBox)control).Text = ""; } } foreach (Control control in panel2.Controls) { if (control is TextBox) { ((TextBox)control).Text = ""; } }
txtLotNo.Focus(); //grvdt.Clear();
//connectgrvdt.Clear();
}
private void btnEnlargeTZ_Click(object sender, EventArgs e) { FileDrawing.Enlarge(axAcroPDF); }
private void txtStopType_EditValueChanged(object sender, EventArgs e) { string sql1 = @"SELECT DISTINCT EnumValue [暂停类型编码] ,EnumText [暂停类型] FROM Sys_EnumValues WHERE EnumKey='00022' and WorkPointCode='" + AppConfig.WorkPointCode + "' and EnumText='" + txtStopType.Text + "' "; sql1 = string.Format(sql1, AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql1).Tables[0]; if (dt != null && dt.Rows.Count > 0) { txtStopType.Text = dt.Rows[0]["暂停类型"].ToString(); txtStopCode.Text = dt.Rows[0]["暂停类型编码"].ToString(); } }
private void FormICSProductionReport_Activated(object sender, EventArgs e) { this.txtLotNo.Focus(); }
private void ClearTxt() { txtLotNo.Text = ""; txtOPCode.Text = ""; txtUserCode.Text = ""; txtUserName.Text = ""; txtEQPCode.Text = ""; txtMOCode.Text = "";
txtOPName.Text = ""; txtItemCode.Text = ""; txtItemName.Text = ""; txtMachineName.Text = ""; txtLONTQty.Text = ""; txtMOQty.Text = ""; txtThisOPOKQty.Text = ""; txtThisOPNGQty.Text = ""; //txtMachineCode1.Text = "";
//txtMachineName1.Text = "";
//txtMachineCode2.Text = "";
//txtMachineName2.Text = "";
//txtOKQty.Text = "";
//txtNGQty.Text = "";
gridControlcc.DataSource = null; gridControl2.DataSource = null; }
#region 设备
private void txtMachineCode_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar == (char)Keys.Enter) { string sql = @"SELECT EQPName FROM ICSEquipment (NOLOCK) WHERE EQPCode='" + txtEQPCode.Text + "' AND WorkPoint='" + AppConfig.WorkPointCode + "'"; DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt2 != null && dt2.Rows.Count > 0) { txtMachineName.Text = dt2.Rows[0][0].ToString(); SetMessage("设备扫描成功", Color.Blue); IsWriteAll(); } else { SetMessage("输入的设备编码:" + txtEQPCode.Text + ",有误,请核对数据", Color.Red); return; } } } catch (Exception ex) { SetMessage(ex.Message, Color.Red); return; }
} #endregion
private void txtMachineCode1_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar == (char)Keys.Enter) { string sql = @"SELECT EQPName FROM ICSEquipment (NOLOCK) WHERE EQPCode='" + txtEQPCode.Text + "' AND WorkPoint='" + AppConfig.WorkPointCode + "'"; DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; if (dt2 != null && dt2.Rows.Count > 0) { txtMachineName.Text = dt2.Rows[0][0].ToString(); SetMessage("设备扫描成功", Color.Blue); this.btnOPOption.Enabled = true; } else { SetMessage("输入的设备编码:" + txtEQPCode.Text + ",有误,请核对数据", Color.Red); this.btnOPOption.Enabled = false; return; } } } catch (Exception ex) { SetMessage(ex.Message, Color.Red); return; } }
//private void txtMachineCode2_KeyPress(object sender, KeyPressEventArgs e)
//{
// try
// {
// if (e.KeyChar == (char)Keys.Enter)
// {
// string sql = @"SELECT EQPName FROM ICSEquipment (NOLOCK) WHERE EQPCode='" + txtMachineCode2.Text + "' AND WorkPoint='" + AppConfig.WorkPointCode + "'";
// DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
// if (dt2 != null && dt2.Rows.Count > 0)
// {
// txtMachineName.Text = dt2.Rows[0][0].ToString();
// SetMessage("设备扫描成功", Color.Blue);
// }
// else
// {
// SetMessage("输入的设备编码:" + txtEQPCode.Text + ",有误,请核对数据", Color.Red);
// return;
// }
// }
// }
// catch (Exception ex)
// {
// SetMessage(ex.Message, Color.Red);
// return;
// }
//}
private void txtIsReturnItem_CheckedChanged(object sender, EventArgs e) { //if (this.txtIsReturnItem.Checked == true)
//{
// this.labelControl2.Text = "退料数量";
// this.txtReturnMateralSave.Visible = true;
// labelControl1.Visible = true;
// txtSBItemCode.Visible = true;
// labelControl2.Visible = true;
// txtSBItemCodeQty.Visible = true;
//}
//else
//{
// this.labelControl2.Text = "发料数量";
// this.txtReturnMateralSave.Visible = false;
// labelControl1.Visible = false;
// txtSBItemCode.Visible = false;
// labelControl2.Visible = false;
// txtSBItemCodeQty.Visible = false;
//}
}
#region 工序上料退料
#endregion
/// <summary>
/// 操作手册
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e) { }
private void gridViewCC_KeyUp(object sender, KeyEventArgs e) { #region
try { if (e.KeyCode == Keys.Enter) { if (gridViewCC.FocusedRowHandle < 0) { return; }
#region colS1
int SNo = gridViewCC.FocusedRowHandle; int SNoCC = gridViewCC.RowCount;
for (int i = SNo; i <= SNo; i++) { SendKeys.Send("{Down}"); if (SNo == SNoCC - 1) { for (int j = 0; j <= SNoCC - 1; j++) { SendKeys.Send("{Up}"); } SendKeys.Send("{RIGHT}"); } //bool istrue = false;
//for (int k = 0; k < gridViewCC.RowCount; k++)
//{
// #region MyRegion
// Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
// if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
// {
// _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
// }
// }
// if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
// {
// _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
// }
// }
// if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
// {
// _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
// }
// }
// if ((_S1 < _VALUEMIN || _S1 > _VALUEMAX) && gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
// {
// istrue = false;
// break;
// }
// else
// {
// istrue = true;
// }
// #endregion
//}
//if (istrue)
//{
// this.txtCCResult.Text = "OK";
// this.txtCCResult.BackColor = Color.Blue;
//}
//else
//{
// this.txtCCResult.Text = "NG";
// this.txtCCResult.BackColor = Color.Red;
//}
}
#endregion
} } catch (Exception ex) { throw new Exception(ex.ToString()); }
#endregion
}
private void gridView2_KeyUp(object sender, KeyEventArgs e) {
}
private void txtIsReturnItem_CheckedChanged_1(object sender, EventArgs e) { if (this.txtIsReturnItem.Checked == true) { this.labelControl2.Text = "退料数量"; this.txtReturnMateralSave.Visible = true;
labelControl1.Visible = true; txtSBItemCode.Visible = true; labelControl2.Visible = true; txtSBItemCodeQty.Visible = true; } else { this.labelControl2.Text = "发料数量"; this.txtReturnMateralSave.Visible = false;
labelControl1.Visible = false; txtSBItemCode.Visible = false; labelControl2.Visible = false; txtSBItemCodeQty.Visible = false; } }
private void txtReturnMateralSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(this.txtSBItemCode.Text) || string.IsNullOrWhiteSpace(this.txtSBItemCodeQty.Text)) { SetMessage("退料编码或者退料数量不能为空", Color.Red); return; }
string sqlUpOPDetail = @"SELECT DISTINCT a.SBItemCode cInvCode,d.QTY UPQty
FROM ICSMOOPDetail a LEFT JOIN ICSITEMLot b ON a.MOCODE = b.TransNO AND a.MOSEQ=b.TransLine AND b.ItemCODE=a.ITEMCODE LEFT JOIN ICSINVENTORY c ON a.SBItemCode = c.INVCODE LEFT JOIN ICSLOTONWIPITEM d ON d.LOTNO = b.LotNO AND d.ROUTECODE=a.MoRoute AND d.OPCODE=a.OPCode LEFT JOIN ICSMO e ON e.MOCODE=a.MOCODE AND e.MOSEQ=a.MOSEQ WHERE b.LotNO='{0}' AND a.OPCode='{1}' AND a.OPType='UPBOM' AND a.WorkPoint='{2}' and b.WorkPoint='{2}' AND a.SBItemCode='{3}'";
sqlUpOPDetail = string.Format(sqlUpOPDetail, txtLotNo.Text.Trim(), txtOPCode.Text.Trim(), AppConfig.WorkPointCode, txtSBItemCode.Text); DataTable _dataUpOPDetail = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlUpOPDetail).Tables[0]; if (_dataUpOPDetail != null && _dataUpOPDetail.Rows.Count > 0) { Decimal UPQty = 0; Decimal _UPQty = Convert.ToDecimal(txtSBItemCodeQty.Text);
if (!string.IsNullOrWhiteSpace(_dataUpOPDetail.Rows[0][1].ToString())) { UPQty = Convert.ToDecimal(_dataUpOPDetail.Rows[0][1].ToString()); } else { SetMessage("当前工序子件料号:" + txtSBItemCode.Text + "还没有发料,不能退料", Color.Red); return; } if (_UPQty > UPQty) { SetMessage("当前工序子件料号:" + txtSBItemCode.Text + ";退料数量:" + txtSBItemCodeQty.Text + "大于发料数量:" + UPQty + ",不能退料", Color.Red); return; } } else { SetMessage("当前工序子件料号:" + txtSBItemCode.Text + "不属于工单上料明细", Color.Red); return; }
if (dataUpOPDetail != null && dataUpOPDetail.Rows.Count > 0) { List<ICSLOTONWIPITEM> list = new List<ICSLOTONWIPITEM>(); foreach (DataRow item in dataUpOPDetail.Rows) { if (item["cInvCode"].ToString() == txtSBItemCode.Text) { //d.QTY UPQty,
ICSLOTONWIPITEM wipItem = new ICSLOTONWIPITEM(); wipItem.MOCODE = item["MOCODE"].ToString(); wipItem.MOSEQ = Int32.Parse(item["TransLine"].ToString()); wipItem.LOTNO = item["LotNO"].ToString(); wipItem.ITEMCODE = txtItemCode.Text;//母件编码
wipItem.INVCODE = item["cInvCode"].ToString();//子件编码
wipItem.OPCODE = item["OPCode"].ToString(); wipItem.ROUTECODE = item["MoRoute"].ToString(); ; Decimal OPOKQty = 0; Decimal OPNGQty = 0; if (!string.IsNullOrWhiteSpace(txtLONTQty.Text)) { OPOKQty = Convert.ToDecimal(txtLONTQty.Text); } //if (!string.IsNullOrWhiteSpace(txtLONTQty.Text))
//{
// OPNGQty = Convert.ToDecimal(txtLONTQty.Text);
//}
if (!string.IsNullOrWhiteSpace(txtLONTQty.Text)) { OPNGQty = 0; } Decimal MOQty = Convert.ToDecimal(item["MOPLANQTY"].ToString()); ; wipItem.QTY = Convert.ToDecimal(item["UPQty"].ToString()) - Convert.ToDecimal(txtSBItemCodeQty.Text); wipItem.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss"); wipItem.MUSER = AppConfig.UserCode; ; wipItem.MUSERName = AppConfig.UserName; wipItem.WorkPoint = AppConfig.WorkPointCode; list.Add(wipItem); } } ICSDataCollectionBLL.CollectOPUP(list, "0", AppConfig.AppConnectString); SetMessage("工序退料成功!", Color.Blue);
if (!string.IsNullOrWhiteSpace(this.txtLotNo.Text.Trim()) && !string.IsNullOrWhiteSpace(this.txtOPCode.Text.Trim())) { string _sqlUpOPDetail = @"SELECT DISTINCT a.MOCODE,b.TransLine,a.MoRoute,b.LotNO,b.LOTQTY,a.MOUPBOM,e.MOPLANQTY,
a.SBItemCode cInvCode,c.INVNAME,a.OPCode,c.INVSTD,a.OPUseQty iQuantity,d.QTY UPQty,(a.OPUseQty - ISNULL(d.QTY, 0)) UnUpQty FROM ICSMOOPDetail a LEFT JOIN ICSITEMLot b ON a.MOCODE = b.TransNO AND a.MOSEQ=b.TransLine AND b.ItemCODE=a.ITEMCODE LEFT JOIN ICSINVENTORY c ON a.SBItemCode = c.INVCODE LEFT JOIN ICSLOTONWIPITEM d ON d.LOTNO = b.LotNO AND d.ROUTECODE=a.MoRoute AND d.OPCODE=a.OPCode AND d.INVCODE=a.SBItemCode LEFT JOIN ICSMO e ON e.MOCODE=a.MOCODE AND e.MOSEQ=a.MOSEQ WHERE b.LotNO='{0}' AND a.OPCode='{1}' AND a.OPType='UPBOM' AND a.WorkPoint='{2}' and b.WorkPoint='{2}'";
_sqlUpOPDetail = string.Format(_sqlUpOPDetail, txtLotNo.Text.Trim(), txtOPCode.Text.Trim(), AppConfig.WorkPointCode); dataUpOPDetail = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, _sqlUpOPDetail).Tables[0];
this.gridControl1.DataSource = dataUpOPDetail; gridView1.BestFitColumns(); } } }
private void btnTransfer_Click(object sender, EventArgs e) { SetMsg(Color.Blue, ""); string msg = check(); if (msg != "") { SetMsg(Color.Red, msg); return; } try { #region simulation
ICSLOTSIMULATION simulationNew = new ICSLOTSIMULATION(); simulationNew.MUSER = txtUserCode.Text.Trim(); simulationNew.LOTNO = txtLotNo.Text.Trim(); simulationNew.OPCODE = txtOPCode.Text.Trim(); simulationNew.EQPCODE = txtEQPCode.Text.Trim(); //simulationNew.RESCODE = txtInvLotFurnace.Text.Trim();//试样号
//simulationNew.CHECKLOTNO = txtMemo.Text.Trim(); //备注
#endregion
ICSCollectBLL.Transfer(AppConfig.AppConnectString, simulationNew); SetMsg(Color.Blue, btnTransfer.Text.Trim() + "成功!");
} catch (Exception ex) { SetMsg(Color.Red, ex.Message); } }
#region 失去焦点
private void gridView2_LostFocus(object sender, EventArgs e) { //#region
//try
//{
// //if (e.KeyCode == Keys.Enter)
// //{
// if (gridView2.FocusedRowHandle < 0)
// {
// return;
// }
// #region colS1
// int SNo = gridView2.FocusedRowHandle;
// int SNoCC = gridView2.RowCount;
// //for (int i = SNo; i <= SNo; i++)
// //{
// // SendKeys.Send("{Down}");
// // if (SNo == SNoCC - 1)
// // {
// // for (int j = 0; j <= SNoCC - 1; j++)
// // {
// // SendKeys.Send("{Up}");
// // }
// // SendKeys.Send("{RIGHT}");
// // }
// bool istrue = false;
// for (int k = 0; k < gridView2.RowCount; k++)
// {
// //DevExpress.XtraGrid.Views.Grid.GridView GV = sender as DevExpress.XtraGrid.Views.Grid.GridView;
// //if (GV.EditingValue == null || GV.EditingValue.ToString() == "" || GV == null)
// //{
// // return;
// //}
// //string Memo = GV.EditingValue.ToString();
// //if (Memo != "")
// //{
// // string ID = gridView2.GetRowCellValue(gridView2.FocusedRowHandle, colOK).ToString();
// //}
// #region MyRegion
// bool _S1 = false;
// bool _S2 = false;
// if (gridView2.GetRowCellValue(k, colOK) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString()))
// {
// if (gridView2.GetRowCellValue(k, colOK).ToString() == "True")
// {
// _S1 = true;
// }
// }
// }
// if (gridView2.GetRowCellValue(k, colNG) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colNG).ToString()))
// {
// if (gridView2.GetRowCellValue(k, colNG).ToString() == "True")
// {
// _S2 = true;
// }
// }
// }
// if (_S1 && gridView2.FocusedColumn.Caption == "合格")
// {
// istrue = true;
// }
// //else
// //{
// // istrue = false;
// // break;
// //}
// if (_S2 && gridView2.FocusedColumn.Caption == "不合格")
// {
// istrue = false;
// break;
// }
// #endregion
// }
// if (istrue)
// {
// this.txtWGResult.Text = "OK";
// this.txtWGResult.BackColor = Color.Blue;
// }
// else
// {
// this.txtWGResult.Text = "NG";
// this.txtWGResult.BackColor = Color.Red;
// }
// //}
// #endregion
// //}
//}
//catch (Exception ex)
//{
// throw new Exception(ex.ToString());
//}
//#endregion
}
#endregion
private void gridViewCC_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { //#region
//try
//{
// //if (e.KeyCode == Keys.Enter)
// //{
// if (gridViewCC.FocusedRowHandle < 0)
// {
// return;
// }
// #region colS1
// int SNo = gridViewCC.FocusedRowHandle;
// int SNoCC = gridViewCC.RowCount;
// //for (int i = SNo; i <= SNo; i++)
// //{
// //SendKeys.Send("{Down}");
// //if (SNo == SNoCC - 1)
// //{
// // for (int j = 0; j <= SNoCC - 1; j++)
// // {
// // SendKeys.Send("{Up}");
// // }
// // SendKeys.Send("{RIGHT}");
// //}
// bool istrue = false;
// if (gridViewCC.FocusedColumn.Caption == "检验值")
// {
// for (int k = 0; k < gridViewCC.RowCount; k++)
// {
// #region MyRegion
// Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
// if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
// {
// _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
// }
// }
// if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
// {
// _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
// }
// }
// if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
// {
// _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
// }
// }
// if ((_S1 >= _VALUEMIN && _S1 <= _VALUEMAX) && gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
// {
// istrue = true;
// }
// else
// {
// istrue = false;
// break;
// }
// #endregion
// }
// if (istrue)
// {
// this.txtCCResult.Text = "OK";
// //this.txtCCResult.BackColor = Color.Blue;//5572e8
// this.txtCCResult.BackColor = Color.MediumSlateBlue;//5572e8
// }
// else
// {
// this.txtCCResult.Text = "NG";
// this.txtCCResult.BackColor = Color.Red;
// }
// //}
// }
// #endregion
// //}
//}
//catch (Exception ex)
//{
// throw new Exception(ex.ToString());
//}
//#endregion
} private string CCNCRMes() {
string result = ""; for (int k = 0; k < gridViewCC.RowCount; k++) {
//Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
//if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
//{
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
// {
// _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
// }
//}
//if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
//{
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
// {
// _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
// }
//}
//if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
//{
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
// {
// _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
// }
//}
if (gridViewCC.GetRowCellValue(k, CCNG).ToString() == "True") { result += "在尺寸检验,检验项目:" + gridViewCC.GetRowCellValue(k, colCKGROUPDESC) + " 发生不良:实测值:" + gridViewCC.GetRowCellValue(k, colCheckResult).ToString() + ",不良原因:" + gridViewCC.GetRowCellValue(k, colRemark).ToString() + ""; }
} return result;
}
private void gridView2_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { #region
try { //if (e.KeyCode == Keys.Enter)
//{
if (gridView2.FocusedRowHandle < 0) { return; }
#region colS1
int SNo = gridView2.FocusedRowHandle; int SNoCC = gridView2.RowCount;
//for (int i = SNo; i <= SNo; i++)
//{
// SendKeys.Send("{Down}");
// if (SNo == SNoCC - 1)
// {
// for (int j = 0; j <= SNoCC - 1; j++)
// {
// SendKeys.Send("{Up}");
// }
// SendKeys.Send("{RIGHT}");
// }
bool istrue = false; for (int k = 0; k < gridView2.RowCount; k++) {
//DevExpress.XtraGrid.Views.Grid.GridView GV = sender as DevExpress.XtraGrid.Views.Grid.GridView;
//if (GV.EditingValue == null || GV.EditingValue.ToString() == "" || GV == null)
//{
// return;
//}
//string Memo = GV.EditingValue.ToString();
//if (Memo != "")
//{
// string ID = gridView2.GetRowCellValue(gridView2.FocusedRowHandle, colOK).ToString();
//}
#region MyRegion
bool _S1 = false; bool _S2 = false;
if (gridView2.GetRowCellValue(k, colOK) != null && e.Column.Caption == "合格") { if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString())) { if (gridView2.GetRowCellValue(k, colOK).ToString() == "True") { _S1 = true; if (gridView2.GetRowCellValue(k, colNG).ToString() == "True") { gridView2.SetRowCellValue(k, colNG, "False"); }
} } } if (gridView2.GetRowCellValue(k, colNG) != null && e.Column.Caption == "不合格") { if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colNG).ToString())) { if (gridView2.GetRowCellValue(k, colNG).ToString() == "True") { _S2 = true;
if (gridView2.GetRowCellValue(k, colOK).ToString() == "True") { gridView2.SetRowCellValue(k, colOK, "False"); } } } }
if (_S1 && gridView2.FocusedColumn.Caption == "合格") {
istrue = true; } //else
//{
// istrue = false;
// break;
//}
if (_S2 && gridView2.FocusedColumn.Caption == "不合格") {
istrue = false; //break;
}
#endregion
} if (istrue) { this.txtWGResult.Text = "OK"; this.txtWGResult.BackColor = Color.Blue; } else { this.txtWGResult.Text = "NG"; this.txtWGResult.BackColor = Color.Red; }
//}
#endregion
//}
} catch (Exception ex) { throw new Exception(ex.ToString()); }
#endregion
}
private string WWNCRMes() { string result = ""; for (int k = 0; k < gridView2.RowCount; k++) { bool _S2 = false;
if (gridView2.GetRowCellValue(k, colNG) != null) { if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colNG).ToString())) { if (gridView2.GetRowCellValue(k, colNG).ToString() == "True") { _S2 = true; } } } if (_S2) { result += "在外观检验,检验项目:" + gridView2.GetRowCellValue(k, colCKGROUPDESC1) + "发生不良";
}
} return result;
} //private void webBrowserMap_SizeChanged(object sender, EventArgs e)
//{
// panelMap.Width = this.Width;
// panelMap.Height = this.Height;
// //webBrowserMap.Dock = DockStyle.Fill;
//}
public static string PLMMap_(string url, string JsonData) { //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
Encoding encoding = Encoding.UTF8;
//构造一个Web请求的对象
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + JsonData); request.Method = "GET"; request.Accept = "text/html, application/xhtml+xml, */*"; request.ContentType = "application/json";
//获取web请求的响应的内容
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) { return reader.ReadToEnd(); }
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create(https + strContent);
//request.Method = "GET";
//request.ContentType = "textml;charset=UTF-8";
//HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//Stream myResponseStream = response.GetResponseStream();
//StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
//string retString = myStreamReader.ReadToEnd();
//myStreamReader.Close();
//myResponseStream.Close();
//dynamic ja = JsonConvert.DeserializeObject(retString);
//return ja;
}
public static BaseModel PLMMap(string URL, string JsonData) { try { //调用接口获取返回信息
//string ContentType = "application/json;charset=UTF-8;";
string ContentType = "application/json";
WebRequest request = WebRequest.Create(URL); request.Method = "POST"; byte[] bytes = System.Text.Encoding.UTF8.GetBytes(JsonData); request.ContentType = ContentType; request.ContentLength = bytes.Length; //using (Stream postStream = request.GetRequestStream())
//{
// postStream.Write(bytes, 0, bytes.Length);
//}
using (Stream postStream = request.GetRequestStream()) { postStream.Write(bytes, 0, bytes.Length); } request.Credentials = CredentialCache.DefaultCredentials; string str = string.Empty; WebResponse response = null; try { response = request.GetResponse(); } catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) response = (WebResponse)ex.Response; } if (response != null) { using (StreamReader st = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8)) { str = System.Web.HttpUtility.UrlDecode(st.ReadToEnd()); } }
//将返回的string类型转换成model
BaseModel obj = (BaseModel)Newtonsoft.Json.JsonConvert.DeserializeObject(str, typeof(BaseModel)); //string obj = (string)Newtonsoft.Json.JsonConvert.DeserializeObject(str, typeof(string));
return obj; } catch (Exception ex) { throw new Exception("调用MES接口错误:" + ex.Message); } }
public static string PLMMap1(string URL, string JsonData) { try { //调用接口获取返回信息
//string ContentType = "application/json;charset=UTF-8;";
string ContentType = "application/json";
WebRequest request = WebRequest.Create(URL); request.Method = "POST"; byte[] bytes = System.Text.Encoding.UTF8.GetBytes(JsonData); request.ContentType = ContentType; request.ContentLength = bytes.Length; //using (Stream postStream = request.GetRequestStream())
//{
// postStream.Write(bytes, 0, bytes.Length);
//}
using (Stream postStream = request.GetRequestStream()) { postStream.Write(bytes, 0, bytes.Length); } request.Credentials = CredentialCache.DefaultCredentials; string str = string.Empty; WebResponse response = null; try { response = request.GetResponse(); } catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) response = (WebResponse)ex.Response; } if (response != null) { using (StreamReader st = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8)) { str = System.Web.HttpUtility.UrlDecode(st.ReadToEnd()); } }
return str; } catch (Exception ex) { throw new Exception("调用MES接口错误:" + ex.Message); } }
public class BaseModel { public string code { get; set; }
public string msg { get; set; }
public string data { get; set; }
}
public static string HttpDownloadFile(string url, string path) { // 设置参数
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
//发送请求并获取相应回应数据
HttpWebResponse response = request.GetResponse() as HttpWebResponse; //直到request.GetResponse()程序才开始向目标网页发送Post请求
Stream responseStream = response.GetResponseStream();
//创建本地文件写入流
Stream stream = new FileStream(path, FileMode.Create);
byte[] bArr = new byte[1024]; int size = responseStream.Read(bArr, 0, (int)bArr.Length); while (size > 0) { stream.Write(bArr, 0, size); size = responseStream.Read(bArr, 0, (int)bArr.Length); } stream.Close(); responseStream.Close(); return path; }
private void btnEnlargeTZ_Click_1(object sender, EventArgs e) { FileDrawing.Enlarge(axAcroPDF); }
//初始化颜色
public void initcolor() {
BtnSOP.BackColor = Color.FromArgb(207, 221, 255); BtnSIP.BackColor = Color.FromArgb(207, 221, 255); btnOPDrowing.BackColor = Color.FromArgb(207, 221, 255); btnOperationManual.BackColor = Color.FromArgb(207, 221, 255); BtnOPUp.BackColor = Color.FromArgb(207, 221, 255); btnDaoJu.BackColor = Color.FromArgb(207, 221, 255);//刀具
btnCaoZuo.BackColor = Color.FromArgb(207, 221, 255);//操作
btnJianYan.BackColor = Color.FromArgb(207, 221, 255);//检验
}
#region 零部件 设计图纸 SOP
private void BtnSOP_Click(object sender, EventArgs e) { try { initcolor(); BtnSOP.BackColor = Color.Aqua;
string url = @"http://172.16.12.155:8999/api/GetPLMToken"; //string url = @"http://localhost:51182/api/GetPLMToken";
SearchPart Bills = new SearchPart(); //Bills.ItemCode = "20100003035";
//Bills.ItemCode = "20100000670";
//Bills.ItemCode = "20800001904";
Bills.ItemCode = txtItemCode.Text; if (string.IsNullOrWhiteSpace(txtItemCode.Text)) { SetMessage("请先输入料号编码", Color.Red); return; } Bills.size = 100; Bills.extra = "DWGSW"; string JsonData = JsonConvert.SerializeObject(Bills);
//try
//{
// //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
// Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
//}
#region MyRegion
BaseModel rtn = PLMMap(url, JsonData); if (rtn.code == "200") { //txtGetPLMMap.Text = rtn.msg;
//panelMap.BringToFront();
//panel8WebMap.BringToFront();
//webBrowserMap.Navigate(txtGetPLMMap.Text);
//string path = string.Empty;
//path = "E:\\PDF";
//HttpDownloadFile(txtGetPLMMap.Text, path);
//SetMessage("", Color.Red);
//return;
//ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
//string Token = result.errmsg;
#region MyRegion
panelMap.BringToFront(); this.label23.Visible = false; string itemCode = this.txtItemCode.Text; //string RouteCode = string.Empty;
string OpCode = this.txtOPCode.Text; //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
//string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
//string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
//if (string.IsNullOrWhiteSpace(connectionString))
// return;
//string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
//object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
//name = "123";
//if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
// return;
//string fileName = "E:\\PDF\\20201015.pdf";
//string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]"); if (string.IsNullOrWhiteSpace(connectionString)) { SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red); return; }
string[] ftps = connectionString.Split(';'); string ftpServerIP = ftps[0].Split('=')[1]; //string ftpRemotePath = ftps[1].Split('=')[1];
string ftpRemotePath = "";
string ftpUserID = ftps[2].Split('=')[1]; string ftpPassword = ftps[3].Split('=')[1];
FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
//string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName = Bills.ItemCode + ".pdf"; ftpWeb.Download(filePath + "\\", fileName);
string filePathName = filePath + "\\" + fileName; //string fileName = logAdress + Bills.ItemCode + ".pdf";
string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
//if (!string.IsNullOrEmpty(fileName))
if (!string.IsNullOrEmpty(filePathName)) { //axAcroPDF.LoadFile(fileName);
axAcroPDF.LoadFile(filePathName); axAcroPDF.setShowToolbar(false); axAcroPDF.setShowScrollbars(false); axAcroPDF.setPageMode("thumbs"); axAcroPDF.setLayoutMode("SinglePage"); axAcroPDF.setView("Fit"); axAcroPDF.Show(); } #endregion
} else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; } #endregion
} catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion
#region 工艺过程卡2
private void btnOperationManual_Click(object sender, EventArgs e) { try { initcolor(); btnOperationManual.BackColor = Color.Aqua;
string url = @"http://172.16.12.155:8999/api/GetPLMToken2"; //string url = @"http://localhost:51182/api/GetPLMToken2";
//;
SearchPart Bills = new SearchPart(); //Bills.ItemCode = "20100003035";
//Bills.ItemCode = "20100000670";
//Bills.ItemCode = "20800001904";
Bills.ItemCode = txtItemCode.Text; if (string.IsNullOrWhiteSpace(txtItemCode.Text)) { SetMessage("请先输入料号编码", Color.Red); return; } Bills.size = 100; //0916 原来的 Bills.extra = "DWGSW";
Bills.extra = "PRCF"; string JsonData = JsonConvert.SerializeObject(Bills);
//try
//{
// //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
// Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
//}
#region MyRegion
BaseModel rtn = PLMMap(url, JsonData); if (rtn.code == "200") { //txtGetPLMMap.Text = rtn.msg;
//panelMap.BringToFront();
//panel8WebMap.BringToFront();
//webBrowserMap.Navigate(txtGetPLMMap.Text);
//string path = string.Empty;
//path = "E:\\PDF";
//HttpDownloadFile(txtGetPLMMap.Text, path);
//SetMessage("", Color.Red);
//return;
//ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
//string Token = result.errmsg;
#region MyRegion
panelMap.BringToFront(); this.label23.Visible = false; string itemCode = this.txtItemCode.Text; //string RouteCode = string.Empty;
string OpCode = this.txtOPCode.Text; //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
//string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
//string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
//if (string.IsNullOrWhiteSpace(connectionString))
// return;
//string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
//object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
//name = "123";
//if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
// return;
//string fileName = "E:\\PDF\\20201015.pdf";
//string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]"); if (string.IsNullOrWhiteSpace(connectionString)) { SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red); return; }
string[] ftps = connectionString.Split(';'); string ftpServerIP = ftps[0].Split('=')[1]; //string ftpRemotePath = ftps[1].Split('=')[1];
string ftpRemotePath = "";
string ftpUserID = ftps[2].Split('=')[1]; string ftpPassword = ftps[3].Split('=')[1];
FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
//string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName=rtn.msg+ ".pdf"; ftpWeb.Download(filePath + "\\", fileName);
string filePathName = filePath + "\\" + fileName; //string fileName = logAdress + Bills.ItemCode + ".pdf";
string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
//if (!string.IsNullOrEmpty(fileName))
if (!string.IsNullOrEmpty(filePathName)) { //axAcroPDF.LoadFile(fileName);
axAcroPDF.LoadFile(filePathName); axAcroPDF.setShowToolbar(false); axAcroPDF.setShowScrollbars(false); axAcroPDF.setPageMode("thumbs"); axAcroPDF.setLayoutMode("SinglePage"); axAcroPDF.setView("Fit"); axAcroPDF.Show(); } #endregion
} else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; }
#endregion
} catch (Exception ex) { MessageBox.Show(ex.Message); }
} #endregion
#region 工序卡3 SIP
private void BtnSIP_Click(object sender, EventArgs e) {
try { initcolor(); BtnSIP.BackColor = Color.Aqua;
string url = @"http://172.16.12.155:8999/api/GetPLMToken3"; //string url = @"http://localhost:51182/api/GetPLMToken3";
SearchPart Bills = new SearchPart(); //Bills.ItemCode = "20100003035";
//Bills.ItemCode = "20100000670";
//Bills.ItemCode = "20800001904";
Bills.ItemCode = txtItemCode.Text; if (string.IsNullOrWhiteSpace(txtItemCode.Text)) { SetMessage("请先输入料号编码", Color.Red); return; } if (string.IsNullOrEmpty(opseq)) { SetMessage("请先输入正确工序!", Color.Red); return; } Bills.size = 100; Bills.extra = "DWGSW"; Bills.routecode = RouteCode; Bills.opseq = opseq; string JsonData = JsonConvert.SerializeObject(Bills);
//try
//{
// //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
// Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
//}
#region MyRegion
BaseModel rtn = PLMMap(url, JsonData); if (rtn.code == "200") { //txtGetPLMMap.Text = rtn.msg;
//panelMap.BringToFront();
//panel8WebMap.BringToFront();
//webBrowserMap.Navigate(txtGetPLMMap.Text);
//string path = string.Empty;
//path = "E:\\PDF";
//HttpDownloadFile(txtGetPLMMap.Text, path);
//SetMessage("", Color.Red);
//return;
//ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
//string Token = result.errmsg;
#region MyRegion
panelMap.BringToFront(); this.label23.Visible = false; string itemCode = this.txtItemCode.Text; //string RouteCode = string.Empty;
string OpCode = this.txtOPCode.Text; //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
//string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
//string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
//if (string.IsNullOrWhiteSpace(connectionString))
// return;
//string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
//object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
//name = "123";
//if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
// return;
//string fileName = "E:\\PDF\\20201015.pdf";
//string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]"); if (string.IsNullOrWhiteSpace(connectionString)) { SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red); return; }
string[] ftps = connectionString.Split(';'); string ftpServerIP = ftps[0].Split('=')[1]; //string ftpRemotePath = ftps[1].Split('=')[1];
string ftpRemotePath = "";
string ftpUserID = ftps[2].Split('=')[1]; string ftpPassword = ftps[3].Split('=')[1];
FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
//string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName = rtn.msg+ ".pdf"; ftpWeb.Download(filePath + "\\", fileName);
string filePathName = filePath + "\\" + fileName; //string fileName = logAdress + Bills.ItemCode + ".pdf";
string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
//if (!string.IsNullOrEmpty(fileName))
if (!string.IsNullOrEmpty(filePathName)) { //axAcroPDF.LoadFile(fileName);
axAcroPDF.LoadFile(filePathName); axAcroPDF.setShowToolbar(false); axAcroPDF.setShowScrollbars(false); axAcroPDF.setPageMode("thumbs"); axAcroPDF.setLayoutMode("SinglePage"); axAcroPDF.setView("Fit"); axAcroPDF.Show(); } #endregion
} else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; }
#endregion
} catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion
#region 作业指导书4
private void btnOPDrowing_Click(object sender, EventArgs e) { try { initcolor(); btnOPDrowing.BackColor = Color.Aqua;
string url = @"http://172.16.12.155:9999/api/GetPLMToken8"; //string url = @"http://localhost:51182/api/GetPLMToken8";
SearchPart Bills = new SearchPart(); //Bills.ItemCode = "20100003035";
//Bills.ItemCode = "20100000670";
//Bills.ItemCode = "20800001904";
Bills.ItemCode = txtItemCode.Text;
if (string.IsNullOrWhiteSpace(txtItemCode.Text)) { SetMessage("请先输入料号编码", Color.Red); return; } if (string.IsNullOrEmpty(opseq)) { SetMessage("请先输入正确工序!", Color.Red); return; } Bills.size = 100; Bills.extra = "DWGSW"; Bills.routecode = RouteCode; Bills.opseq = opseq; string JsonData = JsonConvert.SerializeObject(Bills);
//try
//{
// //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
// Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
//}
#region MyRegion
BaseModel rtn = PLMMap(url, JsonData); if (rtn.code == "200") { //txtGetPLMMap.Text = rtn.msg;
//panelMap.BringToFront();
//panel8WebMap.BringToFront();
//webBrowserMap.Navigate(txtGetPLMMap.Text);
//string path = string.Empty;
//path = "E:\\PDF";
//HttpDownloadFile(txtGetPLMMap.Text, path);
//SetMessage("", Color.Red);
//return;
//ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
//string Token = result.errmsg;
#region MyRegion
panelMap.BringToFront(); this.label23.Visible = false; string itemCode = this.txtItemCode.Text; //string RouteCode = string.Empty;
string OpCode = this.txtOPCode.Text; //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
//string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
//string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
//if (string.IsNullOrWhiteSpace(connectionString))
// return;
//string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
//object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
//name = "123";
//if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
// return;
//string fileName = "E:\\PDF\\20201015.pdf";
//string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]"); if (string.IsNullOrWhiteSpace(connectionString)) { SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red); return; }
string[] ftps = connectionString.Split(';'); string ftpServerIP = ftps[0].Split('=')[1]; //string ftpRemotePath = ftps[1].Split('=')[1];
string ftpRemotePath = "";
string ftpUserID = ftps[2].Split('=')[1]; string ftpPassword = ftps[3].Split('=')[1];
FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
//string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName = rtn.msg + ".pdf"; ftpWeb.Download(filePath + "\\", fileName);
string filePathName = filePath + "\\" + fileName; //string fileName = logAdress + Bills.ItemCode + ".pdf";
string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
//if (!string.IsNullOrEmpty(fileName))
if (!string.IsNullOrEmpty(filePathName)) { //axAcroPDF.LoadFile(fileName);
axAcroPDF.LoadFile(filePathName); axAcroPDF.setShowToolbar(false); axAcroPDF.setShowScrollbars(false); axAcroPDF.setPageMode("thumbs"); axAcroPDF.setLayoutMode("SinglePage"); axAcroPDF.setView("Fit"); axAcroPDF.Show(); } #endregion
} else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; }
#endregion
} catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion
#region 检验判定书5
private void btnJianYan_Click(object sender, EventArgs e) { try { initcolor(); btnJianYan.BackColor = Color.Aqua;
string url = @"http://172.16.12.155:8999/api/GetPLMToken5"; //string url = @"http://localhost:51182/api/GetPLMToken5";
SearchPart Bills = new SearchPart(); //Bills.ItemCode = "20100003035";
//Bills.ItemCode = "20100000670";
//Bills.ItemCode = "20800001904";
Bills.ItemCode = txtItemCode.Text;
if (string.IsNullOrWhiteSpace(txtItemCode.Text)) { SetMessage("请先输入料号编码", Color.Red); return; } if (string.IsNullOrEmpty(opseq)) { SetMessage("请先输入正确工序!", Color.Red); return; } Bills.size = 100; Bills.extra = "DWGSW"; Bills.routecode = RouteCode; Bills.opseq = opseq; string JsonData = JsonConvert.SerializeObject(Bills);
//try
//{
// //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
// Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
//}
#region MyRegion
BaseModel rtn = PLMMap(url, JsonData); if (rtn.code == "200") { //txtGetPLMMap.Text = rtn.msg;
//panelMap.BringToFront();
//panel8WebMap.BringToFront();
//webBrowserMap.Navigate(txtGetPLMMap.Text);
//string path = string.Empty;
//path = "E:\\PDF";
//HttpDownloadFile(txtGetPLMMap.Text, path);
//SetMessage("", Color.Red);
//return;
//ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
//string Token = result.errmsg;
#region MyRegion
panelMap.BringToFront(); this.label23.Visible = false; string itemCode = this.txtItemCode.Text; //string RouteCode = string.Empty;
string OpCode = this.txtOPCode.Text; //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
//string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
//string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
//if (string.IsNullOrWhiteSpace(connectionString))
// return;
//string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
//object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
//name = "123";
//if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
// return;
//string fileName = "E:\\PDF\\20201015.pdf";
//string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]"); if (string.IsNullOrWhiteSpace(connectionString)) { SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red); return; }
string[] ftps = connectionString.Split(';'); string ftpServerIP = ftps[0].Split('=')[1]; //string ftpRemotePath = ftps[1].Split('=')[1];
string ftpRemotePath = "";
string ftpUserID = ftps[2].Split('=')[1]; string ftpPassword = ftps[3].Split('=')[1];
FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
//string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName = rtn.msg + ".pdf"; ftpWeb.Download(filePath + "\\", fileName);
string filePathName = filePath + "\\" + fileName; //string fileName = logAdress + Bills.ItemCode + ".pdf";
string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
//if (!string.IsNullOrEmpty(fileName))
if (!string.IsNullOrEmpty(filePathName)) { //axAcroPDF.LoadFile(fileName);
axAcroPDF.LoadFile(filePathName); axAcroPDF.setShowToolbar(false); axAcroPDF.setShowScrollbars(false); axAcroPDF.setPageMode("thumbs"); axAcroPDF.setLayoutMode("SinglePage"); axAcroPDF.setView("Fit"); axAcroPDF.Show(); } #endregion
} else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; }
#endregion
} catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion
#region 刀具清单6
private void btnDaoJu_Click(object sender, EventArgs e) { try { initcolor(); btnDaoJu.BackColor = Color.Aqua;
string url = @"http://172.16.12.155:8999/api/GetPLMToken6"; //string url = @"http://localhost:51182/api/GetPLMToken6";
SearchPart Bills = new SearchPart(); //Bills.ItemCode = "20100003035";
//Bills.ItemCode = "20100000670";
//Bills.ItemCode = "20800001904";
Bills.ItemCode = txtItemCode.Text;
if (string.IsNullOrWhiteSpace(txtItemCode.Text)) { SetMessage("请先输入料号编码", Color.Red); return; } if (string.IsNullOrEmpty(opseq)) { SetMessage("请先输入正确工序!", Color.Red); return; } Bills.size = 100; Bills.extra = "DWGSW"; Bills.routecode = RouteCode; Bills.opseq = opseq; string JsonData = JsonConvert.SerializeObject(Bills);
//try
//{
// //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
// Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
//}
#region MyRegion
BaseModel rtn = PLMMap(url, JsonData); if (rtn.code == "200") { //txtGetPLMMap.Text = rtn.msg;
//panelMap.BringToFront();
//panel8WebMap.BringToFront();
//webBrowserMap.Navigate(txtGetPLMMap.Text);
//string path = string.Empty;
//path = "E:\\PDF";
//HttpDownloadFile(txtGetPLMMap.Text, path);
//SetMessage("", Color.Red);
//return;
//ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
//string Token = result.errmsg;
#region MyRegion
panelMap.BringToFront(); this.label23.Visible = false; string itemCode = this.txtItemCode.Text; //string RouteCode = string.Empty;
string OpCode = this.txtOPCode.Text; //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
//string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
//string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
//if (string.IsNullOrWhiteSpace(connectionString))
// return;
//string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
//object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
//name = "123";
//if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
// return;
//string fileName = "E:\\PDF\\20201015.pdf";
//string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]"); if (string.IsNullOrWhiteSpace(connectionString)) { SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red); return; }
string[] ftps = connectionString.Split(';'); string ftpServerIP = ftps[0].Split('=')[1]; //string ftpRemotePath = ftps[1].Split('=')[1];
string ftpRemotePath = "";
string ftpUserID = ftps[2].Split('=')[1]; string ftpPassword = ftps[3].Split('=')[1];
FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
//string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName = rtn.msg + ".pdf"; ftpWeb.Download(filePath + "\\", fileName);
string filePathName = filePath + "\\" + fileName; //string fileName = logAdress + Bills.ItemCode + ".pdf";
string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
//if (!string.IsNullOrEmpty(fileName))
if (!string.IsNullOrEmpty(filePathName)) { //axAcroPDF.LoadFile(fileName);
axAcroPDF.LoadFile(filePathName); axAcroPDF.setShowToolbar(false); axAcroPDF.setShowScrollbars(false); axAcroPDF.setPageMode("thumbs"); axAcroPDF.setLayoutMode("SinglePage"); axAcroPDF.setView("Fit"); axAcroPDF.Show(); } #endregion
} else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; }
#endregion
} catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion
#region 操作指导书7
private void btnCaoZuo_Click(object sender, EventArgs e) { //initcolor();
//btnCaoZuo.BackColor = Color.Aqua;
//this.label23.Visible = false;
try { initcolor(); btnCaoZuo.BackColor = Color.Aqua;
string url = @"http://172.16.12.155:8999/api/GetPLMToken7"; //string url = @"http://localhost:51182/api/GetPLMToken7";
SearchPart Bills = new SearchPart(); //Bills.ItemCode = "20100003035";
//Bills.ItemCode = "20100000670";
//Bills.ItemCode = "20800001904";
Bills.ItemCode = txtItemCode.Text;
if (string.IsNullOrWhiteSpace(txtItemCode.Text)) { SetMessage("请先输入料号编码", Color.Red); return; } if (string.IsNullOrEmpty(opseq)) { SetMessage("请先输入正确工序!", Color.Red); return; } Bills.size = 100; Bills.extra = "DWGSW"; Bills.routecode = RouteCode; Bills.opseq = opseq; string JsonData = JsonConvert.SerializeObject(Bills);
//try
//{
// //Bills = JsonConvert.DeserializeObject<List<SearchPart>>(JsonData.ToString());
// Bills = JsonConvert.DeserializeObject<SearchPart>(JsonData.ToString());
//}
#region MyRegion
BaseModel rtn = PLMMap(url, JsonData); if (rtn.code == "200") { //txtGetPLMMap.Text = rtn.msg;
//panelMap.BringToFront();
//panel8WebMap.BringToFront();
//webBrowserMap.Navigate(txtGetPLMMap.Text);
//string path = string.Empty;
//path = "E:\\PDF";
//HttpDownloadFile(txtGetPLMMap.Text, path);
//SetMessage("", Color.Red);
//return;
//ICSSoft.Frame.PLM2MESInterface.Token.GetToken.OperationResult result = ICSSoft.Frame.PLM2MESInterface.Token.GetToken.GetPLMToken();
//string Token = result.errmsg;
#region MyRegion
panelMap.BringToFront(); this.label23.Visible = false; string itemCode = this.txtItemCode.Text; //string RouteCode = string.Empty;
string OpCode = this.txtOPCode.Text; //string sql = @"SELECT SOPDrawing from ICSITEMROUTE2OP WHERE ITEMCODE='" + itemCode + "' AND ROUTECODE='" + RouteCode + "' AND OPCODE='" + OpCode + "' ";
//string connectionString = AppConfig.FrameConnectString; // AppConfig.GetDataBaseConnectStringByKey("[DB.PLM]");
//string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP2]");
//if (string.IsNullOrWhiteSpace(connectionString))
// return;
//string logAdress = ConfigurationManager.AppSettings["PLMAdress"].ToString();
//object name = DBHelper.ExecuteScalar(connectionString, CommandType.Text, sql);
//name = "123";
//if (name == null || string.IsNullOrWhiteSpace(name.ToString()))
// return;
//string fileName = "E:\\PDF\\20201015.pdf";
//string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf";
string connectionString = AppConfig.GetDataBaseConnectStringByKey("[DB.FTP]"); if (string.IsNullOrWhiteSpace(connectionString)) { SetMessage("没有获取到FTP链接,请在数据源中先配置FTP", Color.Red); return; }
string[] ftps = connectionString.Split(';'); string ftpServerIP = ftps[0].Split('=')[1]; //string ftpRemotePath = ftps[1].Split('=')[1];
string ftpRemotePath = "";
string ftpUserID = ftps[2].Split('=')[1]; string ftpPassword = ftps[3].Split('=')[1];
FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); //FtpWeb ftpWeb = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword);
//string filePath = System.IO.Path.GetTempPath() + "\\Drawing";
string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\Drawing";
if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName = rtn.msg+".pdf"; ftpWeb.Download(filePath + "\\", fileName);
string filePathName = filePath + "\\" + fileName; //string fileName = logAdress + Bills.ItemCode + ".pdf";
string ftpURL = "ftp://" + ftpServerIP + "/" + fileName;
//if (!string.IsNullOrEmpty(fileName))
if (!string.IsNullOrEmpty(filePathName)) { //axAcroPDF.LoadFile(fileName);
axAcroPDF.LoadFile(filePathName); axAcroPDF.setShowToolbar(false); axAcroPDF.setShowScrollbars(false); axAcroPDF.setPageMode("thumbs"); axAcroPDF.setLayoutMode("SinglePage"); axAcroPDF.setView("Fit"); axAcroPDF.Show(); } #endregion
} else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; }
#endregion
} catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion
#region 工序上料
public ICSLOTSIMULATION GetSimulationByLotNo(string LotNo) { string sql = @"select * from ICSLOTSIMULATION
where LOTNO = '" + LotNo + "' order by MTIME desc";
var objs = this._domainDataProvider.ExecuteQuery<ICSLOTSIMULATION>(sql).ToList(); if (objs == null || objs.Count < 1) return null; else return (ICSLOTSIMULATION)objs[0]; }
private void BtnOPUp_Click(object sender, EventArgs e) { initcolor(); BtnOPUp.BackColor = Color.Aqua; // BtnOPUp.BackColor = System.Drawing.Color.DeepSkyBlue;
this.label23.Visible = true; panelOP.BringToFront(); //this.txtSBItemCode.Text = txtLotNo.Text;
//this.txtSBItemCode.Text = txtLotNo.Text;
if (this.btnOPOption.Text == " 开工") { List<ICSLOTONWIPITEM> list = new List<ICSLOTONWIPITEM>(); if (dataUpOPDetail != null && dataUpOPDetail.Rows.Count > 0) { foreach (DataRow item in dataUpOPDetail.Rows) { //d.QTY UPQty,
//ICSLOTSIMULATION simulation = GetSimulationByLotNo(this.txtLotNo.Text.Trim());
//ICSLOTSIMULATIONREPORT simulationReport = _DataCollectFacade.GetLastSimulationReport(this.txtLotNo.Text.Trim());
ICSLOTONWIPITEM wipItem = new ICSLOTONWIPITEM(); wipItem.ID = AppConfig.GetGuid(); wipItem.MOCODE = item["MOCODE"].ToString(); wipItem.MOSEQ = Int32.Parse(item["TransLine"].ToString()); wipItem.LOTNO = item["LotNO"].ToString(); wipItem.ITEMCODE = txtItemCode.Text;//母件编码
wipItem.INVCODE = item["cInvCode"].ToString();//子件编码
wipItem.OPCODE = item["OPCode"].ToString(); wipItem.ROUTECODE = item["MoRoute"].ToString(); ; wipItem.QTY = 0;// Convert.ToDecimal(item["iQuantity"].ToString()) / Convert.ToDecimal(txtLONTQty.Text.ToString());
wipItem.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss"); wipItem.MUSER = AppConfig.UserCode; ; wipItem.MUSERName = AppConfig.UserName; wipItem.WorkPoint = AppConfig.WorkPointCode;
list.Add(wipItem); //wipItem.MCARDTYPE = simulation.EATTRIBUTE1;
//wipItem.RESCODE = simulation.RESCODE;
//wipItem.SEGCODE = simulationReport.SEGCODE;
//wipItem.SHIFTTYPECODE = "";
//wipItem.SSCODE = simulationReport.SSCODE;
//wipItem.MOCODE = simulation.MOCODE;
//wipItem.MODELCODE = simulation.MODELCODE;
//wipItem.DATECODE = luhaoCode;
//wipItem.BeginSHIFTCODE = simulationReport.SHIFTTYPECODE;
//wipItem.EndSHIFTCODE = simulationReport.SHIFTTYPECODE;
//wipItem.BeginTPCODE = "";
//wipItem.ENDTPCODE = "";
//wipItem.INVLOTNO = txtKeyPart.Text;
//wipItem.TRANSSTATUS = TransactionStatus.TransactionStatus_NO;
//wipItem.MCARDTYPE = MCardType.MCardType_INNO;
//wipItem.LOTSEQ = (int)simulation.LOTSEQ;
//新增 采集类型
//wipItem.ACTIONTYPE = (int)Enum.Parse(typeof(MaterialType), "CollectMaterial");
} ICSDataCollectionBLL.CollectOPUP(list, "1", AppConfig.AppConnectString); SetMessage("工序上料成功!", Color.Blue); } } if (this.btnOPOption.Text == " 完工") { if (true) {
} }
} #endregion
private void button1_Click_1(object sender, EventArgs e) { if (string.IsNullOrEmpty(lotno)) { ICSBaseSimpleCode.AppshowMessageBox("请先输入正确追踪单号!"); return; } FormICSPictureNew form = new FormICSPictureNew(this.lotno); form.ShowDialog(); }
private void repositoryItemCheckEdit3_QueryValueByCheckState(object sender, DevExpress.XtraEditors.Controls.QueryValueByCheckStateEventArgs e) { int rowhandle = gridViewCC.FocusedRowHandle; if (e.CheckState == CheckState.Checked) {
gridViewCC.SetRowCellValue(rowhandle, CCOK, true); gridViewCC.SetRowCellValue(rowhandle, CCNG, false); } else { gridViewCC.SetRowCellValue(rowhandle, CCOK, false); } #region
//try
//{
// if (gridViewCC.FocusedRowHandle < 0)
// {
// return;
// }
// #region colS1
// int SNo = gridViewCC.FocusedRowHandle;
// int SNoCC = gridViewCC.RowCount;
// for (int i = SNo; i <= SNo; i++)
// {
// SendKeys.Send("{Down}");
// if (SNo == SNoCC - 1)
// {
// for (int j = 0; j <= SNoCC - 1; j++)
// {
// SendKeys.Send("{Up}");
// }
// SendKeys.Send("{RIGHT}");
// }
// bool istrue = false;
// for (int k = 0; k < gridViewCC.RowCount; k++)
// {
// #region MyRegion
// Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0;
// if (gridViewCC.GetRowCellValue(k, colSetValueMax) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString()))
// {
// _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMax).ToString());
// }
// }
// if (gridViewCC.GetRowCellValue(k, colSetValueMin) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString()))
// {
// _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(k, colSetValueMin).ToString());
// }
// }
// if (gridViewCC.GetRowCellValue(k, colCheckResult) != null)
// {
// if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
// {
// _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(k, colCheckResult).ToString());
// }
// }
// if ((_S1 < _VALUEMIN || _S1 > _VALUEMAX) && gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, colCheckResult).ToString()))
// {
// istrue = false;
// break;
// }
// else
// {
// istrue = true;
// }
// #endregion
// }
// if (istrue)
// {
// this.txtCCResult.Text = "OK";
// this.txtCCResult.BackColor = Color.Blue;
// }
// else
// {
// this.txtCCResult.Text = "NG";
// this.txtCCResult.BackColor = Color.Red;
// }
// }
// #endregion
//}
//catch (Exception ex)
//{
// throw new Exception(ex.ToString());
//}
#endregion
#region
try { if (gridViewCC.FocusedRowHandle < 0) { return; }
#region colS1
int SNo = gridViewCC.FocusedRowHandle; int SNoCC = gridViewCC.RowCount;
for (int i = SNo; i <= SNo; i++) {
bool istrue = false; for (int k = 0; k < gridViewCC.RowCount; k++) { #region MyRegion
bool _S1 = false; if (gridViewCC.GetRowCellValue(k, CCOK) != null) { if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, CCOK).ToString())) { string cc = gridViewCC.GetRowCellValue(k, CCOK).ToString(); if (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "True" || (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "False" && gridViewCC.GetRowCellValue(k, CCNG).ToString() == "False")) { _S1 = true; } else _S1 = false; } }
if (_S1) { istrue = true; } else { istrue = false; break; }
#endregion
} if (istrue) { this.txtCCResult.Text = "OK"; this.txtCCResult.BackColor = Color.Blue; } else { this.txtCCResult.Text = "NG"; this.txtCCResult.BackColor = Color.Red; }
}
#endregion
} catch (Exception ex) { throw new Exception(ex.ToString()); } #endregion
}
private void repositoryItemCheckEdit4_QueryValueByCheckState(object sender, DevExpress.XtraEditors.Controls.QueryValueByCheckStateEventArgs e) { int rowhandle = gridViewCC.FocusedRowHandle; if (e.CheckState == CheckState.Checked) {
gridViewCC.SetRowCellValue(rowhandle, CCNG, true); gridViewCC.SetRowCellValue(rowhandle, CCOK, false); } else { gridViewCC.SetRowCellValue(rowhandle, CCNG, false); }
#region
try { if (gridViewCC.FocusedRowHandle < 0) { return; }
#region colS1
int SNo = gridViewCC.FocusedRowHandle; int SNoCC = gridViewCC.RowCount;
for (int i = SNo; i <= SNo; i++) {
bool istrue = false; for (int k = 0; k < gridViewCC.RowCount; k++) { #region MyRegion
bool _S1 = false; if (gridViewCC.GetRowCellValue(k, CCOK) != null) { if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, CCOK).ToString())) { string cc = gridViewCC.GetRowCellValue(k, CCOK).ToString(); if (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "True" || (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "False" && gridViewCC.GetRowCellValue(k, CCNG).ToString() == "False")) { _S1 = true; } else _S1 = false; } }
if (_S1) { istrue = true; } else { istrue = false; break; }
#endregion
} if (istrue) { this.txtCCResult.Text = "OK"; this.txtCCResult.BackColor = Color.Blue; } else { this.txtCCResult.Text = "NG"; this.txtCCResult.BackColor = Color.Red; }
}
#endregion
} catch (Exception ex) { throw new Exception(ex.ToString()); } #endregion
}
private void GetPLMCKDATA(string itemcode, string routecode, string opseq) { try { string url = @"http://172.16.12.155:8999/api/GetPLMCKDATA"; SearchPart Bills = new SearchPart(); Bills.opseq = opseq; Bills.ItemCode = itemcode; Bills.routecode = routecode; string opcode = txtOPCode.Text.Trim(); string JsonData = JsonConvert.SerializeObject(Bills); string CKDATA = PLMMap1(url, JsonData); JObject jobject = JObject.Parse(CKDATA); if (jobject["code"].ToString() == "200") { string data = jobject["data"].ToString(); List<Parts> part = new List<Parts>(); part = (List<Parts>)JsonConvert.DeserializeObject(data, typeof(List<Parts>));
List<ICSOQCCKGROUP> group = new List<ICSOQCCKGROUP>(); List<ICSOQCCKLIST> cklist = new List<ICSOQCCKLIST>(); List<string> RemoveID = new List<string>(); foreach (Parts p in part) { ICSOQCCKGROUP g = ICSOQCCKLISTBLL.isExits(p.objNo); if (g == null) { g = new ICSOQCCKGROUP(); g.ID = AppConfig.GetGuid(); g.ISREF = "是"; g.MTIME = DateTime.Now; g.MUSER = AppConfig.UserId; g.MUSERName = AppConfig.UserName; g.CKGROUP = AppConfig.GetSerialCode(AppConfig.AppConnectString, AppConfig.WorkPointCode, "ICSOQCCKGROUP", "CKGROUP", "A" + DateTime.Now.Year.ToString(), 3); g.CKGROUPDESC = p.objNo.Split(',')[1]; g.WorkPoint = AppConfig.WorkPointCode; g.CKGROUPDNAME = p.objNo.Split(',')[0]; group.Add(g); } ICSOQCCKLIST c = ICSOQCCKLISTBLL.IsExistCKLIST(p.objId); if (c == null || (c != null && Convert.ToDateTime(c.EATTRIBUTE1) < Convert.ToDateTime(string.IsNullOrEmpty(p.mtimestr) ? p.ctimestr : p.mtimestr))) { c = new ICSOQCCKLIST(); c.ID = p.objId; c.CKGROUPCode = g.CKGROUP; c.UNIT = p.extra.DW; c.WorkPoint = AppConfig.WorkPointCode; c.SetValueMax = string.IsNullOrEmpty(p.extra.SX) ? 0 : Convert.ToDecimal(p.extra.SX); c.SetValueMin = string.IsNullOrEmpty(p.extra.XX) ? 0 : Convert.ToDecimal(p.extra.XX); c.MUSER = AppConfig.UserName; c.MTIME = DateTime.Now; c.ISREF = "是"; c.INVCode = p.extra.MPARTNO; c.OPCode = opcode; c.CKGROUPMETH = "工序检验"; c.CKGROUPATTR = p.extra.SX1; c.GJ = p.extra.GJ; c.JY1 = p.extra.JY1; c.JY2 = p.extra.JY2; c.PType = Convert.ToDecimal(p.extra.PTYPE); c.StandValue = p.extra.NAME; if (!string.IsNullOrEmpty(p.mtimestr)) c.EATTRIBUTE1 = p.mtimestr; else c.EATTRIBUTE1 = p.ctimestr;
cklist.Add(c); }
RemoveID.Add(p.objId);
} ICSOQCCKLISTBLL.AddGroupAndList(group, cklist, RemoveID, itemcode, opcode); } else { if (jobject["msg"].ToString() != "没有更多了") throw new Exception(jobject["msg"].ToString()); } } catch (Exception ex) { throw ex;
}
}
public class Parts { public string errcode { get; set; } public string errmsg { get; set; } public string objId { get; set; } public string objNo { get; set; } public string fname { get; set; } public string suffix { get; set; } public string hasAffine { get; set; } public string name { get; set; } public string fsize { get; set; } public string fsizeStr { get; set; } public string type { get; set; } public string tablename { get; set; } public string smemo { get; set; } public string ctimestr { get; set; } public string mtimestr { get; set; } public string creator { get; set; } public string modifier { get; set; } public string ver { get; set; } public string stimestr { get; set; } public string etimestr { get; set; } public Extra extra { get; set; } public string searchText { get; set; } }
public class Extra { public string PTYPE; public string XX; public string NAME; public string SX; public string DW; public string JY2; public string SX1; public string GJ; public string JY1; public string GG; public string SMEMO; public string MPARTNO;
}
private void txtItemCode_TextChanged(object sender, EventArgs e) {
}
private void txtLotNo_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (txtUserCode.Text.Trim() == "" || txtEQPCode.Text.Trim() == "") { ICSBaseSimpleCode.AppshowMessageBox("请先输入员工条码和设备!"); return; } string usercode = txtUserCode.Text.Trim(); string eqpcode = txtEQPCode.Text.Trim(); string username = txtUserName.Text.Trim(); string eqpname = txtMachineName.Text.Trim(); ButtonEdit btn = (ButtonEdit)sender; string sql = @"select distinct a.LOTNO AS 产品跟踪单 from ICSMO2User a
left join ICSLOTONWIP b on a.LOTNO=b.LOTNO and a.OPCODE=b.OPCODE where (b.ACTIONRESULT is null or ACTIONRESULT='COLLECT_BEGIN') and a.usercode='"+ txtUserCode.Text.Trim()+@"' and a.eqpcode='"+ txtEQPCode.Text.Trim()+@"' order By a.lotno desc ";
sql = string.Format(sql); DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0]; FormDataRefer reForm = new FormDataRefer(); reForm.FormTitle = "产品跟踪单"; DataTable menuData = data; reForm.DataSource = menuData; reForm.MSelectFlag = false; reForm.RowIndexWidth = 35; reForm.HideCols.Add("ID"); reForm.FormWidth = 800; reForm.FormHeight = 600; if (reForm.ShowDialog() == DialogResult.OK) { DataTable retData = reForm.ReturnData; foreach (DataRow dr in retData.Rows) { txtLotNo.Text = dr["产品跟踪单"].ToString(); } txtLotNo_KeyPress(null, new KeyPressEventArgs(Convert.ToChar(Keys.Enter))); txtUserCode.Text = usercode; txtEQPCode.Text = eqpcode; txtMachineName.Text = eqpname; txtUserName.Text = username;
}
}
private void txtOPCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (string.IsNullOrEmpty(txtLotNo.Text.Trim())) { ICSBaseSimpleCode.AppshowMessageBox("请先输入产品跟踪单!"); return; }
ButtonEdit btn = (ButtonEdit)sender; string sql = @"select DISTINCT a.OPCODE as 工序,b.opdesc as 名称 from ICSMO2User a left join icsop b on a.OPCODE=b.OPCODE WHERE LOTNO='"+txtLotNo.Text.Trim()+"' and a.usercode='"+txtUserCode.Text.Trim()+@"' and a.eqpcode='"+txtEQPCode.Text.Trim()+@"' "; sql = string.Format(sql); DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0]; FormDataRefer reForm = new FormDataRefer(); reForm.FormTitle = "工序"; DataTable menuData = data; reForm.DataSource = menuData; reForm.MSelectFlag = false; reForm.RowIndexWidth = 35; reForm.HideCols.Add("ID"); reForm.FormWidth = 800; reForm.FormHeight = 600; if (reForm.ShowDialog() == DialogResult.OK) { DataTable retData = reForm.ReturnData; foreach (DataRow dr in retData.Rows) { txtOPCode.Text = dr["工序"].ToString();
} txtOPCode_KeyPress(null, new KeyPressEventArgs(Convert.ToChar(Keys.Enter))); }
}
private string GetLotNoOp(string lotno) {
string sql = @"select A.OPCODE,B.OPSEQ,a.CollectStatus,a.LOTNO from ICSLOTSIMULATION A
LEFT JOIN ICSITEMROUTE2OPLot B ON A.LOTNO = B.LotNo and a.OPCODE = b.OPCODE where a.lotno='"+lotno+"'";
DataTable table = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
sql = "select opcode,opseq from ICSITEMROUTE2OPLot where lotno='"+lotno+"' order by opseq"; DataTable Optable= DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
if (table.Rows.Count <= 0) { return Optable.Rows[0]["opcode"].ToString();
} else { if (table.Rows[0]["CollectStatus"].ToString() == "COLLECT_BEGIN") { return table.Rows[0]["OPCODE"].ToString(); } else if (table.Rows[0]["CollectStatus"].ToString() == "COLLECT_END") { //判断是否检验合格
int opseq = Convert.ToInt32(table.Rows[0]["OPSEQ"].ToString()); int opseq_ = opseq + 10; if (CheckIsOK(opseq)) {
string opcode = Optable.AsEnumerable().Where(a => a["opseq"].ToString() == opseq_.ToString()).Select(a => a["opcode"].ToString()).FirstOrDefault(); if (opcode != null) { return opcode; } else return "";
} else return "";
} else return "";
}
} } }
|