| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- 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.Drawing;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class FrmProcessParameters : FrmBase
- {
- public FrmProcessParameters()
- {
- InitializeComponent();
- }
- private void FrmProcessParameters_Load(object sender, EventArgs e)
- {
- BindCmbParamType();
- cmbParamType.SelectedIndex = 0;
- cmbStyleName.SelectedIndex = 0;
- //doQuery();
- }
- /// <summary>
- /// 获取工艺参数最大值
- /// </summary>
- /// <returns></returns>
- private string GetMaxCode()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParameters.GetMaxCode", null, this.ob);
- string maxCode = "";
- if (dt.Rows.Count > 0)
- {
- if (!"".Equals(dt.Rows[0][0].ToString()))
- {
- maxCode = dt.Rows[0][0].ToString();
- }
- else
- {
- maxCode = "C000";
- }
- }
- return maxCode;
- }
- /// <summary>
- /// 绑定工艺参数类别数据源
- /// </summary>
- private void BindCmbParamType()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParameters.GetType", null, this.ob); ;
- cmbParamType.DataSource = dt;
- cmbParamType.DisplayMember = "BASENAME";
- cmbParamType.ValueMember = "BASECODE";
- DataTable dtProcess = ServerHelper.GetData("com.steering.pss.qcm.CoreControlPointBasics.GetProcess", null, this.ob);
- ultraComboEditor1.DataSource = dtProcess;
- ultraComboEditor1.DisplayMember = "PROCESS_DESC";
- ultraComboEditor1.ValueMember = "PROCESS_CODE";
- }
- /// <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 "doAdd":
- doAdd();
- break;
- case "doModify":
- doModify();
- break;
- case "doDelete":
- this.doDeleteOrResume(true);
- break;
- case "doResume":
- this.doDeleteOrResume(false);
- break;
- case "Refresh":
- {
- BindCmbParamType();
- cmbParamType.SelectedIndex = 0;
- cmbStyleName.SelectedIndex = 0;
- break;
- }
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 用于验证修改时,描述是否已存在
- /// </summary>
- private static string VName = "";
- /// <summary>
- /// 验证非空项
- /// </summary>
- /// <returns></returns>
- private bool ValidInput()
- {
- if (string.IsNullOrEmpty(txtName.Text.Trim()))
- {
- MessageBox.Show("请输入工艺参数描述!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证描述是否重复。
- /// </summary>
- /// <param name="name"></param>
- /// <returns></returns>
- private bool isRepeatName(string name)
- {
- DataTable dt = new DataTable();
- dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParameters.GetName", new Object[] { name }, this.ob);
- if (dt.Rows.Count > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void doAdd()
- {
- if (ValidInput())
- {
- //验证描述不允许重复。
- string name = txtName.Text.Trim();
- if (isRepeatName(name))
- {
- MessageBox.Show("工艺参数描述\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (MessageBox.Show("是否确认新增!", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
- {
- return;
- }
- try
- {
- ArrayList parm = new ArrayList();
- //自动生成编号信息。
- //string chenCode = GridHelper.AutoCode(this.dataTable1);
- //获取数据库中CRAFT_CODE的最大值。
- //GetMaxCode();
- //string chenCode = StringUtil.SequenceIncrease(dataTable1.Compute("max(CRAFT_CODE)", "").ToString());
- string chenCode = StringUtil.SequenceIncrease(GetMaxCode());
- parm.Add(chenCode);
- parm.Add(name);
- parm.Add(cmbParamType.Text);
- parm.Add(cmbStyleName.Value);
- parm.Add(this.UserInfo.GetUserName());
- parm.Add(txtMemo.Text);
- parm.Add(ultraComboEditor1.Value.ToString2());
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.qcm.CoreProcessParameters";
- ccp.MethodName = "doAdd";
- ccp.ServerParams = new object[] { parm };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1) return;
- doQuery();
- //高亮显示新增的数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.Rows[i];
- if (row.Cells["CRAFT_CODE"].Value.ToString().Equals(chenCode))
- {
- row.Activate();
- break;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void doModify()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string validflagStr = ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
- //无效数据不允许修改
- if ("0".Equals(validflagStr))
- {
- MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ValidInput())
- {
- //验证描述不允许重复。
- string name = txtName.Text.Trim();
- if (!VName.Equals(name))
- {
- if (isRepeatName(name))
- {
- MessageBox.Show("工艺参数描述\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- //确认修改吗?
- if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- ArrayList parm = new ArrayList();
- string chenCode = ultraGrid1.ActiveRow.Cells["CRAFT_CODE"].Value.ToString();
- parm.Add(txtName.Text);
- parm.Add(cmbParamType.Text);
- parm.Add(cmbStyleName.Value);
- parm.Add(this.UserInfo.GetUserName());
- parm.Add(txtMemo.Text);
- parm.Add(ultraComboEditor1.Value.ToString2());
- parm.Add(chenCode);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.qcm.CoreProcessParameters";
- ccp.MethodName = "doModify";
- ccp.ServerParams = new object[] { parm };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1) return;
- doQuery();
- //高亮显示新增的数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.Rows[i];
- if (row.Cells["CRAFT_CODE"].Value.ToString().Equals(chenCode))
- {
- row.Activate();
- break;
- }
- }
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void doQuery()
- {
- bool validFlag = chkValid.Checked;
- string titleName = "";
- if (ultraCheckEditor1.Checked)
- {
- titleName = txtTitleName.Text.Trim();
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProcessParameters.getLineList", new Object[] { validFlag, titleName }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //不同颜色区分是否有效数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.Rows[i];
- if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1"))
- {
- row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- row.Appearance.ForeColor = Color.Black;
- }
- }
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, new UltraGridColumn[] {
- ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"]
- });
- }
- /// <summary>
- /// GRID ROW激活时信息带至编辑区
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid1.ActiveRow;
- if (row != null)
- {
- //CRAFT_CODE,CRAFTITEM_DESC,CRAFTITEM_TYPE,CRAFTITEM_LV
- txtName.Text = row.Cells["CRAFTITEM_DESC"].Value.ToString();
- VName = txtName.Text.Trim();
- cmbParamType.Text = row.Cells["CRAFTITEM_TYPE"].Value.ToString();
- cmbStyleName.Value = row.Cells["CRAFTITEM_LV"].Value.ToString();
- txtMemo.Text = row.Cells["MEMO"].Value.ToString();
- ultraComboEditor1.Value = row.Cells["PROCESS_CODE"].Value.ToString();
- }
- }
- /// <summary>
- /// 作废或恢复
- /// </summary>
- /// <param name="isDelete">true作废 false恢复</param>
- private void doDeleteOrResume(bool isDelete)
- {
- ultraGrid1.UpdateData();
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择需要" + (isDelete ? "作废" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string validflagStr = ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
- //无效数据不允许作废
- if ("0".Equals(validflagStr))
- {
- if (isDelete)
- {
- MessageBox.Show("无效数据不支持作废操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- else
- {
- //有效数据不允许恢复
- if (!isDelete)
- {
- MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- if (MessageBox.Show("是否确认" + (isDelete ? "作废" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- try
- {
- ArrayList param = new ArrayList();
- string craftCode = ultraGrid1.ActiveRow.Cells["CRAFT_CODE"].Value.ToString();
- param.Add(craftCode);
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreProcessParameters.deleteLineInfo", new Object[] { param, UserInfo.GetUserName(), isDelete }, this.ob);
- if (count > 0)
- {
- doQuery();
- Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- rowD = ultraGrid1.Rows[i];
- if (rowD.Cells["CRAFT_CODE"].Value.ToString().Equals(craftCode))
- {
- rowD.Activate();
- break;
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
- {
- if (ultraCheckEditor1.Checked)
- {
- txtTitleName.ReadOnly = false;
- }
- else
- {
- txtTitleName.ReadOnly = true;
- }
- }
- }
- }
|