| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062 |
- 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.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class FrmProductCHEMBIAS : FrmBase
- {
- int _cic = 1; //索引号
- bool isflag = false;
- int isselect = 0;
- private List<string> CicCode = new List<string>(); //做过操作的CIC
- public FrmProductCHEMBIAS()
- {
- InitializeComponent();
- }
- public FrmProductCHEMBIAS(string errMsg, OpeBase ob) : this()
- {
- this.ob = ob;
- ultraStatusBar1.Panels["ExMsg"].Text = errMsg;
- panel2.Visible = true;
- ultraStatusBar1.Visible = true;
- doQuery(isflag);
- }
- private void FrmProductCHEMBIAS_Load(object sender, EventArgs e)
- {
- BindcmbType();
- }
- private void InitSteel(string cic)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.getSteel", new object[] { cic }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable3, true);
- }
- private void BindcmbType()
- {
- #region 下拉列表
- DataTable dt1 = new DataTable();
- dt1.Columns.Add("xiaid");
- DataRow dr1 = dt1.NewRow();
- dr1["xiaid"] = ">";
- dt1.Rows.Add(dr1);
- DataRow dr2 = dt1.NewRow();
- dr2["xiaid"] = ">=";
- dt1.Rows.Add(dr2);
- DataRow dr3 = dt1.NewRow();
- dr3["xiaid"] = "=";
- dt1.Rows.Add(dr3);
- DataRow dr4 = dt1.NewRow();
- dr4["xiaid"] = " ";
- dt1.Rows.Add(dr4);
- dt1.Columns["xiaid"].Caption = "符号";
- xiaxian.DataSource = dt1;
- xiaxian.ValueMember = "xiaid";
- DataTable dts1 = new DataTable();
- dts1.Columns.Add("xiaid");
- DataRow drs1 = dts1.NewRow();
- drs1["xiaid"] = "单一元素";
- dts1.Rows.Add(drs1);
- DataRow drs2 = dts1.NewRow();
- drs2["xiaid"] = "复合元素";
- dts1.Rows.Add(drs2);
- DataRow drs4 = dts1.NewRow();
- drs4["xiaid"] = " ";
- dts1.Rows.Add(drs4);
- dts1.Columns["xiaid"].Caption = "符号";
- cmbdanyi.DataSource = dts1;
- cmbdanyi.ValueMember = "xiaid";
- DataTable dt2 = new DataTable();
- dt2.Columns.Add("shangid");
- DataRow dr5 = dt2.NewRow();
- dr5["shangid"] = "<";
- dt2.Rows.Add(dr5);
- DataRow dr6 = dt2.NewRow();
- dr6["shangid"] = "<=";
- dt2.Rows.Add(dr6);
- DataRow dr7 = dt2.NewRow();
- dr7["shangid"] = " ";
- dt2.Rows.Add(dr7);
- dt2.Columns["shangid"].Caption = "符号";
- shangxian.DataSource = dt2;
- shangxian.ValueMember = "shangid";
- DataTable dt3 = ServerHelper.GetData("com.steering.pss.qcm.CoreDropList.GetSelectstd", new Object[] { }, this.ob);//标准表
- int num = dt3.Rows.Count;
- DataTable dt4 = new DataTable();
- dt4.Columns.Add("fenlei");
- dt4.Columns.Add("fenname");
- DataRow dr;
- for (int i = 0; i < num; i++)
- {
- dr = dt4.NewRow();
- dr["fenlei"] = dt3.Rows[i]["STD_NAME"];
- dr["fenname"] = dt3.Rows[i]["STD_CODE"];
- dt4.Rows.Add(dr);
- }
- dt4.Columns["fenlei"].Caption = "名字";
- dt4.Columns["fenname"].Caption = "代码";
- fenleinumber.DataSource = dt4;
- fenleinumber.ValueMember = "fenname";
- fenleinumber.DisplayMember = "fenlei";
- DataTable dt5 = ServerHelper.GetData("com.steering.pss.qcm.CoreDropList.GetSelectinfo", new Object[] { }, this.ob);
- int num1 = dt5.Rows.Count;
- DataTable dt6 = new DataTable();
- dt6.Columns.Add("id");
- dt6.Columns.Add("name");
- dr = dt6.NewRow();
- dr["id"] = "";
- dr["name"] = "";
- dt6.Rows.Add(dr);
- for (int i = 0; i < num1; i++)
- {
- dr = dt6.NewRow();
- dr["id"] = dt5.Rows[i]["BASECODE"];
- dr["name"] = dt5.Rows[i]["BASENAME"];
- dt6.Rows.Add(dr);
- }
- dt6.Columns["id"].Caption = "类型";
- dt6.Columns["name"].Caption = "名字";
- ClsBaseInfo.SetComboItemHeight(yuanfenlei);
- yuanfenlei.DataSource = dt6;
- yuanfenlei.DisplayMember = "name";
- yuanfenlei.ValueMember = "id";
- DataTable dt7 = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.getCombaseChemA", new Object[] { }, this.ob);
- int num2 = dt7.Rows.Count;
- DataTable dt8 = new DataTable();
- dt8.Columns.Add("id");
- dt8.Columns.Add("name");
- for (int i = 0; i < num2; i++)
- {
- dr = dt8.NewRow();
- dr["id"] = dt7.Rows[i]["CHEM_CODE"] + "," + dt7.Rows[i]["CHEM_TYPE"] + "," + dt7.Rows[i]["CHEM_FORMULA"];
- dr["name"] = dt7.Rows[i]["CHEM_NAME"];
- dt8.Rows.Add(dr);
- }
- dt8.Columns["id"].Caption = "类型";
- dt8.Columns["name"].Caption = "名字";
- cmbyuansu.DataSource = dt8;
- cmbyuansu.DisplayMember = "name";
- cmbyuansu.ValueMember = "id";
- #endregion
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "doQuery":
- doQuery(isflag);
- break;
- case "doSave":
- doSave();
- break;
- case "doDelete":
- this.doDeleteOrResume(true);
- break;
- case "doResume":
- this.doDeleteOrResume(false);
- break;
- case "doClose":
- this.Close();
- break;
- }
- }
- ArrayList parmPAdd = new ArrayList(); //主表新增
- ArrayList parmPUpdate = new ArrayList(); //主表修改
- ArrayList parmCAdd = new ArrayList(); //从表新增
- ArrayList parmCUpdate = new ArrayList(); //从表修改
- ArrayList Deletelist = new ArrayList(); //删除数据或恢复数据
- ArrayList DeletelistC = new ArrayList(); //删除数据或恢复数据
- ArrayList parmSteel = new ArrayList(); //勾选的钢级牌号信息
- string deleteCic = ""; //用于钢级删除的CIC码
- private void doQuery(Boolean flag)
- {
- string stdName = "%";
- if (ultraCheckEditor1.Checked)
- stdName = ultraTextEditor1.Text.Trim();
- dataTable3.Clear();
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.doQuery", new Object[] { flag, stdName }, this.ob);
- dataTable2.Clear();
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //从表的记录也要查询出来。
- DataTable mindt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.doQueryC", new Object[] { flag, stdName }, this.ob);
- GridHelper.CopyDataToDatatable(ref mindt, ref this.dataTable2, true);
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- for (int j = 0; j < ultraGrid2.Rows[i].Cells.Count; j++)
- {
- if (j == 7) break;
- ultraGrid2.Rows[i].Cells[j].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- }
- if (ultraGrid2.Rows[i].ChildBands[0].Rows.Count > 0)
- {
- for (int j = 0; j < ultraGrid2.Rows[i].ChildBands[0].Rows.Count; j++)
- {
- for (int k = 0; k < ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells.Count; k++)
- {
- if (k == 16) break;
- ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells[k].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- }
- }
- }
- }
- //不同颜色区分是否有效数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- Infragistics.Win.UltraWinGrid.UltraGridRow minrow = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- row = ultraGrid2.Rows[i];
- if (row.ChildBands[0].Rows.Count > 0)
- {
- for (int j = 0; j < row.ChildBands[0].Rows.Count; j++)
- {
- minrow = row.ChildBands[0].Rows[j];
- if (!minrow.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
- {
- minrow.Appearance.ForeColor = Color.Red;
- row.ExpandAll();
- }
- else
- {
- minrow.Appearance.ForeColor = Color.Black;
- }
- }
- }
- if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
- {
- row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- row.Appearance.ForeColor = Color.Black;
- }
- }
- //UltraGridColumn[] col = new UltraGridColumn[] { };
- //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
- }
- private void doSave()
- {
- ultraGrid2.UpdateData();
- if (GetGridData() == 0 && (parmPAdd.Count > 0 || parmPUpdate.Count > 0 || parmCAdd.Count > 0 || parmCUpdate.Count > 0))
- {
- if (isselect == 0)
- {
- MessageBox.Show("请选择记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (MessageBox.Show("是否确认保存修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- if (ultraGrid2.ActiveRow != null)
- deleteCic = ultraGrid2.ActiveRow.Cells["CIC"].Value.ToString();
- CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
- ccp.ServerName = "com.steering.pss.qcm.CoreProductCHEMBIAS"; //服务名指的是服务端的包名+类名
- ccp.MethodName = "doSave"; //方法名指的是服务名指定类里的方法
- ccp.ServerParams = new object[] { parmPAdd, parmPUpdate, parmCAdd, parmCUpdate, parmSteel, deleteCic };//服务端方法的参数
- //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1)
- return;
- MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- doQuery(isflag);
- ExpandRow();
- CicCode.Clear();
- }
- }
- /// <summary>
- /// 删除或恢复
- /// </summary>
- /// <param name="isDelete">true删除 false恢复</param>
- private void doDeleteOrResume(bool flag)
- {
- if (GetDeleteData(flag) == -1)
- {
- return;
- }
- if (isselect == 0)
- {
- MessageBox.Show("请选择需要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (MessageBox.Show("是否确认" + (flag ? "作废" : "恢复") + "数据", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
- ccp.ServerName = "com.steering.pss.qcm.CoreProductCHEMBIAS"; //服务名指的是服务端的包名+类名
- ccp.MethodName = "doDelete"; //方法名指的是服务名指定类里的方法
- ccp.ServerParams = new object[] { Deletelist, DeletelistC, flag };//服务端方法的参数
- //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1)
- return;
- MessageBox.Show("数据" + (flag ? "作废" : "恢复") + "成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- doQuery(isflag);
- ExpandRow();
- CicCode.Clear();
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- this.ultraGrid2.UpdateData();
- if (e.Cell.Column.Key.Equals("MIN_SIGN"))
- {
- if (e.Cell.Value.ToString() == "=")
- {
- e.Cell.Row.Cells["MAX_SIGN"].Activation = Activation.ActivateOnly;
- e.Cell.Row.Cells["MAX_VAL"].Activation = Activation.ActivateOnly;
- }
- else
- {
- e.Cell.Row.Cells["MAX_SIGN"].Activation = Activation.AllowEdit;
- e.Cell.Row.Cells["MAX_VAL"].Activation = Activation.AllowEdit;
- }
- }
- else if (e.Cell.Column.Key.Equals("ASSORTMENT_NAME"))
- {
- e.Cell.Row.Cells["ASSORTMENT_CODE"].Value = e.Cell.Row.Cells["ASSORTMENT_NAME"].Value;
- }
- else if (e.Cell.Column.Key.Equals("STD_NAME"))
- {
- e.Cell.Row.Cells["STD_CODE"].Value = e.Cell.Row.Cells["STD_NAME"].Value;
- }
- else if (e.Cell.Column.Key.Equals("CHEM_NAME"))
- {
- String str = e.Cell.Row.Cells["CHEM_NAME"].Value.ToString();
- string[] str1 = str.Split(',');
- e.Cell.Row.Cells["CHEM_CODE"].Value = str1[0];
- e.Cell.Row.Cells["WHOLE_BACKLOG"].Value = str1[1];
- e.Cell.Row.Cells["CHEM_FORMULA"].Value = str1[2];
- }
- else if (e.Cell.Column.Key.Equals("cb"))
- {
- Activation activation = Activation.NoEdit;
- if (Convert.ToBoolean(e.Cell.Value))
- {
- activation = Activation.AllowEdit;
- }
- CellsCollection cells = e.Cell.Row.Cells;
- for (int i = 0; i < cells.Count; i++)
- {
- if (!cells[i].Column.Key.Equals("cb")) //i!=9
- {
- if (i == 6) break;
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- // e.Cell.Value = !Convert.ToBoolean(e.Cell.Value);
- }
- else if (e.Cell.Column.Key.Equals("ck1"))
- {
- Activation activation = Activation.ActivateOnly;
- if (Convert.ToBoolean(e.Cell.Value))
- {
- activation = Activation.AllowEdit;
- }
- CellsCollection cells = e.Cell.Row.Cells;
- for (int i = 0; i < cells.Count; i++)
- {
- if (!cells[i].Column.Key.Equals("ck1")) //i!=9
- {
- if (i == 15) break;
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- }
- SaveCic(e);
- ultraGrid2.UpdateData();
- }
- private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
- {
- ultraGrid2.UpdateData();
- UltraGridRow ugr = this.ultraGrid2.ActiveRow;
- if (ugr == null)
- return;
- if (!ugr.HasParent()) //主表
- {
- string cicStr = "";
- string cic = "";
- DataRow[] dr = dataTable1.Select("", "CIC DESC");
- if (dr.Length > 0)
- {
- cic = dr[0]["CIC"].ToString();
- }
- if (!cic.Equals(""))
- {
- int number = int.Parse(cic.Substring(3, 6));
- cicStr = "CIC" + string.Format("{0:000000}", number + 1);
- _cic = number + 1;
- }
- else
- {
- cicStr = "CIC" + string.Format("{0:000000}", _cic);
- _cic = _cic + 1;
- }
- //赋值理化索引号
- ugr.Cells["CIC"].Value = cicStr;
- // ugr.Cells["cb"].Value = false;
- if (!Convert.ToBoolean(ugr.Cells["cb"].Value))
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- if (!ugr.Cells[i].Column.Key.Equals("cb"))
- ugr.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- }
- else
- {
- int indexSeq = 0;
- DataRow[] dr = dataTable2.Select("CIC='" + ugr.Cells["CIC"].Value.ToString() + "'", "INDEX_SEQ DESC");
- if (dr.Length > 0)
- {
- indexSeq = Convert.ToInt32(dr[0]["INDEX_SEQ"]);
- }
- indexSeq += 1;
- //赋值序号
- this.ultraGrid2.DisplayLayout.ActiveRow.Cells["INDEX_SEQ"].Value = indexSeq;
- if (!Convert.ToBoolean(ugr.Cells["ck1"].Value))
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- if (!ugr.Cells[i].Column.Key.Equals("ck1"))
- ugr.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- private int GetGridData()
- {
- this.ultraGrid2.UpdateData();
- this.ultraGrid1.UpdateData();
- parmPAdd = new ArrayList();
- parmPUpdate = new ArrayList();
- parmCAdd = new ArrayList();
- parmCUpdate = new ArrayList();
- UltraGridRow ugr = ultraGrid2.ActiveRow;
- isselect = 0;
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (row.Cells["cb"].Value.ToString().ToUpper() == "TRUE")
- {
- ArrayList plistAdd = new ArrayList();
- ArrayList plistUpdate = new ArrayList();
- isselect += 1;
- if (row.Cells["STD_NAME"].Value.ToString() == "")
- {
- MessageBox.Show("请选择标准名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- //row.Activate();
- return -1;
- }
- //if (row.Cells["ASSORTMENT_NAME"].Value.ToString() == "")
- //{
- // MessageBox.Show("请选择品种名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // row.Activate();
- // return -1;
- //}
- string assortment = row.Cells["ASSORTMENT_NAME"].Value.ToString();
- UltraGridRow[] arrRow = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHK" }, new string[] { "True" });
- if (assortment != "" && arrRow.Length > 0)
- {
- MessageBox.Show("钢种分类和右边的钢级(牌号)不能同时存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // row.Activate();
- return -1;
- }
- else if (assortment == "" && arrRow.Length <= 0)
- {
- MessageBox.Show("请选择钢种分类或者右边钢级(牌号)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (row.Cells["VALIDFLAG"].Value.ToString() == "") //新增
- {
- plistAdd.Add(row.Cells["CIC"].Value.ToString());
- plistAdd.Add(row.Cells["STD_CODE"].Value.ToString());
- plistAdd.Add(row.Cells["STD_NAME"].Text);
- plistAdd.Add(row.Cells["ASSORTMENT_CODE"].Value.ToString());
- plistAdd.Add(row.Cells["ASSORTMENT_NAME"].Text);
- plistAdd.Add(this.UserInfo.GetUserName());
- parmPAdd.Add(plistAdd);
- }
- else
- {
- plistUpdate.Add(row.Cells["CIC"].Value.ToString());
- plistUpdate.Add(row.Cells["STD_CODE"].Value.ToString());
- plistUpdate.Add(row.Cells["STD_NAME"].Text);
- plistUpdate.Add(row.Cells["ASSORTMENT_CODE"].Value.ToString());
- plistUpdate.Add(row.Cells["ASSORTMENT_NAME"].Text);
- plistUpdate.Add(this.UserInfo.GetUserName());
- parmPUpdate.Add(plistUpdate);
- }
- }
- if (row.Cells["VALIDFLAG"].Value.ToString() != "" || (row.Cells["VALIDFLAG"].Value.ToString() == "" && row.Cells["cb"].Value.ToString().ToUpper() == "TRUE"))
- {
- if (row.ChildBands[0].Rows.Count > 0)
- {
- foreach (UltraGridRow crow in row.ChildBands[0].Rows)
- {
- if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE")
- {
- UltraGridRow pRow = crow.ParentRow;
- string assortment = pRow.Cells["ASSORTMENT_NAME"].Text;
- UltraGridRow[] arrRow = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHK" }, new string[] { "True" });
- if (assortment != "" && arrRow.Length > 0)
- {
- MessageBox.Show("钢种分类和右边的钢级(牌号)不能同时存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // row.Activate();
- return -1;
- }
- else if (assortment == "" && arrRow.Length <= 0)
- {
- MessageBox.Show("请选择钢种分类或者右边钢级(牌号)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- isselect += 1;
- if (crow.Cells["CHEM_NAME"].Value.ToString() == "")
- {
- MessageBox.Show("请选择化学元素描述", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- string chem_type = ""; //化学元素类型
- switch (crow.Cells["whole_backlog"].Value.ToString())
- {
- case "单一元素":
- chem_type = "A";
- break;
- case "复合元素":
- chem_type = "B";
- break;
- }
- string min_sign = crow.Cells["MIN_SIGN"].Text.Trim();
- string min_val = crow.Cells["MIN_VAL"].Value.ToString();
- string max_sign = crow.Cells["MAX_SIGN"].Text.Trim();
- string max_val = crow.Cells["MAX_VAL"].Value.ToString();
- //string std_min_sign = crow.Cells["STD_MIN_SIGN"].Text.Trim();
- string std_min_val = crow.Cells["STD_MIN_VAL"].Value.ToString();
- //string std_max_sign = crow.Cells["STD_MAX_SIGN"].Text.Trim();
- string std_max_val = crow.Cells["STD_MAX_VAL"].Value.ToString();
- if (min_sign == "" && max_sign == "")
- {
- MessageBox.Show("化学成分上限符号和下限符号请至少选择一项", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- if (min_sign != "" && min_val == "")
- {
- MessageBox.Show("请输入化学成分下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- if (min_sign == "" && min_val != "")
- {
- MessageBox.Show("化学成分下限值不为空,请选择化学元素下限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- if (max_sign != "" && max_val == "")
- {
- MessageBox.Show("请输入化学成分上限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- if (max_sign == "" && max_val != "")
- {
- MessageBox.Show("化学成分上限值不为空,请选择化学元素上限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- if (min_sign != "=")
- {
- if (min_val != "" && !StringUtil.IsNumber(min_val))
- {
- MessageBox.Show("化学成分下限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- if (max_val != "" && !StringUtil.IsNumber(max_val))
- {
- MessageBox.Show("化学成分上限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- if (min_val != "" && max_val != "")
- {
- if (Convert.ToDouble(max_val) < Convert.ToDouble(min_val))
- {
- MessageBox.Show("化学成分上限值不能小于下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- }
- }
- //if (min_sign != "" && max_sign == "")
- //{
- // exsitchem = 1; //下限
- //}
- //if (max_sign != "" && min_sign == "")
- // exsitchem = 2; //上限
- //if (min_sign != "" && max_sign != "")
- // exsitchem = 3; //上下限存在
- //if (std_min_sign != "" && std_min_val == "")
- //{
- // MessageBox.Show("请输入允许偏差下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // crow.Activate();
- // return -1;
- //}
- //if (std_min_sign == "" && std_min_val != "")
- //{
- // MessageBox.Show("允许偏差下限值存在,请选择下限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // crow.Activate();
- // return -1;
- //}
- //if (std_max_sign != "" && std_max_sign == "")
- //{
- // MessageBox.Show("请输入允许偏差上限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // crow.Activate();
- // return -1;
- //}
- //if (std_max_sign == "" && std_max_val != "")
- //{
- // MessageBox.Show("允许偏差上限值存在,请选择上限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // crow.Activate();
- // return -1;
- //}
- //if (exsitchem == 1 && std_max_val != "")
- //{
- // MessageBox.Show("化学成分不存在上限值,允许偏差也不能存在上偏差", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // crow.Activate();
- // return -1;
- //}
- //if (exsitchem == 2 && std_min_val != "")
- //{
- // MessageBox.Show("化学成分不存在下限值,允许偏差也不能存在下偏差", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // crow.Activate();
- // return -1;
- //}
- if (std_min_val != "")
- {
- if (!StringUtil.IsNumber(std_min_val))
- {
- MessageBox.Show("允许偏差下偏差:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- }
- if (std_max_val != "")
- {
- if (!StringUtil.IsNumber(std_max_val))
- {
- MessageBox.Show("允许偏差上偏差:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- crow.Activate();
- return -1;
- }
- }
- //if (std_min_val != "" && std_max_val != "")
- //{
- // if (Convert.ToDouble(std_max_val) < Convert.ToDouble(std_min_val))
- // {
- // MessageBox.Show("允许偏差上限值不能小于下限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // crow.Activate();
- // return -1;
- // }
- //}
- ArrayList clistAdd = new ArrayList();
- ArrayList clistUpdate = new ArrayList();
- if (crow.Cells["VALIDFLAG"].Value.ToString() == "")
- {
- clistAdd.Add(crow.Cells["CIC"].Value.ToString());
- clistAdd.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
- clistAdd.Add(crow.Cells["CHEM_CODE"].Value.ToString());
- clistAdd.Add(crow.Cells["CHEM_NAME"].Text);
- clistAdd.Add(chem_type);
- clistAdd.Add(crow.Cells["CHEM_FORMULA"].Value.ToString());
- clistAdd.Add(min_sign);
- clistAdd.Add(min_val);
- clistAdd.Add(max_sign);
- clistAdd.Add(max_val);
- // clistAdd.Add(std_min_sign);
- clistAdd.Add(std_min_val);
- //clistAdd.Add(std_max_sign);
- clistAdd.Add(std_max_val);
- clistAdd.Add(this.UserInfo.GetUserName());
- parmCAdd.Add(clistAdd);
- }
- else
- {
- clistUpdate.Add(crow.Cells["CIC"].Value.ToString());
- clistUpdate.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
- clistUpdate.Add(crow.Cells["CHEM_CODE"].Value.ToString());
- clistUpdate.Add(crow.Cells["CHEM_NAME"].Text);
- clistUpdate.Add(chem_type);
- clistUpdate.Add(crow.Cells["CHEM_FORMULA"].Value.ToString());
- clistUpdate.Add(min_sign);
- clistUpdate.Add(min_val);
- clistUpdate.Add(max_sign);
- clistUpdate.Add(max_val);
- //clistUpdate.Add(std_min_sign);
- clistUpdate.Add(std_min_val);
- //clistUpdate.Add(std_max_sign);
- clistUpdate.Add(std_max_val);
- clistUpdate.Add(this.UserInfo.GetUserName());
- parmCUpdate.Add(clistUpdate);
- }
- }
- }
- }
- }
- }
- if (GetGrid1Data() == -1)
- return -1;
- return 0;
- }
- private int GetGrid1Data()
- {
- ultraGrid1.UpdateData();
- ultraGrid2.UpdateData();
- parmSteel = new ArrayList();
- deleteCic = "";
- UltraGridRow ugr = ultraGrid2.ActiveRow;
- if (ugr == null)
- return -1;
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- ArrayList tmpList = new ArrayList();
- tmpList.Add(ugr.Cells["CIC"].Value.ToString());
- tmpList.Add(row.Cells["STEELCODE"].Value);
- tmpList.Add(row.Cells["STEELNAME"].Value);
- tmpList.Add(this.UserInfo.GetUserName());
- parmSteel.Add(tmpList);
- }
- }
- return 0;
- }
- private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
- {
- if (this.ultraCheckEditor1.Checked)
- {
- this.ultraTextEditor1.ReadOnly = false;
- }
- else
- {
- this.ultraTextEditor1.ReadOnly = true;
- }
- }
- private void ultraCheckEditor4_CheckedChanged(object sender, EventArgs e)
- {
- if (this.ultraCheckEditor4.Checked)
- {
- isflag = true;
- }
- else
- {
- isflag = false;
- }
- }
- /// <summary>
- /// 得到删除或恢复的数据
- /// </summary>
- /// <param name="flag">true 删除 false 恢复</param>
- /// <returns></returns>
- private int GetDeleteData(bool flag)
- {
- isselect = 0;
- this.ultraGrid2.UpdateData();
- Deletelist = new ArrayList();
- DeletelistC = new ArrayList();
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (row.Cells["cb"].Value.ToString().ToUpper() == "TRUE")
- {
- isselect += 1;
- if (flag) //删除
- {
- if (row.Cells["VALIDFLAG"].Value.ToString() != "有效")
- {
- MessageBox.Show("无效数据,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- ArrayList list = new ArrayList();
- list.Add(this.UserInfo.GetUserName());
- list.Add(row.Cells["CIC"].Value.ToString());
- Deletelist.Add(list);
- }
- else //恢复
- {
- if (row.Cells["VALIDFLAG"].Value.ToString() == "有效")
- {
- MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- Deletelist.Add(row.Cells["CIC"].Value.ToString());
- if (row.ChildBands[0].Rows.Count > 0)
- {
- foreach (UltraGridRow crow in row.ChildBands[0].Rows)
- {
- if (crow.Cells["VALIDFLAG"].Value.ToString() == "有效")
- {
- MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE")
- {
- ArrayList plist = new ArrayList();
- plist.Add(crow.Cells["CIC"].Value.ToString());
- plist.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
- DeletelistC.Add(plist);
- }
- }
- }
- }
- }
- else
- {
- if (row.ChildBands[0].Rows.Count > 0)
- {
- foreach (UltraGridRow crow in row.ChildBands[0].Rows)
- {
- if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE")
- {
- isselect += 1;
- if (flag)
- {
- if (crow.Cells["VALIDFLAG"].Value.ToString() != "有效")
- {
- MessageBox.Show("无效数据,无法作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- ArrayList clist = new ArrayList();
- clist.Add(this.UserInfo.GetUserName());
- clist.Add(crow.Cells["CIC"].Value.ToString());
- clist.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
- DeletelistC.Add(clist);
- }
- else
- {
- if (crow.Cells["VALIDFLAG"].Value.ToString() == "有效")
- {
- MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (row.Cells["cb"].Value.ToString().ToUpper() == "FALSE" && row.Cells["VALIDFLAG"].Value.ToString() != "有效")
- {
- MessageBox.Show("主记录无效,不能单独恢复从记录,\n请先恢复主记录或主从记录一起恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return -1;
- }
- ArrayList plist = new ArrayList();
- plist.Add(crow.Cells["CIC"].Value.ToString());
- plist.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
- DeletelistC.Add(plist);
- }
- }
- }
- }
- }
- }
- return 0;
- }
- private void SaveCic(CellEventArgs e)
- {
- if (e.Cell.Row.HasParent())
- {
- if (e.Cell.Row.Cells["ck1"].Value.ToString().ToUpper() == "TRUE"
- && !CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString()))
- {
- CicCode.Add(e.Cell.Row.Cells["CIC"].Value.ToString());
- }
- else if (e.Cell.Row.Cells["ck1"].Value.ToString().ToUpper() != "TRUE"
- && CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString()))
- {
- CicCode.Remove(e.Cell.Row.Cells["CIC"].Value.ToString()); //取消按钮 则取消保存的理化标准码
- }
- }
- else if (e.Cell.Row.ChildBands[0].Rows.Count > 0)
- {
- if (e.Cell.Row.Cells["cb"].Value.ToString().ToUpper() == "TRUE"
- && !CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString()))
- {
- CicCode.Add(e.Cell.Row.Cells["CIC"].Value.ToString());
- }
- }
- }
- private void ExpandRow()
- {
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (CicCode.Contains(row.Cells["CIC"].Value.ToString()))
- {
- row.ExpandAll();
- row.Activate();
- }
- }
- }
- UltraGridRow oldActiveRow = null; //之前激活的主记录行
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- UltraGridRow ugr = ultraGrid2.ActiveRow; //当前激活行
- if (ugr == null)
- return;
- UltraGridRow parentActiveRow = null; //主记录行
- if (ugr.HasParent())
- {
- parentActiveRow = ugr.ParentRow;
- //parentActiveRow.Cells["cb"].Value = true;
- }
- else
- {
- // ugr.Cells["cb"].Value = true;
- parentActiveRow = ugr;
- }
- if (oldActiveRow != parentActiveRow)
- {
- if (oldActiveRow != null)
- {
- oldActiveRow.Cells["cb"].Value = false;
- for (int i = 0; i < oldActiveRow.ChildBands[0].Rows.Count; i++)
- {
- oldActiveRow.ChildBands[0].Rows[i].Cells["ck1"].Value = false;
- }
- }
- string cic = parentActiveRow.Cells["CIC"].Value.ToString(); //主记录 子记录都有CIC字段 且主从关系的值一样
- InitSteel(cic);
- ultraGrid2.UpdateData();
- }
- oldActiveRow = parentActiveRow;
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (!e.Row.HasParent())
- {
- if (e.Row.Cells["cb"].Value.ToString().ToUpper() == "TRUE")
- {
- e.Row.Cells["STD_NAME"].Activation = Activation.AllowEdit;
- e.Row.Cells["ASSORTMENT_NAME"].Activation = Activation.AllowEdit;
- }
- }
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "查询":
- doQuery(isflag);
- break;
- case "保存":
- doSave();
- break;
- case "确认":
- break;
- case "作废":
- doDeleteOrResume(true);
- break;
- case "恢复":
- doDeleteOrResume(false);
- break;
- case "关闭":
- this.Close();
- break;
- }
- }
- }
- }
|