| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- 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 FrmProcessParametersD : FrmBase
- {
- public FrmProcessParametersD()
- {
- InitializeComponent();
- }
- private void FrmProcessParametersD_Load(object sender, EventArgs e)
- {
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "doQuery":
- doQuery();
- break;
- case "doSave":
- this.doSave();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询功能实现
- /// </summary>
- private void doQuery()
- {
- BindProcessTable();
- //BindParametersTable();
- }
- /// <summary>
- /// 保存操作
- /// </summary>
- private void doSave()
- {
- ultraGrid2.UpdateData();
- //往工序点与工艺参数对应表中插入工序点编号和工艺参数编号。
- ArrayList Params = new ArrayList();
- string stationCode = ultraGrid1.ActiveRow.Cells["STATION_CODE"].Value.ToString();
- foreach (DataRow dr in this.parametersTable.Rows)
- {
- if ((Boolean)dr["CHK"])
- {
- ArrayList param = new ArrayList();
- //工序代码
- param.Add(ultraGrid1.ActiveRow.Cells["PROCESS_CODE"].Value.ToString());
- //工序描述
- param.Add(ultraGrid1.ActiveRow.Cells["PROCESS_DESC"].Value.ToString());
- //工序点代码
- param.Add(stationCode);
- //工序点描述
- param.Add(ultraGrid1.ActiveRow.Cells["STATION_DESC"].Value.ToString());
- //工艺参数代码
- param.Add(dr["CRAFT_CODE"].ToString());
- //工艺参数描述
- param.Add(dr["CRAFTITEM_DESC"].ToString());
- //单个参数维护个数
- string allowCount = dr["ALLOW_COUNT"].ToString();
- if ("".Equals(allowCount))
- {
- MessageBox.Show("单个参数维护个数不允许为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- param.Add(allowCount);
- Params.Add(param);
- }
- }
- //确定保存吗?
- if (MessageBox.Show("是否确认保存?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- //将Params作为参数传递到服务端,执行插入工作。
- CoreClientParam ccp = new CoreClientParam();
- //服务端的包名+类名
- ccp.ServerName = "com.steering.pss.qcm.CoreProcessParametersD";
- //类里的方法名
- ccp.MethodName = "doSave";
- ccp.ServerParams = new object[] { Params, stationCode };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1)
- {
- return;
- }
- else
- {
- MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- BindProcessTable();
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (stationCode.Equals(row.Cells["STATION_CODE"].Value.ToString()))
- {
- row.Activate();
- }
- }
- }
- }
- /// <summary>
- /// 绑定右侧数据源,工艺参数与对应表两表联查
- /// </summary>
- private void BindParametersTable(string processCode)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParametersD.getLineList", new Object[] { processCode }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.parametersTable, true);
- GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new UltraGridColumn[] {
- ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"]
- });
- }
- /// <summary>
- /// 绑定工序点数据源
- /// </summary>
- private void BindProcessTable()
- {
- //DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.getLineList", new Object[] { true, "" }, this.ob);
- //GridHelper.CopyDataToDatatable(ref dt, ref this.processTable, true);
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParametersD.GetProcessGL", null, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.processTable, true);
- GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, new UltraGridColumn[] {
- });
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- //select 工艺参数 from 对应表 where 工序点 = 当前选中工序点编号
- string processCode = ultraGrid1.ActiveRow.Cells["STATION_CODE"].Value.ToString();
- BindParametersTable(processCode);
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParametersD.GetParameters", new Object[] { processCode }, this.ob);
- //将界面上所有复选框重置为false。
- if (parametersTable.Rows.Count > 0)
- {
- foreach (DataRow dr in parametersTable.Rows)
- {
- dr["CHK"] = false;
- }
- }
- //判断是否有勾选项。
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in parametersTable.Rows)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dr["CRAFT_CODE"].ToString().Equals(dt.Rows[i]["CRAFTITEM_CODE"].ToString()))
- {
- dr["CHK"] = true;
- break;
- }
- }
- }
- }
- //未勾选不允许编辑数据。
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- for (int j = 0; j < ultraGrid2.Rows[i].Cells.Count; j++)
- {
- if (j != 4)
- {
- ultraGrid2.Rows[i].Cells[j].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- }
- }
- //如果已经选中,则单个参数可维护个数允许编辑。
- if ((Boolean)ultraGrid2.Rows[i].Cells[4].Value)
- {
- ultraGrid2.Rows[i].Cells[5].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- }
- }
- }
- /// <summary>
- /// 勾选时,让单个参数维护个数可编辑
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid2.UpdateData();
- if (e.Cell.Column.Key.Equals("CHK"))
- {
- if ((Boolean)e.Cell.Value)
- {
- for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
- {
- //16 17 18 19 20 21 24
- if (i != 0 && i != 1 && i != 2 && i != 3)
- {
- e.Cell.Row.Cells[i].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- }
- }
- }
- else
- {
- for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
- {
- if (i != 4)
- {
- e.Cell.Row.Cells[i].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- }
- }
- }
- }
- }
- private void ultraGrid2_AfterCellUpdate(object sender, CellEventArgs e)
- {
- }
- }
- }
|