| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- 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;
- using CoreFS.CA06;
- using System.Collections;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- namespace Core.StlMes.Client.PlnSaleOrd
- {
- public partial class FrmUpsettingDialExpansion : FrmBase
- {
- private string _gradeCode = "";
- public string GradeCode
- {
- get { return _gradeCode; }
- set { _gradeCode = value; }
- }
- //墩拔扩外径
- private string _dimater = "";
- public string Dimater
- {
- get { return _dimater; }
- set { _dimater = value; }
- }
- //墩拔扩壁厚
- private string _height = "";
- public string Height1
- {
- get { return _height; }
- set { _height = value; }
- }
- public FrmUpsettingDialExpansion()
- {
- InitializeComponent();
- }
- public void PopupLoad(string customInfo, OpeBase ob)
- {
- this.CustomInfo = customInfo;
- this.ob = ob;
- this.OnLoad(EventArgs.Empty);
- }
- /// <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":
- {
- BindProLineInfo();
- BindGZType();
- cmbProLineInfo.SelectedIndex = 0;
- cmbGZType.SelectedIndex = 0;
- break;
- }
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// Load事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FrmUpsettingDialExpansion_Load(object sender, EventArgs e)
- {
- BindProLineInfo();
-
- BindGZType();
- cmbProLineInfo.SelectedIndex = 0;
- cmbGZType.SelectedIndex = 0;
- }
- /// <summary>
- /// 绑定钢种描述
- /// </summary>
- private void BindGZType()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreUpsettingDialExpansion.GetGZType", null, this.ob);
- cmbGZType.DataSource = dt;
- cmbGZType.DisplayMember = "GRADENAME";
- cmbGZType.ValueMember = "GRADECODE";
- ClsBaseInfo.SetComboItemHeight(cmbGZType);
- }
- /// <summary>
- /// 绑定产线描述
- /// </summary>
- private void BindProLineInfo()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreUpsettingDialExpansion.GetProLineInfo", null, this.ob);
- cmbProLineInfo.DataSource = dt;
- cmbProLineInfo.DisplayMember = "PROCESS_DESC_C";
- cmbProLineInfo.ValueMember = "PROCESS_CDOE_C";
- }
-
- /// <summary>
- /// 非空字段验证
- /// </summary>
- /// <returns></returns>
- private bool ValidInput()
- {
- if (cmbProLineInfo.SelectedItem == null)
- {
- MessageUtil.ShowWarning("请选择二级工序!");
- return false;
- }
- if (cmbGZType.SelectedItem == null)
- {
- MessageUtil.ShowWarning("请选择钢种描述!");
- return false;
- }
- //外径壁厚不允许为空。
- if ("".Equals(txtMax_d.Text.Trim()))
- {
- MessageBox.Show("请输入镦拨扩外径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if ("".Equals(txtMax_h.Text.Trim()))
- {
- MessageBox.Show("请输入镦拨扩壁厚!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if ("".Equals(txtMin_d.Text.Trim()))
- {
- MessageBox.Show("请输入轧管外径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if ("".Equals(txtMin_h.Text.Trim()))
- {
- MessageBox.Show("请输入轧管壁厚!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- //外径必须大于壁厚。
- if (Convert.ToDouble(txtMax_d.Text.Trim()) <= Convert.ToDouble(txtMax_h.Text.Trim()))
- {
- MessageBox.Show("镦拨扩外径必须大于镦拨扩壁厚!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- //外径必须大于壁厚。
- if (Convert.ToDouble(txtMin_d.Text.Trim()) <= Convert.ToDouble(txtMin_h.Text.Trim()))
- {
- MessageBox.Show("轧管外径必须大于轧管壁厚!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 获取最大序号
- /// </summary>
- /// <returns></returns>
- private int GetMaxSeq()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreUpsettingDialExpansion.GetMaxSeq", null, this.ob);
- int index_Seq = 1;
- if (dt.Rows.Count > 0)
- {
- if (!"".Equals(dt.Rows[0][0].ToString()))
- {
- index_Seq = Convert.ToInt32(dt.Rows[0][0]) + 1;
- }
- }
- return index_Seq;
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void doAdd()
- {
- if (ValidInput())
- {
- try
- {
- //判断产线描述、钢种描述是否唯一
- string plineCode = cmbProLineInfo.Value.ToString();
- string gradeCode = cmbGZType.Value.ToString();
- string plineText = cmbProLineInfo.Text.Trim();
- string gradeText = cmbGZType.Text.Trim();
- ArrayList al = new ArrayList();
- al.Add(plineCode);
- al.Add(gradeCode);
- al.Add(txtMin_d.Text.Trim()); //轧管外径
- al.Add(txtMin_h.Text.Trim()); //轧管壁厚
- al.Add(txtMax_d.Text.Trim()); //鐓拔扩外径
- al.Add(txtMax_h.Text.Trim()); //鐓拔扩壁厚
-
-
- //从数据库中匹配是否有相同项。
- if (isOnlyAdd(al))
- {
- MessageBox.Show("二级工序:" + plineText + " 钢种描述:" + gradeText + " 鐓拔扩-外径:" + txtMax_d.Text.Trim() + " 壁厚:" + txtMax_h.Text.Trim()
- + "\n轧管-外径:" + txtMin_d.Text.Trim() + " 壁厚:" + txtMin_h.Text.Trim() + " 对应的记录已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
-
- ArrayList parm = new ArrayList();
- parm.Add(plineCode);
- parm.Add(plineText);
- parm.Add(gradeCode);
- parm.Add(gradeText);
- //创建一个序号。
- int index_seq = GetMaxSeq();
- parm.Add(index_seq);
- parm.Add(txtMin_d.Text.Trim());
- parm.Add(txtMin_h.Text.Trim());
- parm.Add(txtMax_d.Text.Trim());
- parm.Add(txtMax_h.Text.Trim());
- parm.Add(this.UserInfo.GetUserName());
- parm.Add(txtMemo.Text);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.qcm.CoreUpsettingDialExpansion";
- ccp.MethodName = "doAdd";
- ccp.ServerParams = new object[] { parm };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1) return;
- MessageUtil.ShowTips("新增成功!");
- doQuery();
- //高亮显示新增的数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- row = ultraGrid2.Rows[i];
- if (row.Cells["INDEX_SEQ"].Value.ToString().Equals(index_seq.ToString()) && row.GetValue("PLINE_CODE") == plineCode)
- {
- row.Activate();
- break;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- /// <summary>
- /// 验证产线、钢种是否唯一
- /// </summary>
- /// <param name="list">工序、钢种、外径最大、最小、壁厚最大、最小、序号(新增数据为空)</param>
- /// <returns></returns>
- private bool isOnlyAdd(ArrayList list)
- {
- DataTable dt = new DataTable();
- dt = ServerHelper.GetData("com.steering.pss.qcm.CoreUpsettingDialExpansion.isOnlyAdd", new Object[] { list }, this.ob);
- if (dt!=null && dt.Rows.Count > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private bool isOnlyUpdate(ArrayList list)
- {
- DataTable dt = new DataTable();
- dt = ServerHelper.GetData("com.steering.pss.qcm.CoreUpsettingDialExpansion.isOnlyUpdate", new Object[] { list }, this.ob);
- if (dt!=null&&dt.Rows.Count > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void doModify()
- {
- if (ultraGrid2.ActiveRow == null)
- {
- MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string validflagStr = ultraGrid2.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
- //无效数据不允许修改
- if ("0".Equals(validflagStr))
- {
- MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ValidInput())
- {
- //判断产线描述、钢种描述是否唯一
- string plineCode = cmbProLineInfo.Value.ToString();
- string plineCodeOld = ultraGrid2.ActiveRow.Cells["PLINE_CODE_OLD"].Value.ToString();
- string gradeCode = cmbGZType.Value.ToString();
- string plineText = cmbProLineInfo.Text.Trim();
- string gradeText = cmbGZType.Text.Trim();
- string GridPlineCode = ultraGrid2.ActiveRow.Cells["PLINE_CODE"].Value.ToString();
- string GridGradeCode = ultraGrid2.ActiveRow.Cells["GRADECODE"].Value.ToString();
- //需要配合序号进行修改。
- string index_seq = ultraGrid2.ActiveRow.Cells["INDEX_SEQ"].Value.ToString();
- ArrayList al = new ArrayList();
- al.Add(plineCode);
- al.Add(gradeCode);
- al.Add(txtMin_d.Text.Trim()); //轧管外径
- al.Add(txtMin_h.Text.Trim()); //轧管壁厚
- al.Add(txtMax_d.Text.Trim()); //鐓拔扩外径
- al.Add(txtMax_h.Text.Trim()); //鐓拔扩壁厚
- al.Add(index_seq); //序号
- //if (!plineCode.Equals(GridPlineCode) || !gradeCode.Equals(GridGradeCode))
- //{
- // //从数据库中匹配是否有相同项。
- // if (isOnly(plineCode, gradeCode))
- // {
- // MessageBox.Show("产线描述\"" + plineText + "\"、钢种描述\"" + gradeText + "\"已存在,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- // }
- //}
- if (isOnlyUpdate(al))
- {
- MessageBox.Show("二级工序:" + plineText + " 钢种描述:" + gradeText + " 鐓拔扩-外径:" + txtMax_d.Text.Trim() + " 壁厚:" + txtMax_h.Text.Trim()
- + "\n轧管-外径:" + txtMin_d.Text.Trim() + " 壁厚:" + txtMin_h.Text.Trim() + " 对应的记录已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
-
- //确认修改吗?
- if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- ArrayList parm = new ArrayList();
- parm.Add(plineCode);
- parm.Add(plineText);
- parm.Add(gradeCode);
- parm.Add(gradeText);
- parm.Add(txtMin_d.Text);
- parm.Add(txtMin_h.Text);
- parm.Add(txtMax_d.Text);
- parm.Add(txtMax_h.Text);
- parm.Add(this.UserInfo.GetUserName());
- parm.Add(txtMemo.Text);
-
-
- parm.Add(index_seq);
- parm.Add(plineCodeOld);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.qcm.CoreUpsettingDialExpansion";
- ccp.MethodName = "doModify";
- ccp.ServerParams = new object[] { parm };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1) return;
- MessageUtil.ShowTips("修改成功!");
- doQuery();
- //高亮显示新增的数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- row = ultraGrid2.Rows[i];
- if (row.Cells["INDEX_SEQ"].Value.ToString().Equals(index_seq.ToString()) && row.GetValue("PLINE_CODE") == plineCode)
- {
- row.Activate();
- break;
- }
- }
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void doQuery()
- {
- bool validFlag = chkValid.Checked;
-
- string titleName = txtTitleName.Text.Trim();
- ArrayList list = new ArrayList();
- list.Add(validFlag ? "0" : "");
- list.Add(titleName);
- list.Add(_gradeCode);
- list.Add(_dimater);
- list.Add(_height);
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreUpsettingDialExpansion.getLineList", new Object[] { list }, this.ob);
-
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //不同颜色区分是否有效数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- row = ultraGrid2.Rows[i];
- if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1"))
- {
- row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- row.Appearance.ForeColor = Color.Black;
- }
- }
- //内容自适应
- //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, new UltraGridColumn[] {
- // ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"]
- //});
- }
- /// <summary>
- /// GRID ROW激活时信息带至编辑区
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid2.ActiveRow;
- if (row != null)
- {
- //PLINE_CODE,PLINE_NAME,INDEX_SEQ,GRADECODE,GRADENAME,MIN_D,MIN_H,MAX_D,MAX_H
- cmbProLineInfo.Value = row.Cells["PLINE_CODE"].Value.ToString();
- cmbGZType.Value = row.Cells["GRADECODE"].Value.ToString();
-
- txtMin_d.Text = row.Cells["MIN_D"].Value.ToString();
- txtMin_h.Text = row.Cells["MIN_H"].Value.ToString();
- txtMax_d.Text = row.Cells["MAX_D"].Value.ToString();
- txtMax_h.Text = row.Cells["MAX_H"].Value.ToString();
- txtMemo.Text = row.Cells["MEMO"].Value.ToString();
- }
- }
- /// <summary>
- /// 作废或恢复
- /// </summary>
- /// <param name="isDelete">true作废 false恢复</param>
- private void doDeleteOrResume(bool isDelete)
- {
- if (ultraGrid2.ActiveRow == null)
- {
- MessageBox.Show("请选择需要" + (isDelete ? "作废" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string validflagStr = ultraGrid2.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;
- }
- }
- ArrayList param = new ArrayList();
- string index_seq = ultraGrid2.ActiveRow.Cells["INDEX_SEQ"].Value.ToString();
- param.Add(index_seq);
-
- if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "作废" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- try
- {
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreUpsettingDialExpansion.deleteLineInfo", new Object[] { param, UserInfo.GetUserName(), isDelete }, this.ob);
- if (count > 0)
- {
- MessageUtil.ShowTips((isDelete ? "作废" : "恢复") + "成功!");
- doQuery();
- Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- rowD = ultraGrid2.Rows[i];
- if (rowD.Cells["INDEX_SEQ"].Value.ToString().Equals(index_seq))
- {
- rowD.Activate();
- break;
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- /// <summary>
- /// 查询产线描述
- /// </summary>
- public Infragistics.Win.UltraWinEditors.UltraTextEditor TxtTitleName
- {
- get { return txtTitleName; }
- set { txtTitleName = value; }
- }
- /// <summary>
- /// 镦拔扩二级工序
- /// </summary>
- public Infragistics.Win.UltraWinEditors.UltraComboEditor setCmbProLineInfo
- {
- get { return cmbProLineInfo; }
- set { cmbProLineInfo = value; }
- }
- /// <summary>
- /// 钢种
- /// </summary>
- public Infragistics.Win.UltraWinEditors.UltraComboEditor setCmbGZType
- {
- get { return cmbGZType; }
- set { cmbGZType = value; }
- }
- /// <summary>
- /// 镦拔扩外径
- /// </summary>
- public Infragistics.Win.UltraWinEditors.UltraNumericEditor setTxtMaxd
- {
- get { return txtMax_d; }
- set { txtMax_d = value; }
- }
- /// <summary>
- /// 镦拔扩壁厚
- /// </summary>
- public Infragistics.Win.UltraWinEditors.UltraNumericEditor setTxtMaxh
- {
- get { return txtMax_h; }
- set { txtMax_h = value; }
- }
- /// <summary>
- /// 轧管外径
- /// </summary>
- public Infragistics.Win.UltraWinEditors.UltraNumericEditor setTxtMind
- {
- get { return txtMin_d; }
- set { txtMin_d = value; }
- }
- /// <summary>
- /// 轧管壁厚
- /// </summary>
- public Infragistics.Win.UltraWinEditors.UltraNumericEditor setTxtMinh
- {
- get { return txtMin_h; }
- set { txtMin_h = value; }
- }
- }
- }
|