| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- 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.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class JGCodeManage : FrmBase
- {
- private FrmJGCodeManage frm;
- public JGCodeManage(OpeBase ob, string mscB, string msc_descB, string alpha,
- string stdName, string stdCode, string stdType, string steel, string dimaterCp,
- string heightCp, string custAlphaNo, string specialDesc, string ordLnPk, string steelCode)
- {
- InitializeComponent();
- //base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
- //base.UpdateStyles();
- this.StartPosition = FormStartPosition.CenterScreen;
- this.IsLoadUserView = true;
- _ob = ob;
- msc = mscB;
- msc_desc = msc_descB;
- _stdName = stdName;
- _stdCode = stdCode;
- _stdType = stdType;
- _alpha = alpha;
- _steel = steel;
- _dimaterCp = dimaterCp;
- _heightCp = heightCp;
- _custAlphaNo = custAlphaNo == "" ? "/" : custAlphaNo;
- _specialDesc = specialDesc == "" ? "/" : specialDesc;
- _ordLnPk = ordLnPk;
- _steelCode = steelCode;
- frm = new FrmJGCodeManage();
- frm.PopupLoad("", _ob);
- this.panel1.Controls.Add(frm.UltraPanel1);
- this.panel1.Controls.Add(frm.UltraExpandableGroupBox1);
- this.panel1.Controls.Add(frm.UltraGrid1);
- frm.UltraGrid1.BringToFront();
- frm.UltraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = false;
- frm.UltraGrid1.DisplayLayout.Bands[0].Columns["CHK"].CellActivation = Activation.AllowEdit;
- frm.UltraGrid1.CellChange += new CellEventHandler(UltraGrid1_CellChange);
- SetDefaultCondition();
- this.DoubleBuffered = true;
- SetStyle(ControlStyles.AllPaintingInWmPaint |
- ControlStyles.OptimizedDoubleBuffer, true);
- }
- private OpeBase _ob;
- private string msc;
- private string msc_desc;
- private string _stdName;
- private string _stdCode;
- private string _stdType;
- private string _alpha;
- private string _steel;
- private string _steelCode;
- private string _dimaterCp;
- private string _heightCp;
- private string _custAlphaNo;
- private string _model;
- private string _psc;
- private string _specialDesc;
- private string _ordLnPk;
- //选择的接箍
- private List<string> _choiceJgCodes = new List<string>();
- private void doQuery()
- {
- frm.ToolBar_Click(null, "Query");
- RefreshMscJG();
- }
- private void SetDefaultCondition()
- {
- if (_stdType == "" && _stdName == "") return;
- //frm.StdName = _stdName;
- frm.UltraCheckEditor3.Checked = true;
- //frm.UltraCheckEditor3.Enabled = false;
- frm.UltraTextEditor4.Text = _steel;
- //frm.UltraTextEditor4.Enabled = false;
- //DataTable dt = (DataTable)frm.UltraComboEditor7.DataSource;
- //dt.DefaultView.RowFilter = "STD_NAME = '"+ _stdName +"'";
- //if (frm.UltraComboEditor7.Items.Count > 0)
- //{
- // frm.UltraComboEditor7.SelectedIndex = 0;
- //}
- //frm.UltraComboEditor7.Enabled = false;
- DataTable dt2 = (DataTable)frm.UltraComboEditor3.DataSource;
- dt2.DefaultView.RowFilter = "STEELNAME = '" + _steel + "'";
- if (frm.UltraComboEditor3.Items.Count > 0)
- {
- frm.UltraComboEditor3.SelectedIndex = 0;
- }
- //frm.UltraComboEditor3.Enabled = false;
- if (_dimaterCp != "")
- {
- frm.NumDimaterCp.Checked = true;
- frm.NumDimaterCp.Value = double.Parse(_dimaterCp);
- }
- if (_heightCp != "")
- {
- frm.NumHeightCp.Checked = true;
- frm.NumHeightCp.Value = double.Parse(_heightCp);
- }
- }
- private void RefreshMscJG()
- {
- //_choiceJgCodes.Clear();
- //DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGAndMSC.doQuery",
- // new object[]{msc, "A"}, _ob);
- //IQueryable<UltraGridRow> iqueryable = frm.UltraGrid1.Rows.AsQueryable();
- //foreach (DataRow dr in dt.Rows)
- //{
- // _choiceJgCodes.Add(dr["CODE_JG"].ToString());
- // UltraGridRow[] rows = iqueryable.Where("CODE_JG = '" + dr["CODE_JG"].ToString() + "'").ToArray();
- // if (rows.Length > 0)
- // {
- // rows[0].Cells["CHK"].Value = true;
- // }
- //}
- //frm.UltraGrid1.UpdateData();
- }
- private void JGCodeManage_Load(object sender, EventArgs e)
- {
- doQuery();
- }
- //选择JG码,并将JG码的相应信息写到关联表中。
- private void ultraButton1_Click(object sender, EventArgs e)
- {
- try
- {
- this.ob = this._ob;
- frm.UltraGrid1.UpdateData();
- IQueryable<UltraGridRow> queryableRows = frm.UltraGrid1.Rows.AsQueryable().Where(
- a => a.GetValue("CHK") == "True");
- if (queryableRows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一条数据后,再进行操作!");
- return;
- }
- //暂时不对接箍的标准做限制。
- //UltraGridRow[] rows = queryableRows.Where(a=> a.GetValue("STD_NAME") != _stdName).ToArray();
- //if (rows.Length > 0)
- //{
- // MessageUtil.ShowWarning("该冶金规范只能关联标准名称为["+ _stdName +"]的接箍!");
- // rows[0].Activate();
- // return;
- //}
- //DataRow orderLineRow = GetSlmOrderLineByPk(_ordLnPk);
- //if (orderLineRow != null)
- //{
- // foreach (UltraGridRow row in queryableRows)
- // {
- // if (row.GetValue("MODEL_CODE") != orderLineRow["MODEL_CODE"].ToString())
- // {
- // MessageUtil.ShowWarning("只能关联扣型为" + orderLineRow["MODEL_DESC"].ToString() + "的接箍");
- // row.Activate();
- // return;
- // }
- // }
- //}
- foreach (UltraGridRow row in queryableRows)
- {
- if (row.GetValue("REP_STEELCODE") != "" && !row.GetValue("REP_STEELCODE").Contains(_steelCode))
- {
- MessageUtil.ShowWarning("只能关联替代钢级包含" + _steel + "的接箍");
- row.Activate();
- return;
- }
- if (row.GetValue("REP_STEELCODE") == "" && row.GetValue("STEELCODE_JG") != _steelCode)
- {
- MessageUtil.ShowWarning("只能关联钢级为" + _steel + "的接箍");
- row.Activate();
- return;
- }
- }
- ArrayList parm = new ArrayList();
- int flag = 0;
- foreach (UltraGridRow row in queryableRows)
- {
- if (IsRepeat(msc, _specialDesc, row.GetValue("CODE_JG")))
- {
- MessageUtil.ShowWarning(msc + "下已存在重复的接箍数据!");
- row.Activate();
- return;
- }
- ArrayList list = new ArrayList();
- flag += 1;
- list.Add(msc);
- list.Add(msc_desc);
- list.Add(row.GetValue("CODE_JG"));
- list.Add("A");
- list.Add(this.UserInfo.GetUserName());
- list.Add(_custAlphaNo);
- list.Add(_specialDesc);
- parm.Add(list);
- }
- ServerHelper.SetData("com.steering.pss.qcm.JGAndMSC.AndJG",
- new object[] { parm }, ob);
- if (flag != 0)
- {
- MessageUtil.ShowTips("操作成功!");
- }
- this.DialogResult = DialogResult.OK;
- }
- catch (Exception ex) { }
- }
- /// <summary>
- /// 是否重复
- /// </summary>
- /// <param name="msc"></param>
- /// <param name="custAlpha"></param>
- /// <param name="codeJg"></param>
- /// <returns></returns>
- private bool IsRepeat(string msc, string orderSpecialDesc, string codeJg)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGAndMSC.IsRepeat",
- new object[] { msc, orderSpecialDesc, codeJg }, ob);
- if (dt.Rows[0][0].ToString() == "0")
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- private DataRow GetSlmOrderLineByPk(string orderLnPk)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.getSlmOrderLineByPk",
- new object[] { orderLnPk }, _ob);
- if (dt.Rows.Count > 0)
- {
- return dt.Rows[0];
- }
- else
- {
- return null;
- }
- }
- private void ultraButton2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- #if !DEBUG
- try
- {
- #endif
- switch (e.Tool.Key)
- {
- case "查询":
- doQuery();
- break;
- case "新增":
- frm.ToolBar_Click(null, "Add");
- RefreshMscJG();
- break;
- case "修改":
- frm.ToolBar_Click(null, "Update");
- RefreshMscJG();
- break;
- case "作废":
- frm.ToolBar_Click(null, "Delete");
- RefreshMscJG();
- break;
- case "恢复":
- frm.ToolBar_Click(null, "Resume");
- RefreshMscJG();
- break;
- case "刷新":
- frm.ToolBar_Click(null, "Refresh");
- RefreshMscJG();
- break;
- }
- #if !DEBUG
- }
- catch (Exception ex) { }
- #endif
- }
- private void UltraGrid1_CellChange(object sender, CellEventArgs e)
- {
- //frm.UltraGrid1.UpdateData();
- //if (e.Cell.Row.Cells["CHK"].Value.ToString() == "True")
- //{
- // //REP_STEELCODE
- // string[] repSteelCodes = e.Cell.Row.Cells["REP_STEELCODE"].Value.ToString().Split(';');
- // string[] steels = new string[repSteelCodes.Length + 1];
- // for(int i = 0; i < repSteelCodes.Length; i++)
- // {
- // steels[i] = repSteelCodes[i];
- // }
- // steels[steels.Length - 1] = e.Cell.Row.Cells["STEELCODE_JG"].Value.ToString();
- // ShowBLForm(steels);
- //}
- //frm.UltraGrid1.UpdateData();
- //if (e.Cell.Column.Key == "CHK")
- //{
- // if (e.Cell.Value.ToString() == "True")
- // {
- // if (_choiceJgCodes.Contains(e.Cell.Row.GetValue("CODE_JG")) == false)
- // {
- // _choiceJgCodes.Add(e.Cell.Row.GetValue("CODE_JG"));
- // }
- // }
- // else
- // {
- // _choiceJgCodes.Remove(e.Cell.Row.GetValue("CODE_JG"));
- // }
- //}
- }
- }
- }
|