using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.Mes.Client.Comm.Tool; using Infragistics.Win.UltraWinEditors; using Core.Mes.Client.Comm.Server; using Infragistics.Win.UltraWinGrid; using Infragistics.Win; using Core.Mes.Client.Comm.Control; namespace Core.StlMes.Client.Lims.Port { public partial class AddPhyItems : FrmBase { private OpeBase _ob; public OpeBase Ob { get { return _ob; } set { _ob = value; } } private DataTable dtSampleReq;//人工选的取样要求 public DataTable DtSampleReq { get { return dtSampleReq; } set { dtSampleReq = value; } } private DataTable dtPhyDetail;//人工选的检验项目明细 public DataTable DtPhyDetail { get { return dtPhyDetail; } set { dtPhyDetail = value; } } private DataTable m_dtSelectPhySampleCode;//工艺里面的取样码 public DataTable DtSelectPhySampleCode { get { return m_dtSelectPhySampleCode; } set { m_dtSelectPhySampleCode = value; } } private DataTable m_dtSelectPhyDetail;//工艺里面的检验明细 public DataTable DtSelectPhyDetail { get { return m_dtSelectPhyDetail; } set { m_dtSelectPhyDetail = value; } } public AddPhyItems() { InitializeComponent(); } public AddPhyItems(OpeBase ob) { InitializeComponent(); this._ob = ob; } private DataTable m_dtPhyMax;//大项 private DataTable m_dtPhySampleCode;//下拉框取样码 private DataTable m_dtPhyMin;//下拉框小项 private DataTable m_dtPhyR;//下拉框方向温度尺寸 //private DataTable m_dtSampleStyle;//样片类型 //private DataTable m_dtLength;//长度 //private DataTable m_dtRate;//频率 //private DataTable m_dtPosition;//取样位置 private void AddPhyItems_Load(object sender, EventArgs e) { InitColumnsDataTable(); InitCombo(); QueryPhyRItems(); QuerySelectPhyItems();//已经选择的项目赋值 //GridHelper.RefreshAndAutoSize(ultraGrid1); //GridHelper.RefreshAndAutoSize(ultraGrid2); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;//不默认加载筛选条件框 //ultraGrid2.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.False; ultraGrid2.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; } private void InitColumnsDataTable() { //检验项目明细"DEPT_ID","所属部门", //string[] arrColumnsDetail = new string[] { "CHK", "PHY_CODE_MAX", "PHY_NAME_MAX", "PHY_CODE_MIN", "PHY_NAME_MIN", "PHY_CODE", "PHY_NAME", "ITEM_CODE_F", "ITEM_NAME_F", "ITEM_CODE_W", "ITEM_NAME_W", "ITEM_CODE_S", "ITEM_NAME_S" }; //string[] arrCaptionDetail = new string[] { "选择", "检验项", "检验项", "取样码", "取样码描述", "检验基础项", "检验基础项", "试验方向代码", "试验方向", "试验温度代码", "试验温度", "试样尺寸代码", "试样尺寸" }; //PublicPort.InitColumns(arrColumnsDetail, arrCaptionDetail, dataTable1); //PublicPort.setColumnShowOrHidden(ultraGrid1, new string[] { "PHY_NAME_MAX", "DEPT_ID", "PHY_NAME_MIN", "PHY_NAME", "ITEM_CODE_F", "ITEM_CODE_W", "ITEM_CODE_S" }, false);//不需要显示的行 //PublicPort.setOtherColumnReadOnly(ultraGrid1, new string[] { "CHK", "PHY_CODE_MAX", "PHY_NAME_MAX", "DEPT_ID", "PHY_CODE_MIN", "PHY_NAME_MIN", "PHY_CODE", "PHY_NAME" }); //PublicPort.setOtherColumnReadOnly(ultraGrid1, new string[] { "CHK" }); //取样要求队列 string[] arrColumnsSampleReq = new string[] { "CHK", "DATA_TYPE", "DATA_TYPE_DESC", "PHY_CODE_MAX", "PHY_NAME_MAX", "PHY_CODE_MIN", "PHY_NAME_MIN", "SAMPLE_STYLE", "DESC_SAMPLE_STYLE", "STD_CODE", "STD_NAME", "LENGTH", "DESC_LENGTH", "WIDTH", "RATE", "DESC_RATE", "BATCH_UNIT", "BATCH_CNT", "POSITION", "DESC_POSITION", "DESC_COUNT", "SAMPLE_COUNT" }; string[] arrCaptionSampleReq = new string[] { "选择", "样品类型", "样品类型", "检验项", "检验项", "取样码", "取样码", "样片类型", "样片类型", "标准代码", "标准名称", "取样长度", "取样长度", "取样宽度", "取样频率", "取样频率", "分批单位", "分批数量", "取样位置", "取样位置", "取样数量", "样条数" }; PublicPort.InitColumns(arrColumnsSampleReq, arrCaptionSampleReq, dataTable2); PublicPort.setColumnShowOrHidden(ultraGrid2, new string[] { "DATA_TYPE_DESC", "PHY_NAME_MAX", "PHY_NAME_MIN", "DESC_SAMPLE_STYLE", "STD_CODE", "STD_NAME", "DESC_LENGTH", "DESC_RATE", "DESC_POSITION" }, false);//不需要显示的行 PublicPort.setOtherColumnReadOnly(ultraGrid2, new string[] { "SAMPLE_STYLE", "DESC_SAMPLE_STYLE", "STD_CODE", "STD_NAME", "LENGTH", "DESC_LENGTH", "WIDTH", "RATE", "DESC_RATE", "BATCH_UNIT", "BATCH_CNT", "POSITION", "DESC_POSITION", "DESC_COUNT", "SAMPLE_COUNT" }); } private void InitCombo() { try { ultraGrid1.DisplayLayout.Bands[0].Columns["DATA_TYPE"].EditorComponent = ultDATA_TYPE;//样品类型 ultraGrid1.DisplayLayout.Bands[0].Columns["DATA_TYPE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid2.DisplayLayout.Bands[0].Columns["DATA_TYPE"].EditorComponent = ultDATA_TYPE;//样品类型 ultraGrid2.DisplayLayout.Bands[0].Columns["DATA_TYPE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["JUDGE_BASIS"].EditorComponent = ultraComJudgeBasis;//判定依据 ultraGrid1.DisplayLayout.Bands[0].Columns["JUDGE_BASIS"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["ADDCONDITION"].EditorComponent = ultraADDCONDITION;//条件项 ultraGrid1.DisplayLayout.Bands[0].Columns["ADDCONDITION"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["STDMIN_SIGN"].EditorComponent = ultraComSignMin;//下限标准范围默认 ultraGrid1.DisplayLayout.Bands[0].Columns["STDMIN_SIGN"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["STDMIN_SIGN2"].EditorComponent = ultraComSignMin;//下限标准范围二 ultraGrid1.DisplayLayout.Bands[0].Columns["STDMIN_SIGN2"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_MIN_SIGN"].EditorComponent = ultraComSignMin;//下限限制规格一 ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_MIN_SIGN"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_MIN_SIGN2"].EditorComponent = ultraComSignMin;//下限限制规格二 ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_MIN_SIGN2"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["ADDSTD_MIN_SIGN"].EditorComponent = ultraComSignMin;//下限附加标准范围 ultraGrid1.DisplayLayout.Bands[0].Columns["ADDSTD_MIN_SIGN"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["STDMAX_SIGN"].EditorComponent = ultraComSignMax;//上限标准范围默认 ultraGrid1.DisplayLayout.Bands[0].Columns["STDMAX_SIGN"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["STDMAX_SIGN2"].EditorComponent = ultraComSignMax;//上限标准范围二 ultraGrid1.DisplayLayout.Bands[0].Columns["STDMAX_SIGN2"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_MAX_SIGN"].EditorComponent = ultraComSignMax;//上限限制规格一 ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_MAX_SIGN"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_MAX_SIGN2"].EditorComponent = ultraComSignMax;//上限限制规格二 ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_MAX_SIGN2"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["ADDSTD_MAX_SIGN"].EditorComponent = ultraComSignMax;//上限附加标准范围 ultraGrid1.DisplayLayout.Bands[0].Columns["ADDSTD_MAX_SIGN"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //附加标准项4070 initJGDropDown(ultraADDSTDCON_CODE, "com.steering.mes.port.mil.FrmMilConfirmItems.GetBaseData", "4070", "BASENAME", "BASECODE"); ultraGrid1.DisplayLayout.Bands[0].Columns["ADDSTDCON_CODE"].EditorComponent = ultraADDSTDCON_CODE; ultraGrid1.DisplayLayout.Bands[0].Columns["ADDSTDCON_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //取大小值4071 initJGDropDown(ultraSTD_CHOOSE, "com.steering.mes.port.mil.FrmMilConfirmItems.GetBaseData", "4071", "BASENAME", "BASECODE"); ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CHOOSE"].EditorComponent = ultraSTD_CHOOSE; ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CHOOSE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //限制规格描述// 4003 initJGDropDown(ultraSIZE_CODE, "com.steering.mes.port.mil.FrmMilConfirmItems.GetBaseData", "4003", "BASENAME", "BASECODE"); ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_CODE"].EditorComponent = ultraSIZE_CODE; ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_CODE2"].EditorComponent = ultraSIZE_CODE; ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_CODE2"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //接箍规格描述 //initJGDropDown(ultraSPEC_JG, "com.steering.mes.port.mil.FrmMilConfirmItems.GetBaseData", "4003", "BASENAME", "BASECODE"); //ultraGrid1.DisplayLayout.Bands[0].Columns["SPEC_JG"].EditorComponent = ultraSPEC_JG; //ultraGrid1.DisplayLayout.Bands[0].Columns["SPEC_JG"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //检验大项 initJGDropDown(ultPHY_NAME_MAX, "com.steering.mes.port.mil.FrmMilConfirmItems.QueryPhyMaxItems", null, "PHY_NAME_MAX", "PHY_CODE_MAX"); ultraGrid1.DisplayLayout.Bands[0].Columns["PHY_CODE_MAX"].EditorComponent = ultPHY_NAME_MAX; ultraGrid1.DisplayLayout.Bands[0].Columns["PHY_CODE_MAX"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid2.DisplayLayout.Bands[0].Columns["PHY_CODE_MAX"].EditorComponent = ultPHY_NAME_MAX; ultraGrid2.DisplayLayout.Bands[0].Columns["PHY_CODE_MAX"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //取样码 initJGDropDown(ultPHY_NAME_MIN, "com.steering.mes.port.mil.FrmMilConfirmItems.QueryPhySampleCode", null, "PHY_NAME_MIN", "PHY_CODE_MIN"); ultraGrid1.DisplayLayout.Bands[0].Columns["PHY_CODE_MIN"].EditorComponent = ultPHY_NAME_MIN; ultraGrid1.DisplayLayout.Bands[0].Columns["PHY_CODE_MIN"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //initJGDropDown(ultPHY_NAME_MIN_, "com.steering.mes.port.mil.FrmMilConfirmItems.QueryPhySampleCode", "PHY_NAME_MIN", "PHY_CODE_MIN"); ultraGrid2.DisplayLayout.Bands[0].Columns["PHY_CODE_MIN"].EditorComponent = ultPHY_NAME_MIN; ultraGrid2.DisplayLayout.Bands[0].Columns["PHY_CODE_MIN"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //检验基础项 initJGDropDown(ultPHY_NAME, "com.steering.mes.port.mil.FrmMilConfirmItems.QueryPhyMinItems", null, "PHY_NAME", "PHY_CODE"); ultraGrid1.DisplayLayout.Bands[0].Columns["PHY_CODE"].EditorComponent = ultPHY_NAME; ultraGrid1.DisplayLayout.Bands[0].Columns["PHY_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //长度4010 initJGDropDown(ultDESC_LENGTH, "com.steering.mes.port.mil.FrmMilConfirmItems.GetBaseData", "4010", "BASENAME", "BASECODE"); ultraGrid2.DisplayLayout.Bands[0].Columns["LENGTH"].EditorComponent = ultDESC_LENGTH; ultraGrid2.DisplayLayout.Bands[0].Columns["LENGTH"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown; //频率4011 initJGDropDown(ultDESC_RATE, "com.steering.mes.port.mil.FrmMilConfirmItems.GetBaseData", "4086", "BASENAME", "BASECODE"); ultraGrid2.DisplayLayout.Bands[0].Columns["RATE"].EditorComponent = ultDESC_RATE; ultraGrid2.DisplayLayout.Bands[0].Columns["RATE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //分批单位 ultraGrid2.DisplayLayout.Bands[0].Columns["BATCH_UNIT"].EditorComponent = ultBATCH_UNIT; ultraGrid2.DisplayLayout.Bands[0].Columns["BATCH_UNIT"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //位置4012 initJGDropDown(ultDESC_POSITION, "com.steering.mes.port.mil.FrmMilConfirmItems.GetBaseData", "4012", "BASENAME", "BASECODE"); ultraGrid2.DisplayLayout.Bands[0].Columns["POSITION"].EditorComponent = ultDESC_POSITION; ultraGrid2.DisplayLayout.Bands[0].Columns["POSITION"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //样片类型 initJGDropDown(ultDESC_SAMPLE_STYLE, "com.steering.mes.port.mil.FrmMilConfirmItems.GetBaseData", "4081", "BASENAME", "BASECODE"); ultraGrid2.DisplayLayout.Bands[0].Columns["SAMPLE_STYLE"].EditorComponent = ultDESC_SAMPLE_STYLE; ultraGrid2.DisplayLayout.Bands[0].Columns["SAMPLE_STYLE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; } catch (Exception e) { MessageUtil.ShowWarning(e.Message); } } private void initJGDropDown(UltraComboEditor uce, string MethodId, string strId, string memberDis, string memberValue) { //初始化编辑区域下拉框 DataTable dt = PublicServer.GetData(MethodId, strId == null ? null : new Object[] { strId }, this._ob); if (dt != null && dt.Rows.Count > 0) { if (uce == ultPHY_NAME_MAX) { m_dtPhyMax = dt.Copy(); } else if (uce == ultPHY_NAME_MIN) { m_dtPhySampleCode = dt.Copy(); //ValueList vl = PublicPort.GeneralValuelist(ref dt, "PHY_NAME_MIN", "PHY_NAME_MIN"); //ultraGrid1.DisplayLayout.Bands[0].Columns["PHY_NAME_MIN"].ValueList = ultPHY_NAME_MIN; } else if (uce == ultPHY_NAME) { m_dtPhyMin = dt.Copy(); } else if (uce == ultDESC_SAMPLE_STYLE) { //m_dtSampleStyle = dt.Copy(); } else if (uce == ultDESC_LENGTH) { //m_dtLength = dt.Copy(); } else if (uce == ultDESC_RATE) { //m_dtRate = dt.Copy(); } else if (uce == ultDESC_POSITION) { //m_dtPosition = dt.Copy(); } DataRow newDr = dt.NewRow(); newDr[0] = ""; dt.Rows.Add(newDr); uce.DataSource = dt; uce.DisplayMember = memberDis; uce.ValueMember = memberValue; } } //查询理化项目方向、温度、尺寸信息 private void QueryPhyRItems() { try { DataTable dt = PublicServer.GetData("com.steering.mes.port.mil.FrmMilConfirmItems.QueryPhyRItems_All", new Object[] { }, this._ob); if (dt != null && dt.Rows.Count > 0) { m_dtPhyR = dt.Copy(); } } catch (Exception ex) { MessageUtil.ShowWarning(ex.Message); } } //已经选择的项目赋值 private void QuerySelectPhyItems() { try { if (dtPhyDetail != null && dtPhyDetail.Rows.Count > 0) { GridHelper.CopyDataToDatatable(dtPhyDetail, dataTable1, true);//把dt复制给dataTable1 } if (dtSampleReq != null && dtSampleReq.Rows.Count > 0) { GridHelper.CopyDataToDatatable(dtSampleReq, dataTable2, true);//把dt复制给dataTable1 } } catch (Exception ex) { MessageUtil.ShowWarning(ex.Message); } } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { if (e.Tool.Key == "btnOK") //保存 { //doSave(); this.DialogResult = DialogResult.OK; ultraGrid1.UpdateData(); ultraGrid2.UpdateData(); foreach (UltraGridRow ur in ultraGrid1.Rows) { ur.Cells["DATA_TYPE_DESC"].Value = ur.Cells["DATA_TYPE"].Text;//样品类型 ur.Cells["PHY_NAME_MAX"].Value = ur.Cells["PHY_CODE_MAX"].Text; ur.Cells["PHY_NAME_MIN"].Value = ur.Cells["PHY_CODE_MIN"].Text; ur.Cells["PHY_NAME"].Value = ur.Cells["PHY_CODE"].Text; } ultraGrid1.UpdateData(); dtPhyDetail = dataTable1.Copy(); foreach (UltraGridRow ur in ultraGrid2.Rows) { ur.Cells["DATA_TYPE_DESC"].Value = ur.Cells["DATA_TYPE"].Text;//样品类型 ur.Cells["DESC_SAMPLE_STYLE"].Value = ur.Cells["SAMPLE_STYLE"].Text;//样片类型 ur.Cells["DESC_LENGTH"].Value = ur.Cells["LENGTH"].Text;//长度 ur.Cells["DESC_RATE"].Value = ur.Cells["RATE"].Text; ur.Cells["BATCH_UNIT"].Value = ur.Cells["BATCH_UNIT"].Text; ur.Cells["DESC_POSITION"].Value = ur.Cells["POSITION"].Text; } ultraGrid2.UpdateData(); dtSampleReq = dataTable2.Copy(); } else if (e.Tool.Key == "btnClose") //刷新 { if (MessageBox.Show("确认关闭本窗口?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) this.Close(); } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); if (e.Cell.Column.Key == "CHK") { if (e.Cell.Row.Cells["CHK"].Value.ToString() == "True") { for (int i = 0; i < e.Cell.Row.Cells.Count; i++) { e.Cell.Row.Cells[i].Activation = Activation.AllowEdit; } } else { for (int i = 0; i < e.Cell.Row.Cells.Count; i++) { if (e.Cell.Row.Cells[i].Column.Key == "CHK") { continue; } e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly; } } } else { if (e.Cell.Row.Cells["CHK"].Value.ToString() == "True") { if (e.Cell.Column.Key == "PHY_CODE_MAX") { if (m_dtSelectPhyDetail != null) { foreach (DataRow dr in m_dtSelectPhyDetail.Rows) { if (e.Cell.Row.Cells["DATA_TYPE"].Value.ToString() == "0" && dr["PHY_CODE_MAX"].ToString() == e.Cell.Row.Cells["PHY_CODE_MAX"].Value.ToString()) { MessageUtil.ShowTips("工艺中已有此检验大项!"); e.Cell.Row.Cells["PHY_CODE_MAX"].Value = ""; return; } } } e.Cell.Row.Cells["PHY_CODE_MIN"].Value = "";//清空取样码 DataTable dtSampleCode = PublicPort.GetSelectDt(m_dtPhySampleCode, "PHY_CODE_MAX = '" + e.Cell.Value.ToString() + "'"); ValueList vl = PublicPort.GeneralValuelist(ref dtSampleCode, "PHY_CODE_MIN", "PHY_NAME_MIN"); vl.ValueListItems.Add(""); e.Cell.Row.Cells["PHY_CODE_MIN"].ValueList = vl; e.Cell.Row.Cells["PHY_CODE"].Value = "";//清空小项 DataTable dtPhyMin = PublicPort.GetSelectDt(m_dtPhyMin, "PHY_CODE_MAX = '" + e.Cell.Value.ToString() + "'"); ValueList vlMin = PublicPort.GeneralValuelist(ref dtPhyMin, "PHY_CODE", "PHY_NAME"); e.Cell.Row.Cells["PHY_CODE"].ValueList = vlMin; //e.Cell.Row.Cells["PHY_CODE_MAX"].Value = e.Cell.Row.Cells["PHY_NAME_MAX"].Value; //e.Cell.Row.Cells["PHY_NAME_MAX"].Value = e.Cell.Row.Cells["PHY_NAME_MAX"].Text;//大项name赋值 } else if (e.Cell.Row.Cells["PHY_CODE_MAX"].Value.ToString() != "" && e.Cell.Column.Key == "PHY_CODE_MIN") { //同一种样品类型同一个大项不允许存在两种不同的取样码 foreach (UltraGridRow ur in ultraGrid1.Rows) { if (ur != e.Cell.Row) { if (ur.Cells["DATA_TYPE"].Value.ToString() == e.Cell.Row.Cells["DATA_TYPE"].Value.ToString() && ur.Cells["PHY_CODE_MAX"].Value.ToString() == e.Cell.Row.Cells["PHY_CODE_MAX"].Value.ToString() && ur.Cells["PHY_CODE_MIN"].Value.ToString() != e.Cell.Row.Cells["PHY_CODE_MIN"].Value.ToString()) { MessageUtil.ShowTips("同一样品类型同一大项不允许存在不同的取样码!"); e.Cell.Row.Cells["PHY_CODE_MIN"].Value = ""; return; } } } foreach (UltraGridRow ur in ultraGrid2.Rows) { if (ur.Cells["DATA_TYPE"].Value.ToString() == e.Cell.Row.Cells["DATA_TYPE"].Value.ToString() && ur.Cells["PHY_CODE_MAX"].Value.ToString() == e.Cell.Row.Cells["PHY_CODE_MAX"].Value.ToString() && ur.Cells["PHY_CODE_MIN"].Value.ToString() == e.Cell.Row.Cells["PHY_CODE_MIN"].Value.ToString()) { return; } } DataRow newDr = dataTable2.NewRow(); newDr["CHK"] = "True"; newDr["DATA_TYPE"] = e.Cell.Row.Cells["DATA_TYPE"].Value; newDr["PHY_CODE_MAX"] = e.Cell.Row.Cells["PHY_CODE_MAX"].Value; newDr["PHY_NAME_MAX"] = e.Cell.Row.Cells["PHY_CODE_MAX"].Text; newDr["PHY_CODE_MIN"] = e.Cell.Row.Cells["PHY_CODE_MIN"].Value; newDr["PHY_NAME_MIN"] = e.Cell.Row.Cells["PHY_CODE_MIN"].Text; dataTable2.Rows.Add(newDr); //e.Cell.Row.Cells["PHY_CODE_MIN"].Value = e.Cell.Row.Cells["PHY_NAME_MIN"].Value; //取样码 //e.Cell.Row.Cells["PHY_NAME_MIN"].Value = e.Cell.Row.Cells["PHY_NAME_MIN"].Text; } else if (e.Cell.Row.Cells["PHY_CODE_MAX"].Value.ToString() != "" && e.Cell.Column.Key == "PHY_CODE") { //查询到有方向温度尺寸才弹出来 DataTable dtPhyR = PublicPort.GetSelectDt(m_dtPhyR, "PHY_CODE_MAX = '" + e.Cell.Row.Cells["PHY_CODE_MAX"].Value.ToString() + "' AND PHY_CODE = '" + e.Cell.Value.ToString() + "'"); if (dtPhyR != null && dtPhyR.Rows.Count > 0) { AddPhyRItems addR = new AddPhyRItems(this._ob, e.Cell.Row.Cells["PHY_CODE_MAX"].Value.ToString(), e.Cell.Value.ToString()); addR.ShowDialog(); if (addR.DialogResult != DialogResult.OK) { return; } UltraGridRow ur = addR.UgRow; e.Cell.Row.Cells["ITEM_CODE_F"].Value = ur.Cells["ITEM_CODE_F"].Text.Trim(); e.Cell.Row.Cells["ITEM_NAME_F"].Value = ur.Cells["ITEM_NAME_F"].Text.Trim(); e.Cell.Row.Cells["ITEM_CODE_W"].Value = ur.Cells["ITEM_CODE_W"].Text.Trim(); e.Cell.Row.Cells["ITEM_NAME_W"].Value = ur.Cells["ITEM_NAME_W"].Text.Trim(); e.Cell.Row.Cells["ITEM_CODE_S"].Value = ur.Cells["ITEM_CODE_C"].Text.Trim(); e.Cell.Row.Cells["ITEM_NAME_S"].Value = ur.Cells["ITEM_NAME_C"].Text.Trim(); } //e.Cell.Row.Cells["PHY_CODE"].Value = e.Cell.Row.Cells["PHY_NAME"].Value; //e.Cell.Row.Cells["PHY_NAME"].Value = e.Cell.Row.Cells["PHY_NAME"].Text; } } else { if (e.Cell.Column.DataType == typeof(bool)) { e.Cell.Value = false; } else { e.Cell.Value = ""; } } } } private void ultraGrid2_CellChange(object sender, CellEventArgs e) { //ultraGrid2.UpdateData(); //if (e.Cell.Row.Cells["CHK"].Value.ToString() == "True" && m_dtSelectPhySampleCode != null) //{ // if (e.Cell.Column.Key == "PHY_NAME_MAX") // { // foreach (DataRow dr in m_dtSelectPhySampleCode.Rows) // { // if (dr["PHY_CODE_MAX"].ToString() == e.Cell.Row.Cells["PHY_NAME_MAX"].Value.ToString()) // { // MessageUtil.ShowTips("工艺取样码中已有此大类!"); // e.Cell.Row.Cells["PHY_NAME_MAX"].Value = ""; // return; // } // } // DataTable dtSampleCode = PublicPort.GetSelectDt(m_dtPhySampleCode, "PHY_CODE_MAX = '" + e.Cell.Value.ToString() + "'"); // ValueList vl = PublicPort.GeneralValuelist(ref dtSampleCode, "PHY_CODE_MIN", "PHY_NAME_MIN"); // e.Cell.Row.Cells["PHY_NAME_MIN"].ValueList = vl; // } //} //else //{ // if (e.Cell.Column.Key != "CHK") // { // e.Cell.Value = ""; // } //} } } }