| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Data;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class FrmPscStationSelect : FrmBase
- {
- private FrmProPSCMSC2 _frm = null;
- private UltraGridRow _row = null;
- private FrmPscStationSelect()
- {
- InitializeComponent();
- ExceptionHelper.RegistException();
- }
- public FrmPscStationSelect(FrmProPSCMSC2 frm, UltraGridRow row) : this()
- {
- _frm = frm;
- _row = row;
- LoadStationData();
- }
- private void LoadStationData()
- {
- DataTable dt = null;
- ArrayList list = new ArrayList();
- list.Add(_row.Cells["PROCESS_CODE"].Value.ToString());
- list.Add(_row.GetValue("PROCESS_CODE_C"));
- try
- {
- dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.queryBaseStation",
- new object[] { list }, _frm.ob);
- }
- catch
- {
- return;
- }
- AddBaseStationDataWithCount(dt);
- //foreach (UltraGridRow row in ultraGridSta.Rows)
- //{
- // if (row.GetValue("CHOOSE") == "True")
- // {
- // row.SetValue("UCCHOOSE", "True");
- // }
- //}
- if (_frm.UltraGrid4.ActiveRow != null)
- {
- if (_frm._dicMscStation.ContainsKey(_row.Cells["PROCESS_CODE"].Value.ToString()))
- {
- AddMscStationData(_frm._dicMscStation[_row.Cells["PROCESS_CODE"].Value.ToString()]);
- ultraGridSta.UpdateData();
- return;
- }
- DataTable dt2 = null;
- ArrayList list2 = new ArrayList();
- list2.Add(_frm.UltraGrid4.ActiveRow.Cells["MSC"].Value.ToString());
- list2.Add(_frm.UltraGrid4.ActiveRow.Cells["MSC_PLINE"].Value.ToString());
- list2.Add(_row.Cells["PROCESS_CODE"].Value.ToString());
- try
- {
- dt2 = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.queryMscStation",
- new object[] { list2 }, _frm.ob);
- }
- catch
- {
- return;
- }
- AddMscStationData(dt2);
- }
- if (_frm._dicMscStation.ContainsKey(_row.Cells["PROCESS_CODE"].Value.ToString()))
- {
- AddMscStationData(_frm._dicMscStation[_row.Cells["PROCESS_CODE"].Value.ToString()]);
- ultraGridSta.UpdateData();
- return;
- }
- COM_MSC_STATION.AcceptChanges();
- ultraGridSta.UpdateData();
- //GridHelper.RefreshAndAutoSize(ultraGridSta);
- }
- /// <summary>
- /// 根据工序的循环次数在客户端自动生成对应的行数。
- /// </summary>
- /// <param name="dt"></param>
- private void AddBaseStationDataWithCount(DataTable dt)
- {
- int count = int.Parse(_row.Cells["ICOUNT"].Value.ToString() == ""
- ? "1" : _row.Cells["ICOUNT"].Value.ToString());
- //GridHelper.CopyDataToDatatable(ref dt, ref COM_MSC_STATION, true);
- for (int i = 0; i < count; i++)
- {
- foreach (DataRow drOld in dt.Rows)
- {
- DataRow drNew = COM_MSC_STATION.NewRow();
- foreach (DataColumn dcOld in dt.Columns)
- {
- if (COM_MSC_STATION.Columns.Contains(dcOld.ColumnName))
- {
- drNew[dcOld.ColumnName] = drOld[dcOld.ColumnName].ToString();
- }
- }
- drNew["PROCESS_SEQ"] = (i + 1).ToString();
- COM_MSC_STATION.Rows.Add(drNew);
- }
- }
- }
- private void AddMscStationData(DataTable dt)
- {
- foreach (DataRow dr in dt.Rows)
- {
- UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGridSta,
- new string[] { "STATION_CODE", "PROCESS_SEQ" },
- new string[] { dr["STATION_CODE"].ToString(), dr["PROCESS_SEQ"].ToString() });
- if (rows.Length == 0) continue;
- rows[0].Cells["MSC"].Value = dr["MSC"].ToString();
- rows[0].Cells["MSC_PLINE"].Value = dr["MSC_PLINE"].ToString();
- rows[0].Cells["COST"].Value = dr["COST"].ToString();
- rows[0].Cells["CHOOSE"].Value = dr["CHOOSE"].ToString();
- rows[0].Cells["RETURN_RESULT"].Value = dr["RETURN_RESULT"].ToString();
- rows[0].Cells["SEND_CHECKPLAN"].Value = dr["SEND_CHECKPLAN"].ToString();
- //rows[0].Cells["GROUP_SEQ"].Value = dr["GROUP_SEQ"].ToString();
- rows[0].Cells["MEMO"].Value = dr["MEMO"].ToString();
- rows[0].Cells["UCCHOOSE"].Value = true;
- }
- }
- private void AddMscStationData(UltraGrid grid)
- {
- UltraGridRow[] rows = GridHelper.GetRowsWithKey(grid, new string[] { "UCCHOOSE" }, new string[] { "True" });
- foreach (UltraGridRow row in rows)
- {
- string stationCode = row.Cells["STATION_CODE"].Value.ToString();
- string processSeq = row.Cells["PROCESS_SEQ"].Value.ToString();
- UltraGridRow[] rowsSta = GridHelper.GetRowsWithKey(ultraGridSta,
- new string[] { "STATION_CODE", "PROCESS_SEQ" },
- new string[] { stationCode, processSeq });
- if (rowsSta.Length == 0) continue;
- rowsSta[0].Cells["COST"].Value = row.Cells["COST"].Value;
- rowsSta[0].Cells["CHOOSE"].Value = row.Cells["CHOOSE"].Value.ToString() == "True" ? true : false;
- rowsSta[0].Cells["RETURN_RESULT"].Value = row.Cells["RETURN_RESULT"].Value.ToString() == "True" ? true : false;
- rowsSta[0].Cells["SEND_CHECKPLAN"].Value = row.Cells["SEND_CHECKPLAN"].Value.ToString() == "True" ? true : false;
- rowsSta[0].Cells["MEMO"].Value = row.Cells["MEMO"].Value;
- rowsSta[0].Cells["UCCHOOSE"].Value = row.Cells["UCCHOOSE"].Value.ToString() == "True" ? true : false;
- }
- }
- private void InitCheckState()
- {
- UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGridSta,
- new string[] { "MSC" }, new string[] { "" });
- foreach (UltraGridRow row in rows)
- {
- row.Cells["UCCHOOSE"].Value = true;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.ultraGridSta.UpdateData();
- foreach (UltraGridRow row in ultraGridSta.Rows)
- {
- if (row.GetValue("UCCHOOSE") == "False") continue;
- if (row.GetValue("COST") != "" && row.GetValue("COST").TryParseDecimal() == false)
- {
- MessageUtil.ShowWarning("标准成本不是有效的数字!");
- row.SetCellActive("COST");
- return;
- }
- }
- this.DialogResult = DialogResult.OK;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- private void ultraGridSta_CellChange(object sender, CellEventArgs e)
- {
- ultraGridSta.UpdateData();
- }
- private void ultraGridSta_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- // CHOOSE UCCHOOSE
- }
- private void MustCheck(bool isCheck)
- {
- foreach (UltraGridRow row in ultraGridSta.Rows)
- {
- if (bool.Parse(row.GetValue("CHOOSE")))
- {
- row.SetValue("UCCHOOSE", isCheck.ToString());
- }
- }
- ultraGridSta.UpdateData();
- }
- private void labelCheckBox1_CheckBox_CheckedChanged(object sender, EventArgs e)
- {
- MustCheck(labelCheckBox1.Checked);
- }
- }
- }
|