| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- 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.Data;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- /// <summary>
- /// 取样要求管理
- /// </summary>
- public partial class FrmComMSCSample : FrmBase
- {
- //提示
- private string errMessage = "";
- //冶金规范码
- private string _msc = "";
- private int isSelect = 0;
- //自增序号
- private int _xh = 1;
- //用于定位
- private int expanl = -1;
- public FrmComMSCSample()
- {
- InitializeComponent();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- this.DoQuery(true);
- break;
- case "Save":
- this.DoSave();
- break;
- case "Delete":
- DoUpdateOrResume(true);
- break;
- case "Resume":
- DoUpdateOrResume(false);
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 传入冶金规范码(外部调用)
- /// </summary>
- /// <param name="msc">冶金规范码</param>
- public void SetMSC(string msc)
- {
- _msc = msc;
- DoQuery(true);
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery(Boolean flag)
- {
- string msc = _msc;
- string valid = "1";
- if (!flag)
- valid = "0";
- ArrayList list = new ArrayList();
- list.Add(_msc);
- list.Add(valid);
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMSCSample.getComMSCSample", new Object[] { list }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //不同颜色区分是否有效数据
- QcmBaseCommon.DistinguishColor(ultraGrid1, "VALIDFLAGNAME", "有效");
- _xh = 1;
- QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
- isSelect = 0;
- if (expanl < ultraGrid1.Rows.Count && expanl >= 0)
- ultraGrid1.Rows[expanl].Activate();
- expanl = -1;
- }
- /// <summary>
- /// 操作数据项
- /// </summary>
- /// <returns></returns>
- private ArrayList GetOptionData(int i)
- {
- ArrayList list = new ArrayList();
- UltraGridRow rows = ultraGrid1.Rows[i];
- string msc = _msc;
- string xh = rows.Cells["XH"].Text.ToString().Trim();
- string minD = rows.Cells["MIN_D"].Value.ToString().Trim();
- if (!minD.Equals("") && !StringUtil.IsNumber(minD))
- {
- errMessage = "最小外径请输入数字";
- return null;
- }
- string maxD = rows.Cells["MAX_D"].Value.ToString().Trim();
- if (!maxD.Equals("") && !StringUtil.IsNumber(maxD))
- {
- errMessage = "最大外径请输入数字";
- return null;
- }
- if (!minD.Equals("") && !maxD.Equals("") && Convert.ToDouble(minD) > Convert.ToDouble(maxD))
- {
- errMessage = "最小外径不能大于最大外径";
- return null;
- }
- string minH = rows.Cells["MIN_H"].Value.ToString().Trim();
- if (!minH.Equals("") && !StringUtil.IsNumber(minH))
- {
- errMessage = "最小壁厚请输入数字";
- return null;
- }
- string maxH = rows.Cells["MAX_H"].Value.ToString().Trim();
- if (!maxH.Equals("") && !StringUtil.IsNumber(maxH))
- {
- errMessage = "最大壁厚请输入数字";
- return null;
- }
- if (!minH.Equals("") && !maxH.Equals("") && Convert.ToDouble(minH) > Convert.ToDouble(maxH))
- {
- errMessage = "最小壁厚不能大于最大壁厚";
- return null;
- }
- string length = rows.Cells["LENGTH"].Text.ToString().Trim();
- string descLength = rows.Cells["DESC_LENGTH"].Text.ToString().Trim();
- if (descLength.Equals(""))
- {
- errMessage = "请选择取样长度";
- return null;
- }
- string rate = rows.Cells["RATE"].Text.ToString().Trim();
- if (rate.Equals(""))
- {
- errMessage = "请选择取样频率";
- return null;
- }
- string descRate = rows.Cells["DESC_RATE"].Text.ToString().Trim();
- if (descRate.Equals(""))
- {
- errMessage = "请选择取样描述";
- return null;
- }
- string descCount = rows.Cells["DESC_COUNT"].Text.ToString().Trim();
- string position = rows.Cells["POSITION"].Text.ToString().Trim();
- if (position.Equals(""))
- {
- errMessage = "请选择位置描述";
- return null;
- }
- string descPosition = rows.Cells["DESC_POSITION"].Text.ToString().Trim();
- string userName = UserInfo.GetUserName();
- string userTime = System.DateTime.Now.ToString();
- string memo = rows.Cells["MEMO"].Text.ToString().Trim();
- string validflag = rows.Cells["VALIDFLAGNAME"].Value.ToString();
- if (validflag.Equals("无效"))
- {
- errMessage = "无效记录不能保存";
- return null;
- }
- list.Add(msc);
- list.Add(xh);
- list.Add(minD);
- list.Add(maxD);
- list.Add(minH);
- list.Add(maxH);
- list.Add(length);
- list.Add(descLength);
- list.Add(rate);
- list.Add(descRate);
- list.Add(descCount);
- list.Add(position);
- list.Add(descPosition);
- list.Add(userName);
- list.Add(userTime);
- list.Add(memo);
- return list;
- }
- /// <summary>
- /// 保存
- /// </summary>
- private void DoSave()
- {
- ultraGrid1.UpdateData();
- if (isSelect == 0)
- {
- MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (MessageBox.Show("是否保存选择记录", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- ArrayList addList = new ArrayList();
- ArrayList updateList = new ArrayList();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (Convert.ToBoolean(ultraGrid1.Rows[i].Cells["CHC"].Value.ToString()))
- {
- ArrayList list = GetOptionData(i);
- if (list == null)
- {
- MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (ultraGrid1.Rows[i].Cells["CREATE_NAME"].Text.Equals(""))
- {
- addList.Add(list);
- }
- else
- {
- list.Add(ultraGrid1.Rows[i].Cells["MSC"].Text.Trim());
- list.Add(Convert.ToInt32(ultraGrid1.Rows[i].Cells["XH"].Text.Trim()));
- updateList.Add(list);
- }
- if (expanl == -1)
- expanl = i;
- }
- }
- if (addList.Count > 0 || updateList.Count > 0)
- {
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreComMSCSample.saveComMSCSample", new Object[] { addList, updateList }, this.ob);
- if (count > 0)
- {
- DoQuery(true);
- MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- MessageBox.Show("保存失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- /// <summary>
- /// 删除或者恢复
- /// </summary>
- private void DoUpdateOrResume(Boolean flag)
- {
- ultraGrid1.UpdateData();
- if (isSelect == 0)
- {
- MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (flag)
- {
- if (MessageBox.Show("作废选中记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- }
- else
- {
- if (MessageBox.Show("恢复选中记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- }
- ArrayList listAll = new ArrayList();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (Convert.ToBoolean(ultraGrid1.Rows[i].Cells["CHC"].Value.ToString()))
- {
- ArrayList list = new ArrayList();
- string validflag = "0";
- string userName = UserInfo.GetUserName();
- string userTime = System.DateTime.Now.ToString();
- if (!flag)
- {
- if (ultraGrid1.Rows[i].Cells["VALIDFLAGNAME"].Value.Equals("有效"))
- {
- MessageBox.Show("记录[" + (i + 1) + "]为有效记录,不能恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- validflag = "1";
- userName = "";
- userTime = "";
- }
- else
- {
- if (ultraGrid1.Rows[i].Cells["VALIDFLAGNAME"].Value.Equals("无效"))
- {
- MessageBox.Show("记录[" + (i + 1) + "]为无效记录,不能删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- }
- string msc = _msc;
- int xh = Convert.ToInt32(ultraGrid1.Rows[i].Cells["XH"].Value.ToString());
- list.Add(validflag);
- list.Add(userName);
- list.Add(userTime);
- list.Add(msc);
- list.Add(xh);
- listAll.Add(list);
- if (expanl == -1)
- expanl = i;
- }
- }
- if (listAll.Count > 0)
- {
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreComMSCSample.deleteComMSCSample", new Object[] { listAll, flag }, this.ob);
- if (count > 0)
- {
- DoQuery(false);
- if (flag)
- MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- else
- MessageBox.Show("恢复成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- /// <summary>
- /// 初始化下拉框
- /// </summary>
- private void InitDownList()
- {
- QcmBaseCommon.InitDropUltraComEditor(ultraComboLength, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4010", "BASENAME", this.ob, false);
- QcmBaseCommon.InitDropUltraComEditor(ultraComPosition, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4011", "BASENAME", this.ob, false);
- QcmBaseCommon.InitDropUltraComEditor(ultraComboRace, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4012", "BASENAME", this.ob, false);
- }
- /// <summary>
- /// 登陆页面事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FrmComMSCSample_Load(object sender, EventArgs e)
- {
- SetMSC("MSC00001");
- InitDownList();
- }
- /// <summary>
- /// 行增加事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- int xh = 1;
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMSCSample.getMaxXH", new Object[] { _msc }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- int xh1 = Convert.ToInt32(dt.Rows[0][0].ToString());
- if (xh1 > _xh)
- {
- xh = xh1 + 1;
- _xh = xh1 + 1;
- }
- else
- {
- xh = _xh + 1;
- _xh += 1;
- }
- }
- else
- {
- xh = _xh;
- _xh += 1;
- }
- UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
- ugr.Cells["XH"].Value = xh;
- if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- if (!ugr.Cells[i].Column.Key.Equals("CHC"))
- ugr.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// 值变化事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
- if (e.Cell.Column.Key.Equals("DESC_LENGTH")) /// 长度描述
- {
- ugr.Cells["LENGTH"].Value = ugr.Cells["DESC_LENGTH"].Value.ToString();
- }
- if (e.Cell.Column.Key.Equals("DESC_POSITION")) /// 位置描述
- {
- ugr.Cells["POSITION"].Value = ugr.Cells["DESC_POSITION"].Value.ToString();
- }
- if (e.Cell.Column.Key.Equals("DESC_RATE")) /// 频率描述
- {
- ugr.Cells["RATE"].Value = ugr.Cells["DESC_RATE"].Value.ToString();
- }
- if (e.Cell.Column.Key.Equals("CHC"))
- {
- Activation activation = Activation.ActivateOnly;
- if (Convert.ToBoolean(e.Cell.Value))
- {
- activation = Activation.AllowEdit;
- isSelect += 1;
- }
- else
- isSelect -= 1;
- CellsCollection cells = e.Cell.Row.Cells;
- for (int i = 0; i < cells.Count; i++)
- {
- if (!cells[i].Column.Key.Equals("CHC"))
- {
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- }
- }
- }
- }
|