| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Windows.Forms;
- using Infragistics.Win;
- using Core.StlMes.Client.Lims.Port.数据管理.实体类;
- namespace Core.StlMes.Client.Lims.Port
- {
- public partial class FrmPhyOutsourcing : FrmBase
- {
- public FrmPhyOutsourcing()
- {
- InitializeComponent();
- }
- private void FrmPhyOutsourcing_Load(object sender, EventArgs e)
- {
- DateTime now = DateTime.Now;
- DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
- DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
- this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
- this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
- EntityHelper.ShowGridCaption<YdmBcInlistEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<QcmJhyPhyresultEntity>(ultraGrid2.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<QcmZgJugdeApplyEntity>(ultraGrid3.DisplayLayout.Bands[0]);
- initPhyCodeM();
- }
- /// <summary>
- /// 加载试样组\检验项
- /// </summary>
- private void initPhyCodeM()
- {
- DataTable dsPhyCodeM = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryPhyCodeM", new object[] { }, ob);
- if (dsPhyCodeM.Rows.Count > 0)
- {
- ultraComboEditor1.DataSource = dsPhyCodeM;
- ultraComboEditor1.ValueMember = "PHY_CODE";
- }
- doQueryPhyF();
- doQueryPhyS();
- doQueryPhyW();
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- doQueryData();
- break;
- case "Add":
- doAdd();
- break;
- case"AddTesting":
- doAddTesting();
- break;
- case"Update":
- doUpdate();
- break;
- case "Delete":
- doDelete();
- break;
- case "Cope":
- doCope();
- break;
- case"Export":
- exportData();
- break;
- case "Close":
- close();
- break;
- }
- }
-
- /// <summary>
- /// 导出
- /// </summary>
- private void exportData()
- {
- GridHelper.ulGridToExcel(ultraGrid2, "外购管成品成分导出");
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void doQueryData()
- {
- string stoveNo = "";
- string judgeNo = "";
- string strRegStart = "";
- string strRegEnd = "";
- if (this.chkFurnace.Checked && this.txtFurnace.Text.Trim() != "")
- {
- stoveNo = this.txtFurnace.Text.Trim();
- }
- if(this.chkJudgeNo.Checked && this.txtJudgeNo.Text.Trim() != "")
- {
- judgeNo = this.txtJudgeNo.Text.Trim();
- }
- ArrayList parm = new ArrayList();
- if (chkRegTime.Checked)
- {
- strRegStart = RegStartTime.Value.ToString();
- strRegEnd = RegEndTime.Value.ToString();
- }
- parm.Add(stoveNo);
- parm.Add(judgeNo);
- parm.Add(strRegStart);
- parm.Add(strRegEnd);
- List<YdmBcInlistEntity> listSource = EntityHelper.GetData<YdmBcInlistEntity>(
- "com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryData", new object[] { parm }, this.ob);
- ydmBcInlistEntityBindingSource.DataSource = listSource;
- }
- /// <summary>
- /// 查询理化数据
- /// </summary>
- private void doQueryChemical(string judgeNo,string batchNo,string ordLnDlyPk)
- {
- List<QcmJhyPhyresultEntity> listSource = EntityHelper.GetData<QcmJhyPhyresultEntity>(
- "com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryPhy", new object[] { judgeNo,batchNo,ordLnDlyPk }, this.ob);
- bool isnull = false;
- if (listSource.Count() == 0)
- {
- isnull = true;
- listSource = new List<QcmJhyPhyresultEntity>() { new QcmJhyPhyresultEntity() };
- }
- qcmJhyPhyresultEntityBindingSource.DataSource = listSource;
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- row.Cells["CHK"].Value = "True";
- }
- //if (!isnull)
- //{
- // ultraGrid2.Rows[0].Cells["CHK"].Value = "True";
- //}
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void doAdd()
- {
- if (tabMain.SelectedTab.Index == 0)
- {
-
- this.ultraGrid2.UpdateData();
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (uRow == null)
- {
- return;
- }
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkMagRows.Count() == 0)
- {
- MessageUtil.ShowTips("请选择录入的理化性能数据!");
- return;
- }
- YdmBcInlistEntity ydmTity = (YdmBcInlistEntity)uRow.ListObject;
- string ydmBcEntity = JSONFormat.Format(ydmTity);
- ArrayList parm = new ArrayList();
- List<List<string>> parmList = new List<List<string>>();
- foreach (UltraGridRow row in checkMagRows)
- {
- if (row.Cells["SampleNo"].Text.Trim().Equals("") || row.Cells["PhyCodeMin"].Text.Trim().Equals("") || row.Cells["PhyCode"].Text.Trim().Equals(""))
- {
- MessageUtil.ShowTips("试样号、式样组、检验项不能为空!");
- return;
- }
- QcmJhyPhyresultEntity entity = (QcmJhyPhyresultEntity)row.ListObject;
- entity.PhyCodeMin = row.Cells["PhyCodeMin"].Value.ToString();
- entity.PhyNameMin = row.Cells["PhyCodeMin"].Text.Trim();
- entity.PhyCode = row.Cells["PhyCode"].Value.ToString();
- entity.PhyName = row.Cells["PhyCode"].Text;
- entity.ItemCodeF = row.Cells["ItemCodeF"].Value.ToString();
- entity.ItemNameF = row.Cells["ItemCodeF"].Text;
- entity.ItemCodeW = row.Cells["ItemCodeW"].Value.ToString();
- entity.ItemNameW = row.Cells["ItemCodeW"].Text;
- entity.ItemCodeS = row.Cells["ItemCodeS"].Value.ToString();
- entity.ItemNameS = row.Cells["ItemCodeS"].Text;
- entity.IsGood = row.Cells["IsGood"].Value.ToString();
- entity.IsDefect = row.Cells["IsDefect"].Value.ToString();
- entity.ItemCodeW1 = row.Cells["ItemCodeW1"].Value.ToString();
- entity.ItemNameW1 = row.Cells["ItemCodeW1"].Text.ToString();
- entity.ItemCodeS1 = row.Cells["ItemCodeS1"].Value.ToString();
- entity.ItemNameS1 = row.Cells["ItemCodeS1"].Text.ToString();
- if (entity.PhyCodeMin.Equals("C0002") || entity.PhyCodeMin.Equals("C0074") || entity.PhyCodeMin.Equals("C0126") || entity.PhyCodeMin.Equals("C0127") || entity.PhyCodeMin.Equals("C0129"))
- {
-
- }
- string qcmEntity = JSONFormat.Format(entity);
- parm.Add(qcmEntity);
- List<string> ss = new List<string>();
- ss.Add(row.Cells["SampleNo"].Text);
- ss.Add(row.Cells["PhyCodeMin"].Value.ToString());
- ss.Add(row.Cells["PhyCodeMin"].Text);
- parmList.Add(ss);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否新增该理化性能数据?") == DialogResult.No)
- {
- return;
- }
- List<List<string>> batchList = parmList.GroupBy(p => p[0]+ "-"+ p[1]).Select(p => p.FirstOrDefault()
- ).ToList();
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.port.vrp.FrmPhyOutsourcing";
- ccp.MethodName = "doAdd";
- ccp.ServerParams = new object[] { parm, ydmBcEntity, UserInfo.GetUserName(), batchList };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("新增成功!"))
- {
- doQueryData();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- }
- /// <summary>
- /// 增加探伤信息
- /// </summary>
- private void doAddTesting()
- {
- this.ultraGrid3.UpdateData();
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkMagRows.Count() == 0)
- {
- MessageUtil.ShowTips("请选择需要保存的探伤信息!");
- return;
- }
- ArrayList parmList = new ArrayList();
- foreach(UltraGridRow row in checkMagRows)
- {
- QcmZgJugdeApplyEntity qcmTity = (QcmZgJugdeApplyEntity)row.ListObject;
- string qcmEntity = JSONFormat.Format(qcmTity);
- parmList.Add(qcmEntity);
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.port.vrp.FrmPhyOutsourcing";
- ccp.MethodName = "doAddTesting";
- ccp.ServerParams = new object[] { parmList };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("保存成功!"))
- {
- doQueryData();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void doUpdate()
- {
- this.ultraGrid2.UpdateData();
- this.ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkMagRows.Count() == 0)
- {
- MessageUtil.ShowTips("请选择需要修改的理化性能数据!");
- return;
- }
- UltraGridRow row = this.ultraGrid1.ActiveRow;
- YdmBcInlistEntity ydmBcEntity = (YdmBcInlistEntity)row.ListObject;
- string ydmEntity = JSONFormat.Format(ydmBcEntity);
- ArrayList parm = new ArrayList();
- foreach(UltraGridRow uRow in checkMagRows)
- {
- QcmJhyPhyresultEntity entity = (QcmJhyPhyresultEntity)uRow.ListObject;
- entity.ItemCodeF = uRow.Cells["ItemCodeF"].Value.ToString();
- entity.ItemNameF = uRow.Cells["ItemCodeF"].Text.ToString();
- entity.ItemCodeS = uRow.Cells["ItemCodeS"].Value.ToString();
- entity.ItemNameS = uRow.Cells["ItemCodeS"].Text.ToString();
- entity.ItemCodeW = uRow.Cells["ItemCodeW"].Value.ToString();
- entity.ItemNameW = uRow.Cells["ItemCodeW"].Text.ToString();
- entity.ItemCodeW1 = uRow.Cells["ItemCodeW1"].Value.ToString();
- entity.ItemNameW1 = uRow.Cells["ItemCodeW1"].Text.ToString();
- entity.ItemCodeS1 = uRow.Cells["ItemCodeS1"].Value.ToString();
- entity.ItemNameS1 = uRow.Cells["ItemCodeS1"].Text.ToString();
- string qcmEntity = JSONFormat.Format(entity);
- parm.Add(qcmEntity);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否修改该理化性能数据?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.port.vrp.FrmPhyOutsourcing";
- ccp.MethodName = "doUpdate";
- ccp.ServerParams = new object[] { parm, ydmEntity };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("修改成功!"))
- {
- doQueryData();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- private void doDelete()
- {
- this.ultraGrid2.UpdateData();
- this.ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkMagRows.Count() == 0)
- {
- MessageUtil.ShowTips("请选择需要删除的理化性能数据!");
- return;
- }
- UltraGridRow row = this.ultraGrid1.ActiveRow;
- YdmBcInlistEntity ydmBcEntity = (YdmBcInlistEntity)row.ListObject;
- string ydmEntity = JSONFormat.Format(ydmBcEntity);
- ArrayList parm = new ArrayList();
- foreach (UltraGridRow uRow in checkMagRows)
- {
- QcmJhyPhyresultEntity entity = (QcmJhyPhyresultEntity)uRow.ListObject;
- string qcmEntity = JSONFormat.Format(entity);
- parm.Add(qcmEntity);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否删除该理化性能数据?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.port.vrp.FrmPhyOutsourcing";
- ccp.MethodName = "doDelete";
- ccp.ServerParams = new object[] { parm, ydmEntity };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("删除成功!"))
- {
- doQueryData();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- /// <summary>
- /// 复制
- /// </summary>
- private void doCope()
- {
- if (tabMain.SelectedTab.Index == 0)
- {
- this.ultraGrid2.UpdateData();
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (uRow == null)
- {
- return;
- }
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
-
- if (checkMagRows.Count() == 0)
- {
- MessageUtil.ShowTips("请选择复制的理化性能数据!");
- return;
- }
- DataTable copyTable = CreateTableByEntity((QcmJhyPhyresultEntity)ultraGrid2.Rows.FirstOrDefault().ListObject);
- foreach (UltraGridRow row in checkMagRows)
- {
- DataRow dr = copyTable.NewRow();
- CopyEntityToRow((QcmJhyPhyresultEntity)row.ListObject, dr);
- copyTable.Rows.Add(dr);
- }
- List<QcmJhyPhyresultEntity> data = (List<QcmJhyPhyresultEntity>)qcmJhyPhyresultEntityBindingSource.DataSource;
- QcmJhyPhyresultEntity activeFd = null;
- foreach (DataRow row in copyTable.Rows)
- {
- QcmJhyPhyresultEntity fd = new QcmJhyPhyresultEntity();
- CopyRowToEntity(row, fd);
- data.Add(fd);
- activeFd = fd;
- }
- qcmJhyPhyresultEntityBindingSource.ResetBindings(false);
- ultraGrid2.UpdateData();
-
- }
-
- }
- private void CopyRowToEntity(DataRow row, QcmJhyPhyresultEntity fdEntity)
- {
- PropertyInfo[] pros = fdEntity.GetType().GetProperties();
- foreach (DataColumn dc in row.Table.Columns)
- {
- if (dc.ColumnName == "CREATE_TIME") continue;
- PropertyInfo pro = fdEntity.GetType().GetProperty(dc.ColumnName);
- if (pro != null)
- {
- pro.SetValue(fdEntity, ConvertDataType(pro.PropertyType, row[dc.ColumnName].ToString()), null);
- }
- }
- }
- private void CopyEntityToRow(QcmJhyPhyresultEntity fdEntity, DataRow desRow)
- {
- PropertyInfo[] pros = fdEntity.GetType().GetProperties();
- foreach (PropertyInfo pro in pros)
- {
- desRow[pro.Name] = pro.GetValue(fdEntity, null);
- }
- }
- private DataTable CreateTableByEntity(QcmJhyPhyresultEntity fdEntity)
- {
- DataTable dt = new DataTable();
- PropertyInfo[] srcPropertyInfos = fdEntity.GetType().GetProperties();
- foreach (PropertyInfo srcPropertyInfo in srcPropertyInfos)
- {
- dt.Columns.Add(srcPropertyInfo.Name);
- }
- return dt;
- }
- /// <summary>
- /// 关闭
- /// </summary>
- private void close()
- {
- this.Close();
- }
- private void chkFurnace_CheckedChanged(object sender, EventArgs e)
- {
- this.txtFurnace.Enabled = this.chkFurnace.Checked;
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (uRow == null)
- {
- return;
- }
- doQueryChemical(uRow.Cells["JudgeStoveNo"].Text,uRow.Cells["BatchNo"].Text, uRow.Cells["OrdLnDlyPk"].Text);
- doQueryQcmApply(uRow.Cells["JudgeStoveNo"].Text, uRow.Cells["BatchNo"].Text);
- }
- /// <summary>
- /// 查询送判信息
- /// </summary>
- /// <param name="judgeNo"></param>
- /// <param name="batchNo"></param>
- private void doQueryQcmApply(string judgeNo,string batchNo)
- {
- List<QcmZgJugdeApplyEntity> listSource = EntityHelper.GetData<QcmZgJugdeApplyEntity>(
- "com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryQcmApply", new object[] { judgeNo, batchNo }, this.ob);
- qcmZgJugdeApplyEntityBindingSource.DataSource = listSource;
- foreach (UltraGridRow row in ultraGrid3.Rows)
- {
- row.Cells["CHK"].Value = "True";
- }
- }
- private void ultraGrid2_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyData == Keys.Right)
- {
- if (ultraGrid2.ActiveCell.Column.Index + 1== ultraGrid2.DisplayLayout.Bands[0].Columns.Count)
- {
- return;
- }
- ultraGrid2.ActiveColScrollRegion.ScrollColIntoView(ultraGrid2.DisplayLayout.Bands[0].Columns[ultraGrid2.ActiveCell.Column.Index + 1], true);
- ultraGrid2.PerformAction(UltraGridAction.EnterEditMode);
- }
- if (e.KeyData == Keys.Left)
- {
- if (ultraGrid2.ActiveCell.Column.Index - 1 == 0)
- {
- return;
- }
- ultraGrid2.ActiveColScrollRegion.ScrollColIntoView(ultraGrid2.DisplayLayout.Bands[0].Columns[ultraGrid2.ActiveCell.Column.Index - 1], true);
- ultraGrid2.PerformAction(UltraGridAction.EnterEditMode);
- }
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- YdmBcInlistEntity matGpEntity = e.Row.ListObject as YdmBcInlistEntity;
- if (!matGpEntity.ActCount.ToString().Equals("0"))
- {
- e.Row.RowSelectorAppearance.BackColor = Color.LightGreen;
- }
- }
- private void txtFurnace_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 13)
- {
- doQueryData();
- }
- }
- private void tabMain_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- if (toolMenu==null|| toolMenu.Toolbars==null ) return;
-
- if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = tabMain.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
- if (toolMenu.Toolbars[0].Tools.Exists("Update")) { toolMenu.Toolbars[0].Tools["Update"].InstanceProps.Visible = tabMain.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
- if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = tabMain.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
- if (toolMenu.Toolbars[0].Tools.Exists("Export")) { toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = tabMain.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
- }
- private void chkRegTime_CheckedChanged(object sender, EventArgs e)
- {
- this.RegStartTime.Enabled = this.RegEndTime.Enabled = this.chkRegTime.Checked;
- }
- private void chkJudgeNo_CheckedChanged(object sender, EventArgs e)
- {
- this.txtJudgeNo.Enabled = this.chkJudgeNo.Checked;
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- this.ultraGrid2.UpdateData();
- int m = 0;
- if (e.Cell.Column.Key == "PhyCodeMin")
- {
- ultraGrid2.ActiveRow.Cells["PhyCode"].Value = "";
- var list1 = new ValueList();
- DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryPhyCodeP", new object[] { e.Cell.Value }, ob);
- foreach (DataRow row in ds.Rows)
- {
- list1.ValueListItems.Add(row["PHY_CODE"].ToString(), row["PHY_NAME"].ToString());
- }
- ultraGrid2.ActiveRow.Cells["PhyCode"].ValueList = list1;
- }
- }
- /// <summary>
- /// 加载尺寸
- /// </summary>
- /// <param name="p"></param>
- private void doQueryPhyS()
- {
- ultraComboEditor5.DataSource = null;
- DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryItemC", new object[] { }, ob);
- ultraComboEditor5.DataSource = ds;
- ultraComboEditor5.ValueMember = "ITEM_CODE_C";
- }
- /// <summary>
- /// 加载方向
- /// </summary>
- /// <param name="p"></param>
- private void doQueryPhyF()
- {
- ultraComboEditor3.DataSource = null;
- DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryItemF", new object[] { }, ob);
- ultraComboEditor3.DataSource = ds;
- ultraComboEditor3.ValueMember = "ITEM_CODE_F";
- }
- /// <summary>
- /// 加载温度
- /// </summary>
- private void doQueryPhyW()
- {
- ultraComboEditor4.DataSource = null;
- DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryItemW", new object[] { }, ob);
- ultraComboEditor4.DataSource = ds;
- ultraComboEditor4.ValueMember = "ITEM_CODE_W";
- }
- private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- var list1 = new ValueList();
- DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryPhyCodeP", new object[] {e.Row.Cells["PhyCodeMin"].Value}, ob);
- foreach (DataRow row in ds.Rows)
- {
- list1.ValueListItems.Add(row["PHY_CODE"].ToString(), row["PHY_NAME"].ToString());
- }
- e.Row.Cells["PhyCode"].ValueList = list1;
- }
- private object ConvertDataType(Type type, object objValue)
- {
- if (type == typeof(bool))
- {
- bool result;
- if (bool.TryParse(objValue.ToString(), out result))
- {
- return result;
- }
- else
- {
- return false;
- }
- }
- else if (type == typeof(bool?))
- {
- bool result;
- if (bool.TryParse(objValue.ToString(), out result))
- {
- return result;
- }
- else
- {
- return null;
- }
- }
- else if (type == typeof(int?))
- {
- if (objValue.ToString2() == "")
- {
- return null;
- }
- else
- {
- return int.Parse(objValue.ToString());
- }
- }
- else if (type == typeof(long?))
- {
- if (objValue.ToString2() == "")
- {
- return null;
- }
- else
- {
- return long.Parse(objValue.ToString());
- }
- }
- else if (type == typeof(short?))
- {
- if (objValue.ToString2() == "")
- {
- return null;
- }
- else
- {
- return short.Parse(objValue.ToString());
- }
- }
- else if (type == typeof(float?))
- {
- if (objValue.ToString2() == "")
- {
- return null;
- }
- else
- {
- return float.Parse(objValue.ToString());
- }
- }
- else if (type == typeof(double?))
- {
- if (objValue.ToString2() == "")
- {
- return null;
- }
- else
- {
- return double.Parse(objValue.ToString());
- }
- }
- else if (type == typeof(decimal?))
- {
- if (objValue.ToString2() == "")
- {
- return null;
- }
- else
- {
- return decimal.Parse(objValue.ToString());
- }
- }
- else if (type == typeof(DateTime?))
- {
- if (objValue.ToString2() == "")
- {
- return null;
- }
- else
- {
- return DateTime.Parse(objValue.ToString());
- }
- }
- else
- {
- return objValue == null ? "" : objValue.ToString();
- }
- }
- }
- }
|