| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- 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.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class FrmProductWater : FrmBase
- {
- //接箍码基础表数据
- private DataTable dtSCJG = null;
- List<int> list = new List<int>();
- int num = 0;
- public FrmProductWater()
- {
- InitializeComponent();
- //cmb1.SelectedIndex = 0;
- }
- private void FrmProductWater_Load(object sender, EventArgs e)
- {
- //结箍码
- InitDropList(ref dtSCJG, ultraSCJG, "com.steering.pss.qcm.ComBaseQuery.getComMSCJG", "SPEC_JG_DESC");
- DataTable dt1 = new DataTable();
- dt1.Columns.Add("xiaid");
- DataRow dr4 = dt1.NewRow();
- dr4["xiaid"] = "";
- dt1.Rows.Add(dr4);
- 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);
- leixing.DataSource = dt1;
- leixing.ValueMember = "xiaid";
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "doQuery":
- doQuery(false);
- break;
- case "QueryKey":
- doQuery(true);
- break;
- case "doSave":
- doSave();
- break;
- case "doDelete":
- this.doDeleteOrResume(true);
- break;
- case "doResume":
- this.doDeleteOrResume(false);
- break;
- case "doClose":
- this.Close();
- break;
- }
- }
- private void doSave()
- {
- int number = this.ultraGrid1.Rows.Count;
- num = 0;
- try
- {
- for (int i = 0; i < number; i++)
- {
- if (Convert.ToBoolean(ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value))
- {
- //判定勾选项是新增行,还是修改行。
- if (ultraGrid1.Rows[i].Cells["XH"].Value.ToString() == "")
- {
- doAdd();
- }
- else
- {
- doUpdate();
- }
- }
- }
- if (num == 0)
- {
- MessageBox.Show("请选择需要处理的数据行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (num > 0)
- {
- doQuery(false);
- MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch
- {
- MessageBox.Show("保存失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- private void doAdd()
- {
- //获取新增加的行。
- ultraGrid1.UpdateData();
- ArrayList parms = new ArrayList();
- //判断是否勾选。
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (Convert.ToBoolean(ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value) && num > -1 && ultraGrid1.Rows[i].Cells["XH"].Value.ToString() == "" && ultraGrid1.Rows[i].Cells["UnboundColumn2"].Value.ToString() == "tagtrue")
- {
- try
- {
- if (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString() == "")
- {
- MessageBox.Show("标准类型不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- if (ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString() == "")
- {
- MessageBox.Show("请输入保压时间!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- try
- {
- Double.Parse(ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString());
- }
- catch
- {
- MessageBox.Show("保压时间需填写数值类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() != "" && ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["SPEC_JG_DESC"].Value.ToString() != "")
- {
- MessageBox.Show("外径和接箍码不能同时存在", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- if (double.Parse(ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString()) > double.Parse(ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString()))
- {
- MessageBox.Show("外径的最小值不能大于最大值", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() == "")
- {
- MessageBox.Show("外径的最大值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() == "")
- {
- MessageBox.Show("外径的最小值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() != "" && ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() != "")
- {
- if (double.Parse(ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString()) > double.Parse(ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString()))
- {
- MessageBox.Show("壁厚的最小值不能大于最大值", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() == "")
- {
- MessageBox.Show("壁厚的最大值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() == "")
- {
- MessageBox.Show("壁厚的最小值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- //构建ArrayList,添加到parms当中。
- ArrayList parm = new ArrayList();
- parm.Add(Guid.NewGuid().ToString().Substring(0, 20));
- switch (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString())
- {
- case "国标/国际/协议":
- parm.Add("G");
- break;
- case "客户":
- parm.Add("K");
- break;
- case "内控":
- parm.Add("N");
- break;
- }
- parm.Add(ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["SPEC_JG"].Text.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["SPEC_JG_DESC"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MODEL_CODE"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MODEL_DESC"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["PRESSURE_Y"].Value.ToString());
- //创建人应为当前操作用户。
- parm.Add(this.UserInfo.GetUserName());
- //创建时间为当前时间。
- parm.Add(DateTime.Now.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MEMO"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["PRESSURE"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString());
- ultraGrid1.Rows[i].Cells["UnboundColumn2"].Value = "";
- ServerHelper.SetData("com.steering.pss.qcm.CoreProducWater.doAdd", new Object[] { parm }, this.ob);
- num++;
- list.Add(i);
- }
- catch
- {
- MessageBox.Show("输入类型有误");
- return;
- }
- }
- }
- }
- private void doDeleteOrResume(Boolean flag)
- {
- ultraGrid1.UpdateData();
- string tishi = "";
- int numb = 0;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (Convert.ToBoolean(ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value))
- {
- if (flag)
- tishi = "删除";
- else
- tishi = "恢复";
- if (numb == 0)
- {
- if (MessageBox.Show(tishi + "勾选记录,您是否继续?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- }
- numb++;
- ArrayList parm = new ArrayList();
- if (flag == true)
- {
- parm.Add(UserInfo.GetUserName());
- }
- parm.Add(ultraGrid1.Rows[i].Cells["MSC"].Value.ToString());
- switch (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString())
- {
- case "国标/国际/协议":
- parm.Add("G");
- break;
- case "客户":
- parm.Add("K");
- break;
- case "内控":
- parm.Add("N");
- break;
- }
- parm.Add(ultraGrid1.Rows[i].Cells["XH"].Value.ToString());
- //主表删除
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreProducWater.deleteLineInfo", new Object[] { parm, flag }, this.ob);
- }
- }
- if (numb == 0)
- {
- MessageBox.Show("请选择需要处理的数据行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- doQuery(false);
- }
- private void doUpdate()
- {
- //需要实现批量修改功能。
- ultraGrid1.UpdateData();
- ArrayList parms = new ArrayList();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- //复选框是否已经选中
- if ((Boolean)ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value && num > -1 && ultraGrid1.Rows[i].Cells["XH"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString() == "")
- {
- MessageBox.Show("标准类型不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- if (ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString() == "")
- {
- MessageBox.Show("请输入保压时间!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- try
- {
- Double.Parse(ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString());
- }
- catch
- {
- MessageBox.Show("保压时间需填写数值类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() != "" && ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["SPEC_JG_DESC"].Value.ToString() != "")
- {
- MessageBox.Show("外径和接箍码不能同时存在", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- if (double.Parse(ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString()) > double.Parse(ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString()))
- {
- MessageBox.Show("外径的最小值不能大于最大值", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() == "")
- {
- MessageBox.Show("外径的最大值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() == "")
- {
- MessageBox.Show("外径的最小值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() != "" && ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() != "")
- {
- if (double.Parse(ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString()) > double.Parse(ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString()))
- {
- MessageBox.Show("壁厚的最小值不能大于最大值", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() == "")
- {
- MessageBox.Show("壁厚的最大值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- if (ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() != "")
- {
- if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() == "")
- {
- MessageBox.Show("壁厚的最小值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- num = -10; return;
- }
- }
- ArrayList parm = new ArrayList();
- parm.Add(ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["SPEC_JG"].Text.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["SPEC_JG_DESC"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MODEL_CODE"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MODEL_DESC"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["PRESSURE_Y"].Value.ToString());
- //创建人应为当前操作用户。
- parm.Add(this.UserInfo.GetUserName());
- //创建时间为当前时间。
- parm.Add(DateTime.Now.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MEMO"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["PRESSURE"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString());
- parm.Add(ultraGrid1.Rows[i].Cells["MSC"].Value.ToString());
- switch (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString())
- {
- case "国标/国际/协议":
- parm.Add("G");
- break;
- case "客户":
- parm.Add("K");
- break;
- case "内控":
- parm.Add("N");
- break;
- }
- parm.Add(ultraGrid1.Rows[i].Cells["XH"].Value.ToString());
- //主表修改
- ultraGrid1.Rows[i].Cells["UnboundColumn2"].Value = "";
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreProducWater.doUpdate", new Object[] { parm }, this.ob);
- num++;
- list.Add(i);
- }
- }
- }
- /// <summary>
- /// 查询方法,比较通用的查询方法
- /// </summary>
- private void doQuery(bool flag)
- {
- bool validFlag = flag;
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProducWater.doQuery", new Object[] { validFlag }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- for (int j = 0; j < ultraGrid1.Rows[i].Cells.Count; j++)
- {
- if (j == 19) break;
- ultraGrid1.Rows[i].Cells[j].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- }
- }
- UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"] };
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
- //不同颜色区分是否有效数据
- 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("0"))
- {
- row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- row.Appearance.ForeColor = Color.Black;
- }
- }
- foreach (int i in list)
- {
- ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value = true;
- }
- list.Clear();
- }
- /// <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)
- {
- DataTable dts = ServerHelper.GetData(methodId, null, this.ob);
- int num = dts.Rows.Count;
- DataTable dt2 = new DataTable();
- dt2.Columns.Add("fenlei");
- dt2.Columns.Add("fenname");
- DataRow dr;
- for (int i = 0; i < num; i++)
- {
- dr = dt2.NewRow();
- dr["fenlei"] = dts.Rows[i]["SPEC_JG_DESC"];
- dr["fenname"] = dts.Rows[i]["SPEC_JG"];
- dt2.Rows.Add(dr);
- }
- uce.DataSource = dt2;
- uce.ValueMember = "fenname";
- uce.DisplayMember = "fenlei";
- }
- /// <summary>
- /// 扣型选择后赋值给ultragrid1
- /// </summary>
- /// <param name="code">扣型代码</param>
- /// <param name="desc">扣型描述</param>
- public void SetModelText(string code, string desc)
- {
- this.ultraGrid1.DisplayLayout.ActiveRow.Cells["MODEL_CODE"].Value = code;
- this.ultraGrid1.DisplayLayout.ActiveRow.Cells["MODEL_DESC"].Value = desc;
- }
- private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
- {
- if (e.Cell.Column.Key.Equals("MODEL_DESC") && Convert.ToBoolean(ultraGrid1.DisplayLayout.ActiveRow.Cells["UCCHOOSE"].Value))
- {
- UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow;
- FrmModel frms = new FrmModel();
- frms.Desc = row.Cells["MODEL_DESC"].Value.ToString();
- frms.FrmOb = this.ob;
- frms.ShowDialog();
- row.Cells["MODEL_CODE"].Value = frms.Code;
- row.Cells["MODEL_DESC"].Value = frms.Desc;
- }
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- if (e.Cell.Column.Key.Equals("UCCHOOSE"))
- {
- this.ultraGrid1.UpdateData();
- Activation activation = Activation.ActivateOnly;
- if (Convert.ToBoolean(e.Cell.Value))
- {
- activation = Activation.AllowEdit;
- e.Cell.Row.Cells["UnboundColumn2"].Value = "tagtrue";
- }
- CellsCollection cells = e.Cell.Row.Cells;
- for (int i = 0; i < cells.Count; i++)
- {
- if (!cells[i].Column.Key.Equals("UCCHOOSE")) //i!=9
- {
- if (i == 22) break;
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- }
- }
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- for (int i = 0; i < e.Row.Cells.Count; i++)
- {
- if (i == 22) break;
- e.Row.Cells[i].Activation = Activation.NoEdit;
- }
- }
- }
- }
|