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 Newtonsoft.Json; using Newtonsoft.Json.Linq; using ICSSoft.Frame.Common; namespace ICSSoft.Frame.APP { public partial class FormICSIPQCAGVHH : DevExpress.XtraEditors.XtraForm { private string sqltxt = ""; private string sqlconn = ""; private string CCNCRresult = ""; private string WGNCRresult = ""; 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; string RouteCode = ""; string opseq = ""; Decimal TotalQty = 0; Decimal YLOTQTY = 0; Decimal UYLOTQTY = 0; string OPCode = string.Empty; //0906 string status1 = ""; string status2 = ""; #region 构造函数 public FormICSIPQCAGVHH() { InitializeComponent(); this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); this.WindowState = FormWindowState.Maximized; checkboxGX.Checked = true; } #endregion #region 构造函数 public FormICSIPQCAGVHH(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; txtUserName.Text = ItemCode = _ItemCode; //txtItemName.Text = ItemName = _ItemName; txtLotNo.Text = LotNo = _LotNo; //txtItemINVDESC.Text = INVDESC = _INVDESC; //txtTotalQty.Text = _TotalQty.ToString(); txtProductCode.Text = _ItemCode; txtPriductName.Text = _ItemName; txtMOCode.Text = ""; TotalQty = _TotalQty; RCVCode = _RCVCode; Decimal YLOTQTY = _YLOTQTY; Decimal UYLOTQTY = _UYLOTQTY; init(); BandData(ItemCode, LotNo, OPCode); } public FormICSIPQCAGVHH(string _ItemCode, string _LotNo, string OPCode) { InitializeComponent(); this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); this.WindowState = FormWindowState.Maximized; txtUserName.Text = ItemCode = _ItemCode; txtLotNo.Text = LotNo = _LotNo; //txtItemINVDESC.Text = INVDESC = _INVDESC; //txtTotalQty.Text = _TotalQty.ToString(); txtProductCode.Text = _ItemCode; //txtPriductName.Text = _ItemName; //txtMOCode.Text = ""; //TotalQty = _TotalQty; //RCVCode = _RCVCode; //Decimal YLOTQTY = _YLOTQTY; Decimal UYLOTQTY = _UYLOTQTY; init(); BandData(ItemCode, LotNo, OPCode); initCheck(); } #endregion #region 初始化查询条件 private void init() { #region string sql = @"SELECT DISTINCT b.CKGROUPDESC,a.InspectionStandard CKGROUPDNAME, a.CKListCode CKGROUPCode,a.VALUEMAX SetValueMax,a.VALUEMIN SetValueMin,a.CheckResultValue CheckResult,a.IsOK,a.CCorWGResult FROM ICSOQCCKGROUP2LISTCheckResult a LEFT JOIN ICSOQCCKGROUP b ON a.CKListCode=b.CKGROUP WHERE a.LOTNO='" + txtLotNo.Text + "' AND a.OPCode='" + txtOPCode.Text + "' and CheckoutAttribute='量化' "; 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) { gridControlcc.DataSource = dt; if (dt != null && dt.Rows.Count > 0) { bool istrue = false; foreach (DataRow item in dt.Rows) { string resultCC = item["CCorWGResult"].ToString(); if (resultCC == "NG") { istrue = false; break; } if (resultCC == "OK") { istrue = true; } } if (istrue) { this.txtCCResult.Text = "OK"; this.txtCCResult.BackColor = Color.Blue; } else { this.txtCCResult.Text = "NG"; this.txtCCResult.BackColor = Color.Red; } } } else { string _OQCSql = @"SELECT DISTINCT a.SetValueMax,a.SetValueMin,a.CKGROUPCode,b.CKGROUPDESC,b.CKGROUPDNAME,a.EATTRIBUTE1 Remark,'' CheckResult FROM ICSOQCCKLIST a LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP WHERE INVCode='" + txtProductCode.Text + "' AND a.CKGROUPATTR='量化' and a.ISREF='是' AND a.OPCode='" + this.txtOPCode.Text + "' and a.CKGROUPMETH ='工序检验' ";//0906 DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0]; gridControlcc.DataSource = _OQCdt; } //} #endregion string sql2 = @"SELECT DISTINCT b.CKGROUPDESC CKGROUPDESC1,a.InspectionStandard CKGROUPMETH,a.AQL CKGROUPATTR, a.CKListCode CKGROUPCode1,a.CheckResultValue, CAST (ISNULL(a.IsOK, 0) AS BIT) AS OK FROM ICSOQCCKGROUP2LISTCheckResult a LEFT JOIN ICSOQCCKGROUP b ON a.CKListCode=b.CKGROUP WHERE a.LOTNO='" + txtLotNo.Text + "' AND a.OPCode='" + txtOPCode.Text + "' and CheckoutAttribute='外观' AND a.InspectionStandard ='工序检验' "; 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) { gridControl2.DataSource = dt2; if (dt2 != null && dt2.Rows.Count > 0) { bool istrue = false; foreach (DataRow item in dt2.Rows) { //string resultCC = item["CCorWGResult"].ToString(); string resultCC = item["OK"].ToString(); //if (resultCC == "NG") if (resultCC == "False") { istrue = false; break; } //if (resultCC == "OK") if (resultCC == "True") { istrue = true; } } if (istrue) { this.txtWGResult.Text = "OK"; this.txtWGResult.BackColor = Color.Blue; } else { this.txtWGResult.Text = "NG"; this.txtWGResult.BackColor = Color.Red; } } } else { string _OQCWGSql = @"SELECT DISTINCT a.CKGROUPATTR,a.CKGROUPMETH,a.CKGROUPCode CKGROUPCode1,b.CKGROUPDESC CKGROUPDESC1,b.CKGROUPDNAME,a.EATTRIBUTE1 Remark1,CAST (ISNULL(0, 0) AS BIT) AS OK , CAST (ISNULL(0, 0) AS BIT) AS NG FROM ICSOQCCKLIST a LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP WHERE INVCode='" + txtProductCode.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]; gridControl2.DataSource = _OQCWGdt; } } // private void initCheck() // { // string _OQCSql = @"SELECT a.SetValueMax,a.SetValueMin,a.CKGROUPCode,b.CKGROUPDESC,b.CKGROUPDNAME,a.EATTRIBUTE1 Remark,'' CheckResult FROM ICSOQCCKLIST a //LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP //WHERE INVCode='" + ItemCode + "' AND a.CKGROUPATTR='量化' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH!='自主检验' ";// // DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0]; // gridControlcc.DataSource = _OQCdt; // string _OQCWGSql = @"SELECT a.CKGROUPATTR,a.CKGROUPMETH,a.CKGROUPCode CKGROUPCode1,b.CKGROUPDESC CKGROUPDESC1,b.CKGROUPDNAME,a.EATTRIBUTE1 Remark1,CAST (ISNULL(0, 0) AS BIT) AS OK , //CAST (ISNULL(0, 0) AS BIT) AS NG FROM ICSOQCCKLIST a //LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP //WHERE INVCode='" + ItemCode + "' AND a.CKGROUPATTR='外观' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH!='自主检验' ";// // DataTable _OQCWGdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCWGSql).Tables[0]; // gridControl2.DataSource = _OQCWGdt; // } 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]; gridControl2.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)) { axAcroPDFTZ.LoadFile(fileName); axAcroPDFTZ.setShowToolbar(false); axAcroPDFTZ.setShowScrollbars(false); axAcroPDFTZ.setPageMode("thumbs"); axAcroPDFTZ.setLayoutMode("SinglePage"); axAcroPDFTZ.setView("Fit"); axAcroPDFTZ.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 ControlList = new List(); //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); txtUserName.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); } #endregion //private void simpleButton1_Click(object sender, EventArgs e) //{ // string id = ""; // List editList = new List(); // for (int i = 0; i < grvDetail.RowCount; i++) // { // if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y") // { // id = grvDetail.GetRowCellValue(i, colID).ToString(); // editList.Add(id); // } // } // if (editList.Count != 1) // { // ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!"); // return; // } // try // { // FormICSOQCCKGROUP2LISTAdd add = new FormICSOQCCKGROUP2LISTAdd(id); // add.ShowDialog(); // btnRefresh_Click(null, null); // } // catch (Exception ex) // { // ICSBaseSimpleCode.AppshowMessageBox(ex.Message); // } //} #region 导入模板下载 private void btnImportMould_Click(object sender, EventArgs e) { DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm(); _wait.Hide(); string anjianExcelFileName = Environment.CommandLine.Substring(1, Environment.CommandLine.LastIndexOf("\\")) + "Output\\"; try { _wait.Show(); _wait.Caption = "模板下载中......"; SaveFileDialog dlgSaveFileDialog = new SaveFileDialog(); //弹框提示保存 dlgSaveFileDialog.InitialDirectory = anjianExcelFileName; //默认打开目录 dlgSaveFileDialog.FilterIndex = 1; dlgSaveFileDialog.RestoreDirectory = true; dlgSaveFileDialog.FileName = "IQC检验关联导入模板.xlsx"; //默认保存名称 dlgSaveFileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx"; if (dlgSaveFileDialog.ShowDialog() == DialogResult.OK) { string fileName = dlgSaveFileDialog.FileName; //获取弹出框选择或填写的文件名称 List colNameList = new List(); colNameList.Add(new FormReadExcelUIModelColumns("物料遍码", true)); colNameList.Add(new FormReadExcelUIModelColumns("检验项目组编码", false)); colNameList.Add(new FormReadExcelUIModelColumns("检验项目编码", false)); colNameList.Add(new FormReadExcelUIModelColumns("抽样标准", false)); colNameList.Add(new FormReadExcelUIModelColumns("检验属性", false)); colNameList.Add(new FormReadExcelUIModelColumns("检验标准", false)); colNameList.Add(new FormReadExcelUIModelColumns("最大值", false)); colNameList.Add(new FormReadExcelUIModelColumns("最小值", false)); colNameList.Add(new FormReadExcelUIModelColumns("单位", false)); colNameList.Add(new FormReadExcelUIModelColumns("是否使用", false)); colNameList.Add(new FormReadExcelUIModelColumns("检验方式", false)); colNameList.Add(new FormReadExcelUIModelColumns("工序编码", false)); colNameList.Add(new FormReadExcelUIModelColumns("首检是否必检", false)); FileUtil.exportToExcelFile(fileName, colNameList); _wait.Close(); ICSBaseSimpleCode.AppshowMessageBox("模板下载成功!"); } _wait.Close(); } catch (Exception ex) { _wait.Close(); ICSBaseSimpleCode.AppshowMessageBox("模板下载失败:" + ex.Message); } } #endregion #region 导入 private void btnImportData_Click(object sender, EventArgs e) { SimpleButton btntemp = (SimpleButton)sender; if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false) { ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!"); return; } DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm(); _wait.Hide(); try { FormReadExcel fre = new FormReadExcel(); if (fre.ShowDialog() != DialogResult.OK) { return; } DataTable dataSource = fre._excelData; if (dataSource == null) { throw new Exception("excel数据取得失败"); } _wait.Show(); _wait.Caption = "判断模版是否正确......"; #region 判断模版是否正确 List colNameList = new List(); colNameList.Add(new FormReadExcelUIModelColumns("物料遍码", true)); colNameList.Add(new FormReadExcelUIModelColumns("检验项目组编码", false)); colNameList.Add(new FormReadExcelUIModelColumns("检验项目编码", false)); colNameList.Add(new FormReadExcelUIModelColumns("抽样标准", false)); colNameList.Add(new FormReadExcelUIModelColumns("检验属性", false)); colNameList.Add(new FormReadExcelUIModelColumns("检验标准", false)); colNameList.Add(new FormReadExcelUIModelColumns("最大值", false)); colNameList.Add(new FormReadExcelUIModelColumns("最小值", false)); colNameList.Add(new FormReadExcelUIModelColumns("单位", false)); colNameList.Add(new FormReadExcelUIModelColumns("是否使用", false)); colNameList.Add(new FormReadExcelUIModelColumns("检验方式", false)); colNameList.Add(new FormReadExcelUIModelColumns("工序编码", false)); colNameList.Add(new FormReadExcelUIModelColumns("首检是否必检", false)); foreach (FormReadExcelUIModelColumns columnsName in colNameList) { if (!dataSource.Columns.Contains(columnsName.columnsName)) { throw new Exception("模版不正确,缺少列" + columnsName.columnsName); } } #endregion _wait.Caption = "数据整理中......"; List InfoList = new List(); foreach (DataRow dr in dataSource.Rows) { ///判断必输项目是否为空 foreach (FormReadExcelUIModelColumns columnsName in colNameList) { if (string.IsNullOrWhiteSpace(dr[columnsName.columnsName].ToString()) == true && columnsName.NotNull == true) { throw new Exception("列" + columnsName.columnsName + "没有输入值"); } } ICSIPQCKGROUP2LIST Info = new ICSIPQCKGROUP2LIST(); Info.CKITEMCODE = dr["物料遍码"].ToString(); Info.CKListCode = dr["检验项目编码"].ToString(); Info.CKGROUP = dr["检验项目组编码"].ToString(); Info.InspectionStandard = dr["检验标准"].ToString(); Info.AQL = dr["抽样标准"].ToString(); Info.CheckoutAttribute = dr["检验属性"].ToString(); Info.UNIT = dr["单位"].ToString(); if (!string.IsNullOrWhiteSpace(dr["最大值"].ToString())) { Info.VALUEMAX = Decimal.Parse(dr["最大值"].ToString()); } if (!string.IsNullOrWhiteSpace(dr["最小值"].ToString())) { Info.VALUEMIN = Decimal.Parse(dr["最小值"].ToString()); } if (!string.IsNullOrWhiteSpace(dr["是否使用"].ToString())) { if (dr["是否使用"].ToString().Length > 2) { Info.IsUse = 0; } else { Info.IsUse = 1; } } Info.CKWay = dr["检验方式"].ToString(); Info.OPCode = dr["工序编码"].ToString(); if (!string.IsNullOrWhiteSpace(dr["首检是否必检"].ToString())) { if (dr["首检是否必检"].ToString().Length > 2) { Info.IsUse = 0; } else { Info.IsUse = 1; } } Info.MUSER = AppConfig.UserCode; Info.MUSERName = AppConfig.UserName; Info.WorkPoint = AppConfig.WorkPointCode; Info.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString()); InfoList.Add(Info); } _wait.Caption = "导入数据......"; ICSIPQCKGROUP2LISTBLL.AddAndEditList(InfoList, AppConfig.AppConnectString); _wait.Close(); ICSBaseSimpleCode.AppshowMessageBox("导入成功!"); //btnRefresh_Click(null, null); } catch (Exception ex) { _wait.Close(); ICSBaseSimpleCode.AppshowMessageBox("数据导入失败:" + ex.Message); } } #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(); } //0906 不合格传入NCR private void SendNCR(List 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 20201202 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; //产品跟踪码0910 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); } } #region IPQC保存 private void btnTempSave_Click(object sender, EventArgs e) { try { //0906 List codeList = new List(); string strResult = ""; decimal QTY = 1;//批次数量 #region if (checkboxGX.Checked == false && checkboxWW.Checked == false) { SetMessage("请选择工序检验或者委外检验!!!!", Color.Red); return; } #endregion //if (gridViewCC == null || gridViewCC.RowCount == 0 || gridView2 == null || gridView2.RowCount == 0) //{ // SetMessage("当前工序没有检验的基础信息!", Color.Red); // return; //} List InfoList = new List(); for (int k = 0; k < gridViewCC.RowCount; k++) { if (gridViewCC.RowCount > 0) { if (string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(k, StandResult).ToString())) { SetMessage("存在未填写的标准检测值!请确认!", Color.Red); 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"))) { SetMessage("存在检验项目未勾选合格或不合格!请确认!", Color.Red); return; } //update 保存尺寸检验信息 zhuqy 2023-11-16 string CKGROUPCode = gridViewCC.GetRowCellValue(k, colCKGROUPCode).ToString(); string Result = ""; if (!string.IsNullOrEmpty(ok)) { Result = "OK"; } else { Result = "NG"; } ICSQualityCKDATADetail CCInfo = new ICSQualityCKDATADetail(); CCInfo.EATTRIBUTE2 = CKGROUPCode; CCInfo.CKResult = Result; CCInfo.DECKResult = Result; InfoList.Add(CCInfo); } } //update 保存外观检验信息 zhuqy 2023-11-16 for (int k = 0; k < gridView2.RowCount; k++) { if (gridView2.RowCount > 0) { string CKGROUPCode = gridView2.GetRowCellValue(k, colCKGROUPCode1).ToString(); string ok = gridView2.GetRowCellValue(k, colOK).ToString(); string ng = gridView2.GetRowCellValue(k, colNotOK).ToString(); if ((string.IsNullOrEmpty(ok) && string.IsNullOrEmpty(ng) || (ok == "False" && ng == "False"))) { SetMessage("存在检验项目未勾选合格或不合格!请确认!", Color.Red); return; } string Result = ""; if (!string.IsNullOrEmpty(ok)) { Result = "OK"; } else { Result = "NG"; } ICSQualityCKDATADetail WGInfo = new ICSQualityCKDATADetail(); WGInfo.EATTRIBUTE2 = CKGROUPCode; WGInfo.CKResult = Result; WGInfo.DECKResult = Result; InfoList.Add(WGInfo); } } string sql1 = "select * from ICSLOTSIMULATION where lotno='" + txtLotNo.Text.Trim() + "' and LOTSTATUS='暂停'"; DataTable tbale = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0]; if (tbale.Rows.Count > 0) { ICSBaseSimpleCode.AppshowMessageBox("该追踪单号对应工序完工检验信息不合格!无法进行质量检验!"); return; } // string sql = @"SELECT DISTINCT a.OPCode,c.CCorWGResult, // b.RouteCode,f.OPSEQ,d.LOTStatus, // CASE d.CollectStatus // WHEN 'COLLECT_BEGIN' THEN 'WG' // WHEN 'COLLECT_END' THEN 'KG' // ELSE '' END AS Status // 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 ICSITEMROUTE2OPLot f ON f.lotno = b.lotno // AND f.OPCODE = a.OPCODE // LEFT JOIN ICSOQCCKGROUP2LISTCheckResult c ON c.LotNo=b.LOTNO AND c.OPCode=b.OPCODE // WHERE b.LOTNO = '" + txtLotNo.Text + "' order by f.OPSEQ "; // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; // int _OPSEQ = 0; // if (data.Rows.Count > 0) // { // foreach (DataRow dr in data.Rows) // { // if (txtOPCode.Text == dr["OPCODE"].ToString()) // { // string OPSEQ = dr["OPSEQ"].ToString(); // _OPSEQ = Int32.Parse(OPSEQ) - 10; // } // } // } //查询上一道工序是否检验 20240612 string sql = @"SELECT TOP 1 ROUTECODE, OPCODE, OPSEQ FROM ICSITEMROUTE2OPLot WHERE LOTNO = '{0}' AND OPSEQ<( SELECT OPSEQ FROM ICSITEMROUTE2OPLot WHERE LOTNO = '{0}' AND OPCode='{1}') ORDER BY OPSEQ DESC"; sql = string.Format(sql, txtLotNo.Text, txtOPCode.Text); DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0]; int _OPSEQ = 0; if (data.Rows.Count > 0) { _OPSEQ = Int32.Parse(data.Rows[0]["OPSEQ"].ToString()); } bool isOK = CheckIsOK(_OPSEQ); if (!isOK) { SetMessage("上道工序检验结果不合格,不能开工!", Color.Red); return; } #region #region 20210707新增当前工序是否已经报工,没有报工不允许检验 string checkSQL = @"SELECT DISTINCT CASE d.ACTIONRESULT WHEN 'COLLECT_BEGIN' THEN 'WG' WHEN 'COLLECT_END' THEN 'KG' ELSE '' END AS Status FROM ICSOP a WITH (nolock) LEFT JOIN ICSMO2User b WITH (nolock) ON a.OPCODE = b.OPCODE LEFT JOIN ICSLOTONWIP d WITH (nolock) ON b.LOTNO = d.LOTNO AND b.OPCODE = d.OPCODE LEFT JOIN ICSITEMROUTE2OPLot f ON f.lotno = b.lotno AND f.OPCODE = a.OPCODE LEFT JOIN ICSOQCCKGROUP2LISTCheckResult c ON c.LotNo=b.LOTNO AND c.OPCode=b.OPCODE WHERE b.LOTNO = '" + txtLotNo.Text + "' and a.OPCode='" + txtOPCode.Text + "' "; DataTable Checkdata = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, checkSQL).Tables[0]; if (Checkdata != null && Checkdata.Rows.Count > 0) { string Status = Checkdata.Rows[0]["Status"].ToString(); if (Status != "KG") { SetMessage("当前工序还没有完工,不能检验!", Color.Red); return; } } else { SetMessage("当前工序还没有开工,不能检验!", Color.Red); return; } #endregion ICSQualityCKDATA QualityCKDATA = new ICSQualityCKDATA(); QualityCKDATA.EATTRIBUTE3 = "";//参与人 QualityCKDATA.LOTNO = LotNo; QualityCKDATA.SEQ = _OPSEQ + 10; QualityCKDATA.OPCode = this.txtOPCode.Text.Trim(); QualityCKDATA.MOCODE = txtMOCode.Text.Trim(); QualityCKDATA.CKUserCode = txtUserCode.Text.Trim(); ICSLOTONWIPCheck ICSLOTONWIPCheck = new ICSLOTONWIPCheck(); if (checkboxGX.Checked) { QualityCKDATA.Type = "GX"; } if (checkboxWW.Checked) { QualityCKDATA.Type = "WW"; } if ((txtCCResult.Text == "OK" || string.IsNullOrEmpty(txtCCResult.Text)) && (txtWGResult.Text == "OK" || string.IsNullOrEmpty(txtWGResult.Text))) { QualityCKDATA.CKResult = "1"; //9月18号添ICSLOTONWIPCheck表格 ICSLOTONWIPCheck.Result = "合格"; } else { QualityCKDATA.CKResult = "0"; //9月18号添ICSLOTONWIPCheck表格 ICSLOTONWIPCheck.Result = "不合格"; //0906判退到NCR if (!codeList.Contains(LotNo)) { strResult += "产品追踪单:" + LotNo + " " + CCNCRMes() + " " + WWNCRMes(); codeList.Add(LotNo); } string itemcode = txtProductCode.Text; string OPCODE = txtOPCode.Text; string MOCODE = txtMOCode.Text; LotNo = txtLotNo.Text; // LotNo = ""; QTY = Convert.ToDecimal(txtLotQty.Text); SendNCR(codeList, strResult, QTY, itemcode, MOCODE, OPCODE, LotNo); } List entityList = new List(); 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)) { SetMessage("尺寸还没有检验,请核对!!!!", Color.Red); return; } } //entity.CKITEMCODE = txtUserName.Text;// gridViewCC.GetRowCellValue(k, colCKITEMCODE).ToString(); entity.CKListCode = gridViewCC.GetRowCellValue(k, colCKGROUPCode).ToString(); entity.RCVCode = RCVCode; entity.LotNo = LotNo; entity.CKITEMCODE = ItemCode; entity.INVDESC = INVDESC; entity.CheckoutAttribute = "量化"; 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(txtLotQty.Text);//合格数 } else { entity.UnQualified = Decimal.Parse(txtLotQty.Text); ;//不合格数 } if (this.checkboxGX.Checked == true) { entity.GXorWWCheck = "GX"; } else { entity.GXorWWCheck = "WW"; } 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); } for (int k = 0; k < gridView2.RowCount; k++) { ICSOQCCKGROUP2LISTCheckResult entity = new ICSOQCCKGROUP2LISTCheckResult(); #region MyRegion if (gridView2.RowCount > 0) { if (string.IsNullOrWhiteSpace(txtWGResult.Text)) { SetMessage("外观还没有检验,请核对!!!!", Color.Red); return; } } #endregion //entity.CKITEMCODE = txtUserName.Text;// gridViewCC.GetRowCellValue(k, colCKITEMCODE).ToString(); entity.CKListCode = gridView2.GetRowCellValue(k, colCKGROUPCode1).ToString(); entity.RCVCode = RCVCode; entity.LotNo = LotNo; entity.CKITEMCODE = ItemCode; entity.INVDESC = INVDESC; entity.CheckoutAttribute = "外观"; entity.CCorWGResult = txtWGResult.Text; entity.AQL = gridView2.GetRowCellValue(k, colCKGROUPATTR).ToString(); entity.InspectionStandard = gridView2.GetRowCellValue(k, colCKGROUPMETH).ToString(); if (this.checkboxGX.Checked == true) { entity.GXorWWCheck = "GX"; } else { entity.GXorWWCheck = "WW"; } if (gridView2.GetRowCellValue(k, colOK).ToString() == "True") { entity.IsOK = 1; } else { entity.IsOK = 0; } if (txtWGResult.Text == "OK") { entity.Qualified = Decimal.Parse(txtLotQty.Text);//合格数 } else { entity.UnQualified = Decimal.Parse(txtLotQty.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 try { //ICSIPQCBLL.AddAndEditList(entityList, AppConfig.AppConnectString); //if (entityList != null && entityList.Count > 0) //{ //} FramDataContext db = ICSDataCollectionBLL.AddAndEditList(QualityCKDATA, entityList, InfoList, AppConfig.AppConnectString, true); //9.18新增 ICSDataCollectionBLL.save2ICSLOTONWIPCheck(ICSLOTONWIPCheck, QualityCKDATA, AppConfig.AppConnectString, db); //this.Close(); //ICSBaseSimpleCode.AppshowMessageBox("保存成功"); bool Islastop = ICSAGVBLL.IsLastOP(LotNo, this.txtOPCode.Text.Trim(), AppConfig.AppConnectString, AppConfig.WorkPointCode); if (ICSAGVBLL.IsCanToAGV(LotNo, this.txtOPCode.Text.Trim(), "AGV是否开启", AppConfig.AppConnectString, AppConfig.WorkPointCode) && !Islastop && ICSLOTONWIPCheck.Result == "合格") { try { ICSAGVTASKLOG Log = new ICSAGVTASKLOG(); Log.ID = AppConfig.GetGuid(); Log.Lotno = LotNo; Log.Opcode = this.txtOPCode.Text.Trim(); ; Log.Itemcode = ItemCode; bool NextOpIsWW = ICSAGVBLL.NextOPisWW(LotNo, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode); bool NextOpIsWG = ICSAGVBLL.NextOPisWG(LotNo, Log.Opcode, AppConfig.AppConnectString, AppConfig.WorkPointCode); string Area = ""; string CArea = ""; if (!(NextOpIsWW && checkboxWW.Checked && NextOpIsWG)) { if (ICSLOTONWIPCheck.Result == "合格") { //if (Islastop) //{ // FormICSAGVAreaChoose Choose = new FormICSAGVAreaChoose(true); // Choose.ShowDialog(); // Area = ICSAGVBLL.GetAreaCode("00088", "4", AppConfig.AppConnectString, AppConfig.WorkPointCode); // CArea = Choose.AreaCode; // Log.TaskType = "成品检合格HH"; //} //需要注意连续委外逻辑,当前工序和下道工序为连续委外,当前工序不触发AGV if (NextOpIsWW) { Area = ICSAGVBLL.GetAreaCode("00088", "6", AppConfig.AppConnectString, AppConfig.WorkPointCode); Log.TaskType = "质检合格下工序委外HH"; } else { Area = ICSAGVBLL.GetAreaCode("00088", "2", AppConfig.AppConnectString, AppConfig.WorkPointCode); Log.TaskType = "质检合格HH"; } } else { Area = ICSAGVBLL.GetAreaCode("00088", "3", AppConfig.AppConnectString, AppConfig.WorkPointCode); Log.TaskType = "质检不合格HH"; } string BeginArea = Area.Split('@')[0].Split(':')[0]; string EndArea = Area.Split('@')[1].Split(':')[0]; AGVCreateTaskModel model = new AGVCreateTaskModel(); model.area = EndArea.Split(':')[0]; model.qty = (int)Convert.ToDecimal(txtLotQty.Text); //model.station = BeginArea.Split(':')[0]; model.type = "false"; model.materialCode = ItemCode; model.materialName = txtPriductName.Text; model.trackingNumber = Log.Lotno; model.orderCode = txtMOCode.Text; model.warehouseCode = "KS0001"; Log.LocationCode = BeginArea; Log.EndArea = EndArea; Log.Mtime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Log.MuserName = AppConfig.UserName; FormICSAGVContainer container = new FormICSAGVContainer(model, Log); container.ShowDialog(); } } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox("AGV任务异常:" + ex.Message); } } SetMessage("保存成功!!!!", Color.Blue); Clear(true); return; } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); } } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); } } #endregion private bool CheckIsOK(int OPSEQ) { bool isfalse = false; string _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 isnull(CC.RESULT,'')<>'合格' "; DataTable _OQCdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql).Tables[0]; if (_OQCdt != null && _OQCdt.Rows.Count > 0) { isfalse = false; } else { isfalse = true; } return isfalse; } private bool CheckIsDecmil(string KeyValue) { try { Decimal.Parse(KeyValue); return true; } catch (Exception ex) { return false; } } private void gridViewCC_KeyUp(object sender, KeyEventArgs e) { } private void gridView2_KeyUp(object sender, KeyEventArgs 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++) { #region MyRegion bool _S1 = 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 (_S1 && gridView2.FocusedColumn.Caption == "合格") { istrue = true; } else { 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 void txtUserCode_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { string UserCode = txtUserCode.Text.Trim(); string sql = @"select UserName from Sys_User where UserCode='{0}'"; sql = string.Format(sql, UserCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0]; if (dt.Rows.Count == 0) { SetMessage("员工条码不存在,请确认后重新输入!", Color.Red); return; } else { txtUserName.Text = dt.Rows[0][0].ToString(); } SetMessage("员工条码扫描成功!", Color.Blue); return; } } //消息提示 private void SetMessage(string Msg, Color color) { txtMessage.Text = Msg; txtMessage.ForeColor = color; } //2.2. 工序条码:扫描完产品跟踪单后才能选择;下拉,只能选择到该产品跟踪单下对应的工序信息; //批次条码的对应的关系 //物料条码 private void txtLotNo_KeyPress_1(object sender, KeyPressEventArgs e) { try { #region` if (e.KeyChar == (char)Keys.Enter) { #region string chksql = @"select a.LotNO,a.MCODE ItemCODE,b.INVNAME,a.LOTQTY ,a.TransNO,c.MOPLANQTY from ICSITEMLot a WITH (nolock) LEFT JOIN ICSINVENTORY b WITH (nolock) ON a.MCODE = b.INVCODE LEFT JOIN ICSMO c WITH (nolock) ON a.TransNO = c.MOCODE AND a.TransLine=c.MOSEQ where a.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; } txtProductCode.Text = dt.Rows[0]["ItemCODE"].ToString(); string itemCode = dt.Rows[0]["ItemCODE"].ToString(); txtPriductName.Text = dt.Rows[0]["INVNAME"].ToString(); txtLotQty.Text = dt.Rows[0]["LOTQTY"].ToString(); LotNo = dt.Rows[0]["LotNO"].ToString(); txtMOCode.Text = dt.Rows[0]["TransNO"].ToString(); txtMOQty.Text = dt.Rows[0]["MOPLANQTY"].ToString(); #region 工序 string __sql = @"SELECT b.OPCODE 工序编码,c.OPDESC 工序名称 FROM ICSITEM2ROUTE a INNER JOIN ICSROUTE2OP b ON b.ROUTECODE=a.ROUTECODE INNER JOIN ICSOP c ON b.OPCODE=c.OPCODE WHERE a.ITEMCODE='" + itemCode + "' AND a.WorkPoint='{0}' ORDER BY b.OPSEQ"; __sql = string.Format(__sql, AppConfig.WorkPointCode); DataTable __dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, __sql).Tables[0]; txtOPCode_.Properties.ValueMember = "工序编码"; txtOPCode_.Properties.DisplayMember = "工序编码"; txtOPCode_.Properties.DataSource = __dt; txtOPCode_.Properties.NullText = "";//空时的值 txtOPCode_.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体 txtOPCode_.Properties.ValidateOnEnterKey = true;//回车确认 txtOPCode_.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard txtOPCode_.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 txtOPCode_.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion //if (__dt != null && __dt.Rows.Count > 0) //{ // foreach (DataRow item in __dt.Rows) // { //this.txtOPCode_.Items.Add(item["OPCODE"].ToString()); // } //} } #endregion } #endregion } catch (Exception ex) { SetMessage(ex.Message, Color.Red); } } private void txtOPCode_TextChanged(object sender, EventArgs e) { try { string itemCode = this.txtProductCode.Text; string OpCode = this.txtOPCode_.Text; string sql = @"SELECT EnumName FROM Sys_EnumKey WHERE EnumKey='00006'"; 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 + LotNo + this.txtOPCode_.Text + ".pdf"; //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; name = "123"; if (name == null || string.IsNullOrWhiteSpace(name.ToString())) return; //fileName = "E:\\PDF\\20201015.pdf"; //string fileName = name.ToString() + itemCode + "\\" + RouteCode + "\\" + OpCode + ".pdf"; //string fileName = name.ToString() + ".pdf"; if (!string.IsNullOrEmpty(fileName)) { axAcroPDFTZ.LoadFile(fileName); axAcroPDFTZ.setShowToolbar(false); axAcroPDFTZ.setShowScrollbars(false); axAcroPDFTZ.setPageMode("thumbs"); axAcroPDFTZ.setLayoutMode("SinglePage"); axAcroPDFTZ.setView("Fit"); axAcroPDFTZ.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } #region 选中工序委外 private void checkboxGX_CheckedChanged(object sender, EventArgs e) { if (this.checkboxGX.Checked == true) { this.checkboxWW.Checked = false; } } #endregion #region 委外检验 private void checkboxWW_CheckedChanged(object sender, EventArgs e) { if (this.checkboxWW.Checked == true) { this.checkboxGX.Checked = false; } } #endregion private void txtOPCode_SelectedIndexChanged(object sender, EventArgs e) { initCheck(); } private void initCheck() { string _OQCSql = @"SELECT a.SetValueMax,a.SetValueMin,a.CKGROUPCode,b.CKGROUPDESC,b.CKGROUPDNAME,'' Remark,'' CheckResult,a.standvalue as standresult,CAST (ISNULL(0, 0) AS BIT) AS OK,CAST (ISNULL(0, 0) AS BIT) AS NG,ptype, a.id,'' as bgcheckcc,'' as bgcheckresultcc FROM ICSOQCCKLIST a LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP WHERE INVCode='" + txtProductCode.Text + "' AND a.CKGROUPATTR='量化' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + @"' and a.CKGROUPMETH='工序检验' select cklistcode,checkresultvalue ,ccorwgresult,CheckoutAttribute from ICSOQCCKGROUP2LISTCheckResult where GXorWWCheck='GX' AND LOTNO='" + txtLotNo.Text + @"' AND OPCODE='" + txtOPCode.Text + @"' ";//0906 DataSet set = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCSql); DataTable _OQCdt = set.Tables[0]; DataTable ZZLOG = set.Tables[1]; _OQCdt.PrimaryKey = new DataColumn[] { _OQCdt.Columns["id"] }; List 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"]); List rowlist = ZZLOG.AsEnumerable().Where(a => a["cklistcode"].ToString() == row["CKGROUPCode"].ToString() && a["CheckoutAttribute"].ToString() == "量化").ToList(); 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"; if (rowlist.Count >= i + 1) { newrow["bgcheckcc"] = rowlist[i]["checkresultvalue"].ToString(); newrow["bgcheckresultcc"] = rowlist[i]["ccorwgresult"].ToString(); } newrow["id"] = AppConfig.GetGuid(); _OQCdt.Rows.Add(newrow); } _OQCdt.Rows.Remove(row); } } //else //{ // DataRow newrow = _OQCdt.NewRow(); // newrow["id"] = AppConfig.GetGuid(); // _OQCdt.Rows.Add(newrow); //} foreach (DataRow rowcc in _OQCdt.Rows) { if (!string.IsNullOrEmpty(rowcc["bgcheckcc"].ToString())) continue; DataRow row = ZZLOG.AsEnumerable().Where(a => a["cklistcode"].ToString() == rowcc["CKGROUPCode"].ToString() && a["CheckoutAttribute"].ToString() == "量化").FirstOrDefault(); if (row != null) { rowcc["bgcheckcc"] = row["checkresultvalue"].ToString(); rowcc["bgcheckresultcc"] = row["ccorwgresult"].ToString(); } } gridControlcc.DataSource = _OQCdt; string _OQCWGSql = @"SELECT a.CKGROUPATTR,a.CKGROUPMETH,a.CKGROUPCode CKGROUPCode1,b.CKGROUPDESC CKGROUPDESC1,b.CKGROUPDNAME,'' Remark1,CAST (ISNULL(0, 0) AS BIT) AS OK,CAST (ISNULL(0, 0) AS BIT) AS NG,ptype,a.id,'' as bgcheckwg,'' as bgcheckresultwg FROM ICSOQCCKLIST a LEFT JOIN ICSOQCCKGROUP b ON a.CKGROUPCode=b.CKGROUP WHERE INVCode='" + txtProductCode.Text + "' AND a.CKGROUPATTR='外观' and a.ISREF='是' AND a.OPCode='" + txtOPCode.Text + "' and a.CKGROUPMETH='工序检验'";//0906 DataSet set2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, _OQCWGSql); DataTable _OQCWGdt = set2.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"]); List rowlist = ZZLOG.AsEnumerable().Where(a => a["cklistcode"].ToString() == row["CKGROUPCode1"].ToString() && a["CheckoutAttribute"].ToString() == "外观").ToList(); 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["NG"] = row["NG"]; newrow["ptype"] = "1"; newrow["id"] = AppConfig.GetGuid(); if (rowlist.Count >= i + 1) { newrow["bgcheckwg"] = rowlist[i]["checkresultvalue"].ToString(); newrow["bgcheckresultwg"] = rowlist[i]["ccorwgresult"].ToString(); } _OQCWGdt.Rows.Add(newrow); } _OQCWGdt.Rows.Remove(row); } } //else //{ // DataRow newWGrow = _OQCWGdt.NewRow(); // newWGrow["id"] = AppConfig.GetGuid(); // _OQCWGdt.Rows.Add(newWGrow); //} foreach (DataRow rowcc in _OQCWGdt.Rows) { if (!string.IsNullOrEmpty(rowcc["bgcheckwg"].ToString())) continue; DataRow row = ZZLOG.AsEnumerable().Where(a => a["cklistcode"].ToString() == rowcc["CKGROUPCode1"].ToString() && a["CheckoutAttribute"].ToString() == "外观").FirstOrDefault(); if (row != null) { rowcc["bgcheckwg"] = row["checkresultvalue"].ToString(); rowcc["bgcheckresultwg"] = row["ccorwgresult"].ToString(); } } gridControl2.DataSource = _OQCWGdt; LoadGroup(); } private void txtOPCode_EditValueChanged(object sender, EventArgs e) { } 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_KeyUp_1(object sender, KeyEventArgs 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++) { if (gridView2.GetRowCellValue(k, colCKGROUPCode1) == null) { gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colOK, false); gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colOK, false); } #region MyRegion bool _S1 = 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 (_S1 && gridView2.FocusedColumn.Caption == "合格") { istrue = true; } else { 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; WGNCRresult += ""; } } #endregion } } catch (Exception ex) { throw new Exception(ex.ToString()); } #endregion } private string WWNCRMes() { string result = ""; for (int k = 0; k < gridView2.RowCount; k++) { bool _S1 = 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 (!_S1) { result += "在外观检验,检验项目:" + gridView2.GetRowCellValue(k, colCKGROUPDESC1) + "发生不良"; } } return result; } private void txtLotNo_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { try { if (checkboxGX.Checked == false && checkboxWW.Checked == false) { ICSBaseSimpleCode.AppshowMessageBox("请选择工序检验还是委外检验!!"); return; } int Type = 0; if (checkboxGX.Checked) { Type = 0; } if (checkboxWW.Checked) { Type = 1; } FormICSLLAGVHH form = new FormICSLLAGVHH(Type); form.ShowDialog(); txtLotNo.Text = form.LotNo_; KeyPressEventArgs eves = new KeyPressEventArgs((Char)Keys.Enter); if (!string.IsNullOrEmpty(form.LotNo_)) txtLotNo_KeyPress(null, eves); KeyEventArgs eve = new KeyEventArgs(Keys.Enter); txtProductCode.Text = form.ItemCode_; txtOPCode.Text = form.OPCode_; if (!string.IsNullOrEmpty(form.OPCode_)) txtOPCode_KeyDown(null, eve); this.txtMOCode.Text = form.MOCode_; this.txtMOQty.Text = form.MOPLANQTY_; txtPriductName.Text = form.INVDESC_; txtLotQty.Text = form.LOTQTY_; //LotNoChanged(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void LotNoChanged() { try { #region string chksql = @"select a.LotNO,a.MCODE ItemCODE,b.INVNAME,a.LOTQTY ,a.TransNO,c.MOPLANQTY from ICSITEMLot a WITH (nolock) LEFT JOIN ICSINVENTORY b WITH (nolock) ON a.MCODE = b.INVCODE LEFT JOIN ICSMO c WITH (nolock) ON a.TransNO = c.MOCODE AND a.TransLine=c.MOSEQ where a.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; } txtProductCode.Text = dt.Rows[0]["ItemCODE"].ToString(); string itemCode = dt.Rows[0]["ItemCODE"].ToString(); txtPriductName.Text = dt.Rows[0]["INVNAME"].ToString(); txtLotQty.Text = dt.Rows[0]["LOTQTY"].ToString(); LotNo = dt.Rows[0]["LotNO"].ToString(); txtMOCode.Text = dt.Rows[0]["TransNO"].ToString(); txtMOQty.Text = dt.Rows[0]["MOPLANQTY"].ToString(); #region 工序 string __sql = @"SELECT b.OPCODE 工序编码,c.OPDESC 工序名称 FROM ICSITEM2ROUTE a INNER JOIN ICSROUTE2OP b ON b.ROUTECODE=a.ROUTECODE INNER JOIN ICSOP c ON b.OPCODE=c.OPCODE WHERE a.ITEMCODE='" + itemCode + "' AND a.WorkPoint='{0}' ORDER BY b.OPSEQ"; __sql = string.Format(__sql, AppConfig.WorkPointCode); DataTable __dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, __sql).Tables[0]; txtOPCode_.Properties.ValueMember = "工序编码"; txtOPCode_.Properties.DisplayMember = "工序编码"; txtOPCode_.Properties.DataSource = __dt; txtOPCode_.Properties.NullText = "";//空时的值 txtOPCode_.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体 txtOPCode_.Properties.ValidateOnEnterKey = true;//回车确认 txtOPCode_.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard txtOPCode_.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 txtOPCode_.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion } #endregion } catch (Exception ex) { SetMessage(ex.Message, Color.Red); } } private void txtLotNo_KeyPress(object sender, KeyPressEventArgs e) { try { #region` if (e.KeyChar == (char)Keys.Enter) { if (checkboxGX.Checked == false && checkboxWW.Checked == false) { ICSBaseSimpleCode.AppshowMessageBox("请选择工序检验还是委外检验!!"); return; } #region string chksql = @"select a.LotNO,a.MCODE ItemCODE,b.INVNAME,a.LOTQTY ,a.TransNO,c.MOPLANQTY,ROUTECODE,c.ORDERNO from ICSITEMLot a WITH (nolock) LEFT JOIN ICSINVENTORY b WITH (nolock) ON a.MCODE = b.INVCODE LEFT JOIN ICSMO c WITH (nolock) ON a.TransNO = c.MOCODE AND a.TransLine=c.MOSEQ LEFT JOIN (SELECT LOTNO,ROUTECODE FROM ICSMO2USER GROUP BY LOTNO,ROUTECODE) D ON D.LOTNO=A.LOTNO where a.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; } Clear(false); txtProductCode.Text = dt.Rows[0]["ItemCODE"].ToString(); ItemCode = dt.Rows[0]["ItemCODE"].ToString(); txtPriductName.Text = dt.Rows[0]["INVNAME"].ToString(); txtLotQty.Text = dt.Rows[0]["LOTQTY"].ToString(); RouteCode = dt.Rows[0]["ROUTECODE"].ToString(); LotNo = dt.Rows[0]["LotNO"].ToString(); txtMOCode.Text = dt.Rows[0]["TransNO"].ToString(); txtMOQty.Text = dt.Rows[0]["MOPLANQTY"].ToString(); txtOrderNo.Text= dt.Rows[0]["ORDERNO"].ToString(); #region 工序 //string __sql = @"SELECT b.OPCODE 工序编码,c.OPDESC 工序名称 FROM ICSITEM2ROUTE a // INNER JOIN ICSROUTE2OP b ON b.ROUTECODE=a.ROUTECODE // INNER JOIN ICSOP c ON b.OPCODE=c.OPCODE // WHERE a.ITEMCODE='" + itemCode + "' AND a.WorkPoint='{0}' ORDER BY b.OPSEQ"; string __sql = @"SELECT a.OPCODE 工序编码,c.OPDESC 工序名称 FROM ICSITEMROUTE2OPLot a INNER JOIN ICSOP c ON c.OPCODE=a.OPCODE WHERE a.lotno='" + LotNo + "' AND a.WorkPoint='{0}' ORDER BY a.OPSEQ"; __sql = string.Format(__sql, AppConfig.WorkPointCode); DataTable __dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, __sql).Tables[0]; txtOPCode_.Properties.ValueMember = "工序编码"; txtOPCode_.Properties.DisplayMember = "工序编码"; txtOPCode_.Properties.DataSource = __dt; txtOPCode_.Properties.NullText = "";//空时的值 txtOPCode_.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体 txtOPCode_.Properties.ValidateOnEnterKey = true;//回车确认 txtOPCode_.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard txtOPCode_.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 txtOPCode_.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; #endregion //if (__dt != null && __dt.Rows.Count > 0) //{ // foreach (DataRow item in __dt.Rows) // { //this.txtOPCode_.Items.Add(item["OPCODE"].ToString()); // } //} txtOPCode.SelectAll(); txtOPCode.Focus(); } #endregion } #endregion } catch (Exception ex) { SetMessage(ex.Message, Color.Red); } } private void txtOPCode_TextChanged_1(object sender, EventArgs e) { } private void txtLotNo_EditValueChanged(object sender, EventArgs e) { } private void txtMessage_MouseMove(object sender, MouseEventArgs e) { } private void BtnDesignMap_MouseMove_1(object sender, MouseEventArgs e) { BtnDesignMap.BackColor = System.Drawing.Color.DeepSkyBlue; } private void BtnDesignMap_MouseLeave_1(object sender, EventArgs e) { BtnDesignMap.BackColor = System.Drawing.Color.FromArgb(207, 221, 255); } private void BrnOPMap_MouseMove_1(object sender, MouseEventArgs e) { BrnOPMap.BackColor = System.Drawing.Color.DeepSkyBlue; } private void BrnOPMap_MouseLeave_1(object sender, EventArgs e) { BrnOPMap.BackColor = System.Drawing.Color.FromArgb(207, 221, 255); } private void BtnCheckBookMap_MouseMove_1(object sender, MouseEventArgs e) { BtnCheckBookMap.BackColor = System.Drawing.Color.DeepSkyBlue; } private void BtnCheckBookMap_MouseLeave_1(object sender, EventArgs e) { BtnCheckBookMap.BackColor = System.Drawing.Color.FromArgb(207, 221, 255); } private void btnTempSave_MouseMove(object sender, MouseEventArgs e) { } private void btnTempSave_MouseLeave(object sender, EventArgs e) { } private void gridViewCC_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { #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())) // { // if (gridViewCC.GetRowCellValue(k, CCOK).ToString() == "True") // { // _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 #region try { if (gridViewCC.FocusedRowHandle < 0) { return; } #region 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}"); } //for (int k = 0; k < gridViewCC.RowCount; k++) //{ Decimal _VALUEMAX = 0; Decimal _VALUEMIN = 0; Decimal _S1 = 0; if (gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMax) != null) { if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMax).ToString())) { _VALUEMAX = Decimal.Parse(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMax).ToString()); } } if (gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin) != null) { if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin).ToString())) { _VALUEMIN = Decimal.Parse(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin).ToString()); } } if (gridViewCC.FocusedColumn.Caption == "检验值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult).ToString())) { #region MyRegion //判断检验值是否是数字 if (!IsNum(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult).ToString())) { //gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult, 0); SetMessage("检验值请填写数字!", Color.Red); return; } else { if (gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult) != null) { if (!string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult).ToString())) { _S1 = Decimal.Parse(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colCheckResult).ToString()); } } //string OK = gridViewCC.GetRowCellValue(k, CCOK).ToString(); //string NG = gridViewCC.GetRowCellValue(k, CCNG).ToString(); //if ((OK == "False" && NG == "False") || (OK == "" && NG == "")) //{ if ((_S1 < _VALUEMIN || _S1 > _VALUEMAX)) { if (status1 != "true") { status1 = "true"; gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, CCNG, true); status1 = ""; } else if (status2 != "true") { status2 = "true"; gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, CCOK, false); status2 = ""; } //break; } else if ((_S1 >= _VALUEMIN || _S1 <= _VALUEMAX)) { if (status1 != "true") { status1 = "true"; gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, CCOK, true); status1 = ""; } else if (status2 != "true") { status2 = "true"; gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, CCNG, false); status2 = ""; } //break; } //} } #endregion } else if (gridViewCC.FocusedColumn.Caption == "标准检测值" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, StandResult).ToString())) { //判断检验值是否是数字 if (!IsNum(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, StandResult).ToString())) { gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, StandResult, 0); SetMessage("标准检测值请填写数字!", Color.Red); return; } } else if (gridViewCC.FocusedColumn.Caption == "标准下限" && !string.IsNullOrWhiteSpace(gridViewCC.GetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin).ToString())) { if (_VALUEMAX < _VALUEMIN) { //gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, colSetValueMin, 0); SetMessage("标准下限值不能大于标准上限值,请确认!", Color.Red); return; } } CheckResult(); } #endregion } catch (Exception ex) { throw new Exception(ex.ToString()); } #endregion } //判断是否全为数字 public static bool IsNum(string str) { char[] ch = new char[str.Length]; ch = str.ToCharArray(); for (int i = 0; i < ch.Length; i++) { if (!(ch[i] >= 0x0030 && ch[i] <= 0x0039) && ch[i].ToString() != ".") return false; } return true; } private void gridView2_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { try { 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 = true; for (int k = 0; k < gridView2.RowCount; k++) { #region MyRegion //bool _S1 = false; //if (gridView2.GetRowCellValue(k, colOK) != null) //{ // if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colOK).ToString())) // { // if (gridView2.GetRowCellValue(k, colOK).ToString() == "True") // { // _S1 = true; // } // } //} //bool _S2 = false; //if (gridView2.GetRowCellValue(k, colNotOK) != null) //{ // if (!string.IsNullOrWhiteSpace(gridView2.GetRowCellValue(k, colNotOK).ToString())) // { // if (gridView2.GetRowCellValue(k, colNotOK).ToString() == "True") // { // _S2 = true; // } // } //} //if (_S1 && gridView2.FocusedColumn.Caption == "合格") //{ // istrue = true; //} //else if (gridView2.FocusedColumn.Caption == "检验项代码") //{ // istrue = true; //} //else if(_S2 && gridView2.FocusedColumn.Caption == "不合格") //{ // istrue = false; //} #endregion string OK = gridView2.GetRowCellValue(k, colOK).ToString(); string NG = gridView2.GetRowCellValue(k, colNotOK).ToString(); if (!string.IsNullOrEmpty(OK) && OK == "True") { istrue = true; } else if (!string.IsNullOrEmpty(NG) && NG == "True") { istrue = false; break; } } 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()); } } private void BtnDesignMap_Click(object sender, EventArgs e) { try { 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 = txtProductCode.Text.Trim(); if (string.IsNullOrWhiteSpace(Bills.ItemCode)) { SetMessage("请先输入产品追踪单号", Color.Red); return; } Bills.size = 100; Bills.extra = "DWGSW"; string JsonData = JsonConvert.SerializeObject(Bills); //try //{ // //Bills = JsonConvert.DeserializeObject>(JsonData.ToString()); // Bills = JsonConvert.DeserializeObject(JsonData.ToString()); //} #region MyRegion BaseModel rtn = PLM.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; 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); axAcroPDFTZ.LoadFile(filePathName); axAcroPDFTZ.setShowToolbar(false); axAcroPDFTZ.setShowScrollbars(false); axAcroPDFTZ.setPageMode("thumbs"); axAcroPDFTZ.setLayoutMode("SinglePage"); axAcroPDFTZ.setView("Fit"); axAcroPDFTZ.Show(); } #endregion } else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void BrnOPMap_Click(object sender, EventArgs e) { 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 = txtProductCode.Text.Trim(); if (string.IsNullOrWhiteSpace(Bills.ItemCode)) { 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>(JsonData.ToString()); // Bills = JsonConvert.DeserializeObject(JsonData.ToString()); //} #region MyRegion BaseModel rtn = PLM.PLMMap(url, JsonData); if (rtn.code == "200") { 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); axAcroPDFTZ.LoadFile(filePathName); axAcroPDFTZ.setShowToolbar(false); axAcroPDFTZ.setShowScrollbars(false); axAcroPDFTZ.setPageMode("thumbs"); axAcroPDFTZ.setLayoutMode("SinglePage"); axAcroPDFTZ.setView("Fit"); axAcroPDFTZ.Show(); } #endregion } else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; } } private void BtnCheckBookMap_Click_1(object sender, EventArgs e) { try { 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 = txtProductCode.Text; if (string.IsNullOrWhiteSpace(Bills.ItemCode)) { 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>(JsonData.ToString()); // Bills = JsonConvert.DeserializeObject(JsonData.ToString()); //} #region MyRegion BaseModel rtn = PLM.PLMMap(url, JsonData); if (rtn.code == "200") { 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); axAcroPDFTZ.LoadFile(filePathName); axAcroPDFTZ.setShowToolbar(false); axAcroPDFTZ.setShowScrollbars(false); axAcroPDFTZ.setPageMode("thumbs"); axAcroPDFTZ.setLayoutMode("SinglePage"); axAcroPDFTZ.setView("Fit"); axAcroPDFTZ.Show(); } #endregion } else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void txtOPCode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtOpName.Text = ""; string __sql = @"SELECT a.OPCODE 工序编码,c.OPDESC 工序名称,opseq,b.EATTRIBUTE1,e.result,d.ACTIONRESULT FROM ICSITEMROUTE2OPLot a left join ICSMO2User b on a.LotNo= b.LOTNO and a.OPCODE=b.OPCODE left join ICSLOTONWIP d on d.LotNo=a.LotNo and d.OPCODE=a.OPCODE left join ICSLOTONWIPCheck e on e.onwipid=d.ID INNER JOIN ICSOP c ON c.OPCODE=a.OPCODE WHERE a.lotno='" + LotNo + "' AND a.WorkPoint='{0}' and a.opcode='" + txtOPCode.Text.Trim() + "' and d.eattribute1 is null ORDER BY a.OPSEQ"; __sql = string.Format(__sql, AppConfig.WorkPointCode); DataTable __dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, __sql).Tables[0]; if (__dt.Rows.Count <= 0) { SetMessage("未查询到该工序!", Color.Red); btnTempSave.Enabled = false; return; } DataRow row = __dt.Rows[0]; string isww = "0"; if (checkboxWW.Checked == true) { isww = "1"; } if (string.IsNullOrEmpty(row["EATTRIBUTE1"].ToString())) { SetMessage("该工序未派工!", Color.Red); btnTempSave.Enabled = false; return; } if (row["EATTRIBUTE1"].ToString() != isww) { if (isww == "1") SetMessage("该工序不是委外工序", Color.Red); else SetMessage("该工序不是自制工序", Color.Red); btnTempSave.Enabled = false; return; } if (row["ACTIONRESULT"].ToString() != "COLLECT_END") { SetMessage("该工序还未完工或收料!", Color.Red); btnTempSave.Enabled = false; return; } if (string.IsNullOrEmpty(row["result"].ToString()) != true && row["result"].ToString() != "待检") { SetMessage("该工序已检验!", Color.Red); btnTempSave.Enabled = false; return; } if (__dt != null && __dt.Rows.Count > 0) { opseq = __dt.Rows[0]["opseq"].ToString(); txtOpName.Text = __dt.Rows[0]["工序名称"].ToString(); SetMessage("工序条码扫描成功!", Color.Blue); //调用检验数据接口 try { //GetPLMCKDATA(txtProductCode.Text.Trim(), RouteCode, opseq); } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); return; } btnTempSave.Enabled = true; } initCheck(); } } public void Clear(bool clearlotno) { txtUserCode.Text = ""; txtUserName.Text = ""; txtMOCode.Text = ""; txtMOQty.Text = ""; txtOrderNo.Text = ""; if (clearlotno) { txtLotNo.Text = ""; } txtProductCode.Text = ""; txtPriductName.Text = ""; txtLotQty.Text = ""; txtOPCode.Text = ""; txtOpName.Text = ""; gridControlcc.DataSource = null; txtCCResult.Text = ""; txtWGResult.Text = ""; gridControl2.DataSource = null; } private void btnEnlargeTZ_Click(object sender, EventArgs e) { FileDrawing.Enlarge(axAcroPDFTZ); } private void btnOperationManua_Click(object sender, EventArgs e) { try { 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 = txtProductCode.Text; if (string.IsNullOrWhiteSpace(Bills.ItemCode)) { SetMessage("请先输入料号编码", Color.Red); return; } Bills.size = 100; //0916 原来的 Bills.extra = "DWGSW"; Bills.extra = "PRCF"; string JsonData = JsonConvert.SerializeObject(Bills); //try //{ // //Bills = JsonConvert.DeserializeObject>(JsonData.ToString()); // Bills = JsonConvert.DeserializeObject(JsonData.ToString()); //} #region MyRegion BaseModel rtn = PLM.PLMMap(url, JsonData); if (rtn.code == "200") { #region MyRegion string OpCode = this.txtOPCode.Text; 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); axAcroPDFTZ.LoadFile(filePathName); axAcroPDFTZ.setShowToolbar(false); axAcroPDFTZ.setShowScrollbars(false); axAcroPDFTZ.setPageMode("thumbs"); axAcroPDFTZ.setLayoutMode("SinglePage"); axAcroPDFTZ.setView("Fit"); axAcroPDFTZ.Show(); } #endregion } else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; } #endregion } catch (Exception ex) { MessageBox.Show(ex.Message); } } 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 = PLM.PLMMap1(url, JsonData); JObject jobject = JObject.Parse(CKDATA); if (jobject["code"].ToString() == "200") { string data = jobject["data"].ToString(); List part = new List(); part = (List)JsonConvert.DeserializeObject(data, typeof(List)); List group = new List(); List cklist = new List(); List RemoveID = new List(); 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 repositoryItemCheckEdit3_CheckedChanged(object sender, EventArgs e) { } 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 btnZP_Click(object sender, EventArgs e) { 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 = txtProductCode.Text.Trim(); if (string.IsNullOrWhiteSpace(Bills.ItemCode)) { SetMessage("请先输入料号编码", Color.Red); return; } if (string.IsNullOrEmpty(opseq)) { SetMessage("请先输入正确工序!", Color.Red); return; } Bills.size = 100; Bills.routecode = RouteCode; Bills.opseq = opseq; string JsonData = JsonConvert.SerializeObject(Bills); //try //{ // //Bills = JsonConvert.DeserializeObject>(JsonData.ToString()); // Bills = JsonConvert.DeserializeObject(JsonData.ToString()); //} #region MyRegion BaseModel rtn = PLM.PLMMap(url, JsonData); if (rtn.code == "200") { 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); axAcroPDFTZ.LoadFile(filePathName); axAcroPDFTZ.setShowToolbar(false); axAcroPDFTZ.setShowScrollbars(false); axAcroPDFTZ.setPageMode("thumbs"); axAcroPDFTZ.setLayoutMode("SinglePage"); axAcroPDFTZ.setView("Fit"); axAcroPDFTZ.Show(); } #endregion } else { SetMessage("调用PLM接口返回异常:" + rtn.code + ";" + rtn.msg, Color.Red); return; } } private void btnOperationManua_MouseLeave(object sender, EventArgs e) { btnOperationManua.BackColor = System.Drawing.Color.FromArgb(207, 221, 255); } private void btnOperationManua_MouseMove(object sender, MouseEventArgs e) { btnOperationManua.BackColor = System.Drawing.Color.DeepSkyBlue; } private void btnZP_MouseLeave(object sender, EventArgs e) { btnZP.BackColor = System.Drawing.Color.FromArgb(207, 221, 255); } private void btnZP_MouseMove(object sender, MouseEventArgs e) { btnZP.BackColor = System.Drawing.Color.DeepSkyBlue; } private void btnAddRow_Click(object sender, EventArgs e) { string message = txtMessage.Text.Trim(); if (message != "") { if (!message.Contains("保存成功")) { if (!message.Contains("该工序")) { DataTable dt = this.gridControlcc.DataSource as DataTable; DataRow dr = dt.NewRow(); dr["id"] = AppConfig.GetGuid(); dt.Rows.Add(dr); } } } } private void btnDelRow_Click(object sender, EventArgs e) { gridViewCC.PostEditor(); this.Validate(); if (gridViewCC.RowCount == 0) return; if (gridViewCC.FocusedRowHandle < 0) return; gridViewCC.DeleteRow(gridViewCC.FocusedRowHandle); CheckResult(); } private void CheckResult() { //重新判断检验结果 bool istrue = true; for (int k = 0; k < gridViewCC.RowCount; k++) { string OK = gridViewCC.GetRowCellValue(k, CCOK).ToString(); string NG = gridViewCC.GetRowCellValue(k, CCNG).ToString(); if (!string.IsNullOrEmpty(OK) && OK == "True") { istrue = true; } else if (!string.IsNullOrEmpty(NG) && NG == "True") { istrue = false; break; } } if (istrue) { this.txtCCResult.Text = "OK"; this.txtCCResult.BackColor = Color.Blue; } else { this.txtCCResult.Text = "NG"; this.txtCCResult.BackColor = Color.Red; } } #region 查询尺寸检验项目 private void CCGroupItemButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { ButtonEdit btn = (ButtonEdit)sender; string sql = ""; DataTable data = null; ButtonEdit buttonEdit = (sender as ButtonEdit); sql = @"select CKGROUP as 检验项代码,CKGROUPDNAME as 检验项名称,CKGROUPDESC as 检验项描述 from ICSOQCCKGROUP where ISREF='是'"; sql = string.Format(sql); 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.FormWidth = 500; reForm.FormHeight = 500; if (reForm.ShowDialog() == DialogResult.OK) { DataTable retData = reForm.ReturnData; foreach (DataRow dr in retData.Rows) { buttonEdit.Text = dr["检验项代码"].ToString(); gridViewCC.SetRowCellValue(gridViewCC.FocusedRowHandle, colCKGROUPDESC, dr["检验项描述"].ToString()); } } } #endregion #region 查询外观检验项目 private void WGGroupItemButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { ButtonEdit btn = (ButtonEdit)sender; string sql = ""; DataTable data = null; ButtonEdit buttonEdit = (sender as ButtonEdit); sql = @"select CKGROUP as 检验项代码,CKGROUPDNAME as 检验项名称,CKGROUPDESC as 检验项描述 from ICSOQCCKGROUP where ISREF='是'"; sql = string.Format(sql); 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.FormWidth = 500; reForm.FormHeight = 500; if (reForm.ShowDialog() == DialogResult.OK) { DataTable retData = reForm.ReturnData; foreach (DataRow dr in retData.Rows) { buttonEdit.Text = dr["检验项代码"].ToString(); gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colCKGROUPDESC1, dr["检验项描述"].ToString()); } } } #endregion private void btnAddRow2_Click(object sender, EventArgs e) { string message = txtMessage.Text.Trim(); if (message != "") { if (!message.Contains("保存成功")) { if (!message.Contains("该工序")) { DataTable dt = this.gridControl2.DataSource as DataTable; DataRow dr = dt.NewRow(); dr["id"] = AppConfig.GetGuid(); dt.Rows.Add(dr); } } } } private void btnDelRow2_Click(object sender, EventArgs e) { gridView2.PostEditor(); this.Validate(); if (gridView2.RowCount == 0) return; if (gridView2.FocusedRowHandle < 0) return; gridView2.DeleteRow(gridView2.FocusedRowHandle); CheckResult1(); } private void CheckResult1() { //重新判断检验结果 bool istrue = true; for (int k = 0; k < gridView2.RowCount; k++) { string OK = gridView2.GetRowCellValue(k, colOK).ToString(); string NG = gridView2.GetRowCellValue(k, colNotOK).ToString(); if (!string.IsNullOrEmpty(OK) && OK == "True") { istrue = true; } else if (!string.IsNullOrEmpty(NG) && NG == "True") { istrue = false; break; } } if (istrue) { this.txtWGResult.Text = "OK"; this.txtWGResult.BackColor = Color.Blue; } else { this.txtWGResult.Text = "NG"; this.txtWGResult.BackColor = Color.Red; } } private void OKItemCheckEdit2_EditValueChanged(object sender, EventArgs e) { gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colNotOK, false); gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colOK, true); } private void NotOKItemCheckEdit2_EditValueChanged(object sender, EventArgs e) { gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colOK, false); gridView2.SetRowCellValue(gridView2.FocusedRowHandle, colNotOK, true); } private void LoadGroup() { try { string sql = @"select CKGROUP as 检验项代码,CKGROUPDNAME as 检验项名称,CKGROUPDESC as 检验项描述 from ICSOQCCKGROUP where ISREF='是'"; sql = string.Format(sql, AppConfig.WorkPointCode); DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0]; //尺寸检验 CCCodeGridLookUpEdit.ValueMember = "检验项代码"; CCCodeGridLookUpEdit.DisplayMember = "检验项代码"; CCCodeGridLookUpEdit.DataSource = dt; CCCodeGridLookUpEdit.NullText = "";//空时的值 CCCodeGridLookUpEdit.ImmediatePopup = true;//输入值是否马上弹出窗体 CCCodeGridLookUpEdit.ValidateOnEnterKey = true;//回车确认 CCCodeGridLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard CCCodeGridLookUpEdit.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 CCCodeGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; CCDescGridLookUpEdit.ValueMember = "检验项描述"; CCDescGridLookUpEdit.DisplayMember = "检验项描述"; CCDescGridLookUpEdit.DataSource = dt; CCDescGridLookUpEdit.NullText = "";//空时的值 CCDescGridLookUpEdit.ImmediatePopup = true;//输入值是否马上弹出窗体 CCDescGridLookUpEdit.ValidateOnEnterKey = true;//回车确认 CCDescGridLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard CCDescGridLookUpEdit.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 CCDescGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; //外观检验 WGCodeGridLookUpEdit.ValueMember = "检验项代码"; WGCodeGridLookUpEdit.DisplayMember = "检验项代码"; WGCodeGridLookUpEdit.DataSource = dt; WGCodeGridLookUpEdit.NullText = "";//空时的值 WGCodeGridLookUpEdit.ImmediatePopup = true;//输入值是否马上弹出窗体 WGCodeGridLookUpEdit.ValidateOnEnterKey = true;//回车确认 WGCodeGridLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard WGCodeGridLookUpEdit.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 WGCodeGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; WGDescGridLookUpEdit.ValueMember = "检验项描述"; WGDescGridLookUpEdit.DisplayMember = "检验项描述"; WGDescGridLookUpEdit.DataSource = dt; WGDescGridLookUpEdit.NullText = "";//空时的值 WGDescGridLookUpEdit.ImmediatePopup = true;//输入值是否马上弹出窗体 WGDescGridLookUpEdit.ValidateOnEnterKey = true;//回车确认 WGDescGridLookUpEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard WGDescGridLookUpEdit.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 WGDescGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; } catch (Exception ex) { SetMessage(ex.Message, Color.Red); } } private void CCGroupGridLookUpEdit_EditValueChanged(object sender, EventArgs e) { GridLookUpEdit LookupEdit = sender as GridLookUpEdit; DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow(); if (string.IsNullOrWhiteSpace(LookupEdit.EditValue.ToString())) { } else { gridViewCC.SetFocusedRowCellValue("CKGROUPCode", SelectedDataRow["检验项代码"].ToString()); } } private void WGGroupGridLookUpEdit_EditValueChanged(object sender, EventArgs e) { GridLookUpEdit LookupEdit = sender as GridLookUpEdit; DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow(); if (string.IsNullOrWhiteSpace(LookupEdit.EditValue.ToString())) { } else { gridView2.SetFocusedRowCellValue("CKGROUPCode1", SelectedDataRow["检验项代码"].ToString()); } } private void gridViewCC_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { } private void CCCodeGridLookUpEdit_EditValueChanged(object sender, EventArgs e) { GridLookUpEdit LookupEdit = sender as GridLookUpEdit; DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow(); if (string.IsNullOrWhiteSpace(LookupEdit.EditValue.ToString())) { } else { gridViewCC.SetFocusedRowCellValue("CKGROUPDESC", SelectedDataRow["检验项描述"].ToString()); } } private void WGCodeGridLookUpEdit_EditValueChanged(object sender, EventArgs e) { GridLookUpEdit LookupEdit = sender as GridLookUpEdit; DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow(); if (string.IsNullOrWhiteSpace(LookupEdit.EditValue.ToString())) { } else { gridView2.SetFocusedRowCellValue("CKGROUPDESC1", SelectedDataRow["检验项描述"].ToString()); } } } }