| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Qcm;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- 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;
- namespace Core.StlMes.Client.SaleOrder.Dialog
- {
- public partial class CraftOrdFdPicSmpFrm : FrmBase
- {
- private string _ordLnPk = "";
- private string _mscPline = "";
- private string _processCode = "";
- public CraftOrdFdPicSmpFrm(string ordLnPk, string mscPline, string processCode, OpeBase ob)
- {
- InitializeComponent();
- _ordLnPk = ordLnPk;
- _mscPline = mscPline;
- _processCode = processCode;
- this.ob = ob;
- }
- private void Query()
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- if (ultraTabControl1.ActiveTab.Index == 0)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getPhyMinSample",
- new object[] { _ordLnPk, _mscPline, _processCode }, ob);
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- ultraGrid1.DisplayLayout.Bands[0].Columns["ITEM_NAME_W"].Hidden = false;
- }
- else
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getPhyMinSpline",
- new object[] { _ordLnPk, _mscPline, _processCode }, ob);
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- ultraGrid1.DisplayLayout.Bands[0].Columns["ITEM_NAME_W"].Hidden = true;
- }
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- Query();
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- var mRow = ultraGrid1.ActiveRow;
- string phyCodeMin = mRow.GetValue("PHY_CODE_MIN");
- string stdCode = mRow.GetValue("STD_CODE");
- string steelCode = mRow.GetValue("STEELCODE");
- string produccode = mRow.GetValue("PRODUCCODE");
- string itemCodeF = mRow.GetValue("ITEM_CODE_F");
- string itemCodeC = mRow.GetValue("ITEM_CODE_C");
- string itemCodeW = mRow.GetValue("ITEM_CODE_W");
- if (ultraTabControl1.ActiveTab.Index == 0)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.Query",
- new Object[] { phyCodeMin, stdCode, steelCode, produccode }, ob);
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- DataTable dtSic = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getFdSampleSic",
- new Object[] { _ordLnPk, _mscPline, _processCode, phyCodeMin, itemCodeF, itemCodeC, itemCodeW }, ob);
- if (dtSic.Rows.Count != 0)
- {
- string sic = dtSic.Rows[0]["SIC"].ToString();
- foreach (var row in ultraGrid2.Rows)
- {
- if (row.GetValue("SIC") == sic)
- {
- row.Cells["CHK"].Value = true;
- row.Update();
- }
- }
- }
- }
- else
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.DAL.ComBaseSplineDAL.Query2",
- new object[] { phyCodeMin, itemCodeF, itemCodeC, "", "" }, ob);
- GridHelper.CopyDataToDatatable(dt, dataTable3, true);
- DataTable dtEic = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getFdSampleEic",
- new Object[] { _ordLnPk, _mscPline, _processCode, phyCodeMin, itemCodeF, itemCodeC }, ob);
- if (dtEic.Rows.Count != 0)
- {
- string eic = dtEic.Rows[0]["EIC"].ToString();
- foreach (var row in ultraGrid3.Rows)
- {
- if (row.GetValue("EIC") == eic)
- {
- row.Cells["CHK"].Value = true;
- row.Update();
- }
- }
- }
- }
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private void CraftOrdFdPicSmpFrm_Load(object sender, EventArgs e)
- {
- Query();
- ClsBaseInfo.FillComBaseInfo(ultraComboEditor2, "4081", ob, false);
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- this.Cursor = Cursors.WaitCursor;
- string phyCodeMin = ultraGrid1.ActiveRow.GetValue("PHY_CODE_MIN");
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.QueryStdRTest",
- new object[] { phyCodeMin }, ob);
- dt.Columns["STD_NAME_TEST"].Caption = "试验标准";
- dt.Columns["MEMO"].Caption = "备注";
- BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_NAME_TEST", "STD_CODE_TEST");
- baseInfoPopup.LabelTextBox1.Caption = "试验标准";
- baseInfoPopup.Shown += new EventHandler((a, b) =>
- {
- var actRow = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
- c => c.GetValue("STD_CODE_TEST") == ultraGrid1.ActiveRow.GetValue("STD_CODE_TEST")).FirstOrDefault();
- if (actRow != null)
- {
- actRow.Activate();
- }
- });
- this.Cursor = Cursors.Default;
- if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- UltraGridRow row = ultraGrid1.ActiveRow;
- row.SetValue("STD_NAME_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_NAME_TEST"));
- row.SetValue("STD_CODE_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_CODE_TEST"));
- row.Update();
- //foreach (var row in ultraGrid1.Rows)
- //{
- // if (row.GetValue("PHY_CODE_MIN") == ultraGrid1.ActiveRow.GetValue("PHY_CODE_MIN"))
- // {
- // row.SetValue("STD_NAME_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_NAME_TEST"));
- // row.SetValue("STD_CODE_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_CODE_TEST"));
- // row.Update();
- // }
- //}
- }
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "关联":
- Save();
- break;
- case "取样要求维护":
- ShowSample();
- break;
- case "关闭":
- break;
- }
- }
- private void ShowSample()
- {
- UltraGridRow ugr = this.ultraGrid1.ActiveRow;
- try
- {
- this.Cursor = Cursors.WaitCursor;
- string phyCodeMin = ugr.GetValue("PHY_CODE_MIN");
- string itemCodeF = ugr.GetValue("ITEM_CODE_F");
- string itemCodeC = ugr.GetValue("ITEM_CODE_C");
- string itemCodeW = ugr.GetValue("ITEM_CODE_W");
- FrmBaseSample fbs = new FrmBaseSample();
- fbs.Ob = ob; //ob对象
- fbs.CustomInfo = this.CustomInfo;
- fbs.Phycode = ugr.Cells["PHY_CODE_MIN"].Value.ToString(); //取样码
- fbs.Phydesc = ugr.Cells["PHY_NAME_MIN"].Value.ToString(); //取样码描述
- fbs.Stdcode = ugr.Cells["STD_CODE"].Value.ToString(); //标准代码
- fbs.Stddesc = ugr.Cells["STD_NAME"].Value.ToString(); //标准名称
- fbs.Load += new EventHandler((a, b) =>
- {
- this.Cursor = Cursors.Default;
- });
- fbs.ShowDialog();
- Query();
- var reActRow = ultraGrid1.Rows.Where(a=>a.GetValue("PHY_CODE_MIN") == phyCodeMin && a.GetValue("ITEM_CODE_F") == itemCodeF
- && a.GetValue("ITEM_CODE_C") == itemCodeC && a.GetValue("ITEM_CODE_W") == itemCodeW).FirstOrDefault();
- if (reActRow != null)
- {
- reActRow.Activate();
- }
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private void Save()
- {
- if (ultraGrid1.ActiveRow == null) return;
- var mRow = ultraGrid1.ActiveRow;
- var rows = ultraGrid2.Rows.Where(a=>a.GetValue("CHK") == "True");
- var splineRows = ultraGrid3.Rows.Where(a=>a.GetValue("CHK") == "True");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一条取样要求!");
- return;
- }
- else if (mRow.GetValue("STD_CODE_TEST") == "")
- {
- MessageUtil.ShowWarning("请选择试验标准!");
- return;
- }
- if (ultraTabControl1.ActiveTab.Index == 0)
- {
- if (rows.Count() > 1)
- {
- MessageUtil.ShowWarning("只能选择一条取样要求!");
- return;
- }
- }
- else
- {
- if (splineRows.Count() > 1)
- {
- MessageUtil.ShowWarning("只能选择一条试样要求!");
- return;
- }
- }
-
- if (MessageUtil.ShowYesNoAndQuestion("是否确认关联?") == System.Windows.Forms.DialogResult.No)
- {
- return;
- }
- if (ultraTabControl1.ActiveTab.Index == 0)
- {
- ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdPic.setSample",
- new object[]{ _ordLnPk, mRow.GetValue("PHY_CODE_MIN"), mRow.GetValue("ITEM_CODE_F"), mRow.GetValue("ITEM_CODE_C"),
- mRow.GetValue("ITEM_CODE_W"), _mscPline, _processCode, mRow.GetValue("STD_NAME_TEST"), mRow.GetValue("STD_CODE_TEST"),
- rows.FirstOrDefault().GetValue("SIC"), mRow.GetValue("COMMON") }, ob);
- }
- else
- {
- ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdPic.setSpline",
- new object[]{ _ordLnPk, mRow.GetValue("PHY_CODE_MIN"), mRow.GetValue("ITEM_CODE_F"), mRow.GetValue("ITEM_CODE_C"),
- _mscPline, _processCode, mRow.GetValue("STD_NAME_TEST"), mRow.GetValue("STD_CODE_TEST"),
- splineRows.FirstOrDefault().GetValue("EIC") }, ob);
- }
- MessageUtil.ShowTips("关联成功!");
- }
- private void ultraGrid2_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- e.Cell.Row.Update();
- }
- private void ultraGrid3_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- e.Cell.Row.Update();
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- e.Cell.Row.Update();
- }
- }
- }
|