| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class FrmProductGrade : FrmBase
- {
- List<int> list = new List<int>();
- int number = 0;
- private int _index; //临时索引列
- public FrmProductGrade()
- {
- InitializeComponent();
- ExceptionHelper.RegistException();
- }
- public void PopupLoad(string customInfo, OpeBase ob)
- {
- this.CustomInfo = customInfo;
- this.ob = ob;
- this.OnLoad(EventArgs.Empty);
- }
- private void FrmProductGrade_Load(object sender, EventArgs e)
- {
- BindcmbType();
- }
- 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 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.GetDropFenLei", 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]["BASENAME"];
- dr["fenname"] = dt3.Rows[i]["BASECODE"];
- dt4.Rows.Add(dr);
- }
- dt4.Columns["fenlei"].Caption = "钢种类型";
- dt4.Columns["fenname"].Caption = "钢种代码";
- fenleinumber.DataSource = dt4;
- fenleinumber.ValueMember = "fenname";
- fenleinumber.DisplayMember = "fenlei";
- ClsBaseInfo.SetComboItemHeight(fenleinumber);
- DataTable dt5 = ServerHelper.GetData("com.steering.pss.qcm.CoreDropList.GetSelect", new Object[] { }, this.ob);
- int num1 = dt5.Rows.Count;
- DataTable dt6 = new DataTable();
- dt6.Columns.Add("id");
- dt6.Columns.Add("name");
- for (int i = 0; i < num1; i++)
- {
- dr = dt6.NewRow();
- dr["id"] = dt5.Rows[i]["CHEM_CODE"];
- dr["name"] = dt5.Rows[i]["CHEM_NAME"];
- dt6.Rows.Add(dr);
- }
- dt6.Columns["id"].Caption = "类型";
- dt6.Columns["name"].Caption = "名字";
- yuanfenlei.DataSource = dt6;
- yuanfenlei.ValueMember = "id";
- yuanfenlei.DisplayMember = "name";
- #endregion
- }
- /// <summary>
- /// 初始下拉框
- /// </summary>
- /// <param name="dt">数据表</param>
- /// <param name="uce">下拉框</param>
- /// <param name="methodId">方法名</param>
- /// <param name="desc">描述</param>
- /// <param name="code">代码</param>
- private void InitDropList(ref DataTable dt, UltraComboEditor uce, string methodId, string desc)
- {
- dt = ServerHelper.GetData(methodId, null, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- uce.DataSource = dt;
- uce.Text = desc;
- uce.DisplayMember = desc;
- }
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "doQuery":
- try
- {
- this.Cursor = Cursors.WaitCursor;
- doQuery(false);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- break;
- case "doSave":
- doSave();
- break;
- case "QueryKey":
- try
- {
- this.Cursor = Cursors.WaitCursor;
- doQuery(true);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- break;
- case "doDelete":
- this.doDeleteOrResume(true);
- break;
- case "doResume":
- this.doDeleteOrResume(false);
- break;
- case "Refresh":
- BindcmbType();
- break;
- case "Export":
- GridHelper.ulGridToExcel(ultraGrid2, "钢种信息");
- break;
- case "doClose":
- this.Close();
- break;
- }
- }
- private void doSave()
- {
- number = 0;
- int count = 0;
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (row.GetValue("cb") == "True")
- {
- count++;
- }
- foreach (UltraGridRow row2 in row.ChildBands[0].Rows)
- {
- if (row2.GetValue("check2") == "True")
- {
- count++;
- }
- }
- }
- if (count == 0)
- {
- MessageBox.Show("您当前没有勾选任何行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- int chkCnt = ultraGrid2.Rows.AsQueryable().Where("cb = 'True'").Count();
- int dstCnt = ultraGrid2.Rows.AsQueryable().Where("cb = 'True'")
- .Select(a => a.GetValue("GRADENAME")).Distinct().Count();
- if (chkCnt != dstCnt)
- {
- MessageUtil.ShowWarning("钢种名称不能重复!");
- return;
- }
- save();
- }
- private bool CheckGrd(UltraGridRow row)
- {
- if (row.Cells["COEFFICIENT"].Value.ToString().Length > 5)
- {
- MessageBox.Show("钢种系数填写错误,总长度4位 小数2位!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (row.Cells["GRADENAME"].Value.ToString() == "")
- {
- MessageBox.Show("请输入钢种名称!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (row.GetValue("VALIDFLAG") == "")
- {
- if (isExistGradeName(row.Cells["GRADENAME"].Value.ToString()) == true)
- {
- MessageUtil.ShowWarning("系统已存在钢种名称[" + row.Cells["GRADENAME"].Value.ToString() + "]!");
- row.Cells["GRADENAME"].Activate();
- return false;
- }
- }
- else
- {
- if (row.Cells["GRADENAME"].Value.ToString() != row.Cells["GRADENAME_OLD"].Value.ToString())
- {
- if (isExistGradeName(row.Cells["GRADENAME"].Value.ToString()) == true)
- {
- MessageUtil.ShowWarning("系统已存在钢种名称[" + row.Cells["GRADENAME"].Value.ToString() + "]!");
- row.Cells["GRADENAME"].Activate();
- return false;
- }
- }
- }
- if (row.Cells["ASSORTMENT_NAME"].Value.ToString() == "")
- {
- MessageBox.Show("请输入钢种分类名称!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (row.Cells["COEFFICIENT"].Value.ToString() == "")
- {
- MessageBox.Show("请输入钢种系数!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- return true;
- }
- private bool CheckGrdChm(UltraGridRow row, string gradeCode)
- {
- if (row.Cells["CHEM_NAME"].Value.ToString() == "")
- {
- MessageBox.Show("请选择化学元素描述!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- if (row.Cells["STDMIN"].Value.ToString().Length > 10)
- {
- MessageBox.Show("范围下限值最大只能输入十位数!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- if (row.Cells["STDMAX"].Value.ToString().Length > 10)
- {
- MessageBox.Show("范围上限值最大只能输入十位数!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- if (row.Cells["STDMIN_SIGN"].Value.ToString() != "")
- {
- try
- {
- double.Parse(row.Cells["STDMIN"].Value.ToString());
- }
- catch
- {
- MessageBox.Show("范围下限值类型输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- }
- if (row.Cells["STDMAX_SIGN"].Value.ToString() != "")
- {
- try
- {
- double.Parse(row.Cells["STDMAX"].Value.ToString());
- }
- catch
- {
- MessageBox.Show("范围上限值类型输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- }
- if (row.Cells["STDMIN_SIGN"].Value.ToString() != "" && row.Cells["STDMAX_SIGN"].Value.ToString() != "")
- {
- try
- {
- if (double.Parse(row.Cells["STDMIN"].Value.ToString()) > double.Parse(row.Cells["STDMAX"].Value.ToString()))
- {
- MessageBox.Show("成分的最小值不能比最大值大!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- }
- catch
- {
- MessageBox.Show("输入类型错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- }
- if (row.GetValue("VALIDFLAG") == "")
- {
- DataTable dtbs = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecificationsGradeChem.SelectCode",
- new Object[] { gradeCode, row.Cells["CHEM_CODE"].Value.ToString() }, this.ob);
- if (Convert.ToInt32(dtbs.Rows[0][0]) > 0)
- {
- MessageBox.Show("此条记录已存在,请核实!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- }
- else
- {
- if (row.GetValue("CHEM_CODE") != row.GetValue("CHEM_CODE_OLD"))
- {
- DataTable dtbs = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecificationsGradeChem.SelectCode",
- new Object[] { gradeCode, row.Cells["CHEM_CODE"].Value.ToString() }, this.ob);
- if (Convert.ToInt32(dtbs.Rows[0][0]) > 0)
- {
- MessageBox.Show("此条记录已存在,请核实!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return false;
- }
- }
- }
- return true;
- }
- private void save()
- {
- ultraGrid2.UpdateData();
- ArrayList listGrds = new ArrayList();
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- ArrayList parm = new ArrayList();
- if (Convert.ToBoolean(ultraGrid2.Rows[i].Cells["cb"].Value))
- {
- if (CheckGrd(ultraGrid2.Rows[i]) == false) return;
- parm.Add(ultraGrid2.Rows[i].Cells["GRADENAME"].Value.ToString());
- parm.Add(ultraGrid2.Rows[i].Cells["ASSORTMENT_CODE"].Value.ToString());
- parm.Add(ultraGrid2.Rows[i].Cells["ASSORTMENT_NAME"].Text.ToString());
- parm.Add(ultraGrid2.Rows[i].Cells["COEFFICIENT"].Value.ToString());
- parm.Add(this.UserInfo.GetUserName());
- parm.Add(ultraGrid2.Rows[i].Cells["MEMO"].Value.ToString());
- parm.Add(ultraGrid2.Rows[i].GetValue("ALLOW_BUY") == "True" ? "1" : "0");
- parm.Add(ultraGrid2.Rows[i].Cells["GRADECODE"].Value.ToString());
- parm.Add(ultraGrid2.Rows[i].Cells["VALIDFLAG"].Value.ToString());
- //主表修改
- number++;
- }
- if (ultraGrid2.Rows[i].ChildBands[0].Rows.Count > 0)
- {
- ArrayList listGrdChms = new ArrayList();
- for (int j = 0; j < ultraGrid2.Rows[i].ChildBands[0].Rows.Count; j++)
- {
- Infragistics.Win.UltraWinGrid.UltraGridRow minrow = ultraGrid2.Rows[i].ChildBands[0].Rows[j];
- if (Convert.ToBoolean(minrow.Cells["check2"].Value))
- {
- if (CheckGrdChm(minrow, ultraGrid2.Rows[i].GetValue("GRADECODE")) == false)
- {
- return;
- }
- ArrayList minParm = new ArrayList();
- minParm.Add(ultraGrid2.Rows[i].Cells["assortment_code"].Value.ToString());
- minParm.Add(ultraGrid2.Rows[i].Cells["ASSORTMENT_NAME"].Value.ToString());
- minParm.Add(ultraGrid2.Rows[i].Cells["COEFFICIENT"].Value.ToString());
- minParm.Add(minrow.Cells["STDMIN_SIGN"].Value.ToString());
- minParm.Add(minrow.Cells["STDMIN"].Value.ToString());
- minParm.Add(minrow.Cells["STDMAX_SIGN"].Value.ToString());
- minParm.Add(minrow.Cells["STDMAX"].Value.ToString());
- minParm.Add(this.UserInfo.GetUserName());
- minParm.Add(minrow.Cells["memo"].Value.ToString());
- minParm.Add(ultraGrid2.Rows[i].Cells["GRADENAME"].Value.ToString());
- minParm.Add(minrow.Cells["CHEM_NAME"].Text.ToString());
- minParm.Add(ultraGrid2.Rows[i].Cells["GRADECODE"].Value.ToString());
- minParm.Add(minrow.Cells["CHEM_CODE"].Text.ToString());
- minParm.Add(minrow.Cells["VALIDFLAG"].Text.ToString());
- //从表修改
- number++;
- listGrdChms.Add(minParm);
- }
- }
- if (listGrdChms.Count > 0)
- {
- parm.Add(listGrdChms);
- }
- }
- if (parm.Count > 0)
- {
- listGrds.Add(parm);
- }
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否保存数据?") == DialogResult.No)
- {
- return;
- }
- string gradeCode = ServerHelper.SetDataReturnObj("com.steering.pss.qcm.CoreSpecificationsGrade.save",
- new Object[] { listGrds }, this.ob).ToString();
- if (number > 0)
- {
- doQuery(false);
- MessageBox.Show("保存成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- UltraGridRow[] rows = ultraGrid2.Rows.AsQueryable().Where("GRADECODE = '" + gradeCode + "'").ToArray();
- if (rows.Length > 0)
- {
- rows[0].Activate();
- rows[0].ExpandAll();
- }
- }
- private bool isExistGradeName(string gradeName)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecificationsGrade.isExistGradeName",
- new object[] { gradeName }, ob);
- if (dt.Rows[0][0].ToString() == "0")
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// 删除或恢复
- /// </summary>
- /// <param name="isDelete">true删除 false恢复</param>
- private void doDeleteOrResume(bool flag)
- {
- ultraGrid2.UpdateData();
- int numb = 0;
- if (ultraGrid2.Rows.Count == 0)
- {
- MessageBox.Show("您当前没有勾选任何行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- if (Convert.ToBoolean(ultraGrid2.Rows[i].Cells["cb"].Value))
- {
- if (ultraGrid2.Rows[i].ChildBands[0].Rows.Count > 0 && flag)
- {
- MessageBox.Show("子表数据必须删除!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- string tishi = "";
- if (flag)
- tishi = "删除";
- else
- tishi = "恢复";
- if (numb == 0)
- {
- if (MessageBox.Show(tishi + "勾选记录,您是否继续?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- }
- numb++;
- ArrayList listBase = new ArrayList();
- if (flag == true)
- {
- listBase.Add(UserInfo.GetUserName());
- }
- listBase.Add(ultraGrid2.Rows[i].Cells["GRADECODE"].Text.Trim().ToString());
- //主表删除
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreSpecificationsGrade.deleteLineInfo", new Object[] { listBase, flag }, this.ob);
- }
- if (ultraGrid2.Rows[i].ChildBands[0].Rows.Count > 0)
- {
- for (int j = 0; j < ultraGrid2.Rows[i].ChildBands[0].Rows.Count; j++)
- {
- if (Convert.ToBoolean(ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells["check2"].Value))
- {
- string tishi = "";
- if (flag)
- tishi = "删除";
- else
- tishi = "恢复";
- if (numb == 0)
- {
- if (MessageBox.Show(tishi + "勾选记录,您是否继续?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- }
- numb++;
- ArrayList listChild = new ArrayList();
- if (flag == true)
- {
- listChild.Add(UserInfo.GetUserName());
- listChild.Add(System.DateTime.Now);
- }
- listChild.Add(ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells["GRADECODE"].Text.Trim().ToString());
- listChild.Add(ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells["CHEM_CODE"].Value.ToString());
- //从表删除
- int count1 = ServerHelper.SetData("com.steering.pss.qcm.CoreSpecificationsGradeChem.deleteLineInfo", new Object[] { listChild, flag }, this.ob);
- }
- }
- }
- }
- if (numb == 0)
- {
- MessageBox.Show("请选择需要处理的数据行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- doQuery(false);
- }
- /// <summary>
- /// 查询方法,比较通用的查询方法
- /// </summary>
- private void doQuery(bool flag)
- {
- bool validFlag = flag;
- string titleName = "";
- string gradeName = labelTextBox1.Checked ? labelTextBox1.Text.Trim() : "";
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecificationsGrade.getLineList",
- new Object[] { validFlag, titleName, gradeName }, this.ob);
- dataTable2.Clear();
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //从表的记录也要查询出来。
- DataTable mindt = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecificationsGradeChem.getLineList",
- new Object[] { validFlag, titleName, gradeName }, 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 (ultraGrid2.Rows[i].Cells[j].Column.Key == "cb") continue;
- ultraGrid2.Rows[i].Cells[j].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- }
- if (ultraGrid2.Rows[i].ChildBands != null && 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 (ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells[k].Column.Key == "check2") continue;
- ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells[k].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- }
- }
- }
- }
- UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] };
- //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
- //不同颜色区分是否有效数据
- 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 != null && 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("1"))
- {
- minrow.Appearance.ForeColor = Color.Red;
- }
- else
- {
- minrow.Appearance.ForeColor = Color.Black;
- }
- }
- }
- if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1"))
- {
- row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- row.Appearance.ForeColor = Color.Black;
- }
- }
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- this.ultraGrid2.UpdateData();
- //勾选 全选
- if (e.Cell.Column.Key.Equals("cb"))
- {
- if (e.Cell.Row.ChildBands[0] != null)
- {
- foreach (UltraGridRow row in e.Cell.Row.ChildBands[0].Rows)
- {
- row.Cells["check2"].Value = e.Cell.Value;
- }
- }
- }
- if (e.Cell.Column.Key.Equals("check2"))
- {//勾选从表(取消勾选)
- int flag = 0; //判断从表状态参数
- foreach (UltraGridRow row in e.Cell.Row.ParentRow.ChildBands[0].Rows)
- {
- if (Convert.ToBoolean(row.Cells["check2"].Value))
- {
- flag += 1; //从表勾选了 状态参数+1
- }
- }
- if (flag < e.Cell.Row.ParentRow.ChildBands[0].Rows.Count)
- {//状态参数小于从表的行数,说明未全勾选,主表未半选状态
- e.Cell.Row.ParentRow.Cells["cb"].Value = null;
- }
- else if (flag == 0) //从表取消全部勾选,主表不勾选
- {
- e.Cell.Row.ParentRow.Cells["cb"].Value = false;
- }
- else //否则主表未全选状态
- {
- e.Cell.Row.ParentRow.Cells["cb"].Value = true;
- }
- }
- if (e.Cell.Column.Key.Equals("ASSORTMENT_NAME"))
- {
- e.Cell.Row.Cells["ASSORTMENT_CODE"].Value = e.Cell.Row.Cells["ASSORTMENT_NAME"].Value;
- }
- if (e.Cell.Column.Key.Equals("CHEM_NAME"))
- {
- e.Cell.Row.Cells["CHEM_CODE"].Value = e.Cell.Row.Cells["CHEM_NAME"].Value;
- }
- 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
- {
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- }
- if (e.Cell.Column.Key.Equals("check2"))
- {
- 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("check2"))
- {
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- }
- }
- private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
- {
- for (int i = 0; i < e.Row.Cells.Count; i++)
- {
- if (i == 8) break;
- e.Row.Cells[i].Activation = Activation.NoEdit;
- }
- if (e.Row.HasParent())
- {
- e.Row.Cells["GRADECODE"].Value = e.Row.ParentRow.Cells["GRADECODE"].Value.ToString();
- }
- else
- {
- e.Row.Cells["GRADECODE"].Value = ++_index;
- }
- }
- private void labelTextBox1_TextBox_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- this.doQuery(false);
- }
- }
- }
- }
|