| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 |
- 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 FrmWaterRatioStd : FrmBase
- {
- public FrmWaterRatioStd()
- {
- InitializeComponent();
- ExceptionHelper.RegistException();
- }
- private OpeBase _ob;
- public OpeBase Ob
- {
- get { return _ob; }
- set { _ob = value; }
- }
- //UltraComboEditor stdUce = new UltraComboEditor();
- //UltraComboEditor stdUcec = new UltraComboEditor();
- UltraCombo stdCombo = new UltraCombo();
- UltraCombo stdComboRep = new UltraCombo();
- string stdName = "";
- private void FrmWaterRatioStd_Load(object sender, EventArgs e)
- {
- Init();
- DoQuery(false);
- }
- private void InitDrop(UltraCombo uce, string methodID, string showName, string value, Boolean isNull, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData(methodID, new Object[] { }, ob);
- if (dt != null && dt.Rows.Count > 0 && isNull)
- {
- DataRow dr = dt.NewRow();
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- dr[i] = "";
- }
- dt.Rows.InsertAt(dr, 0);
- }
- uce.DataSource = dt;
- uce.DisplayMember = showName;
- uce.ValueMember = value;
- }
- private void Init()
- {
- //this.Controls.Add(stdCombo);
- //this.Controls.Add(stdComboRep);
- //stdCombo.Visible = false;
- //stdComboRep.Visible = false;
- //InitDrop(stdCombo, "com.steering.pss.qcm.WaterRatioRStd.getStd", "STD_NAME", "ID_CODE", true, this._ob);
- //InitDrop(stdComboRep, "com.steering.pss.qcm.WaterRatioRStd.getStdReplace", "STD_NAME", "IDCODE", true, this._ob);
- //ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME_C"].EditorComponent = stdCombo;
- //ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME_C"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- //ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].EditorComponent = stdComboRep;
- //ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- //stdCombo.DisplayLayout.Bands[0].Columns["ID_CODE"].Hidden = true;
- //stdCombo.DisplayLayout.Bands[0].Columns["STD_NAME"].Header.Caption = "标准名称";
- //stdCombo.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Header.Caption = "标准类别";
- //stdComboRep.DisplayLayout.Bands[0].Columns["IDCODE"].Hidden = true;
- //stdComboRep.DisplayLayout.Bands[0].Columns["STD_NAME"].Header.Caption = "标准名称";
- //stdComboRep.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Header.Caption = "标准类别";
- //stdCombo.DisplayLayout.Bands[0].Columns["STD_NAME"].Width = 240;
- //stdComboRep.DisplayLayout.Bands[0].Columns["STD_NAME"].Width = 240;
- //ultraGrid1.UpdateData();
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- if (e.Tool.Key == "ButtonTool1") //保存
- {
- DoSave();
- }
- if (e.Tool.Key == "ButtonTool2") //删除
- {
- DeleteOrResume(true);
- }
- if (e.Tool.Key == "ButtonTool3") //恢复
- {
- DeleteOrResume(false);
- }
- if (e.Tool.Key == "ButtonTool5") //刷新
- {
- DoRefresh();
- }
- if (e.Tool.Key == "ButtonTool6") //查询
- {
- DoQuery(false);
- }
- if (e.Tool.Key == "ButtonTool7") //查询
- {
- DoQuery(true);
- }
- if (e.Tool.Key == "ButtonTool4") //关闭
- {
- if (MessageBox.Show("是否关闭本窗口?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- this.Close();
- }
- }
- private void DoSave()
- {
- if (GetData() == -1)
- {
- return;
- }
- if (param.Count <= 0 && paramUpdate.Count <= 0)
- {
- MessageUtil.ShowWarning("请选择要保存的记录!");
- return;
- }
- List<string> list = stdList.Distinct().ToList();
- if (list.Count < stdList.Count)
- {
- MessageUtil.ShowWarning("有重复的标准名称,请重新选择!");
- return;
- }
- if (MessageBox.Show("是否保存所选记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- // int count = ServerHelper.SetData("com.steering.pss.qcm.WaterRatioRStd.save", new object[] { param, paramUpdate }, this._ob);
- //一个标准只能引用一个水压标准,一个水压标准可被多个标准引用
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.qcm.WaterRatioRStd";
- ccp.MethodName = "save";
- ccp.ServerParams = new object[] { param, paramUpdate };
- ccp = this._ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp != null && ccp.ReturnInfo == "FALSE###") //服务端传来的错误信息
- {
- MessageUtil.ShowWarning("您所选标准已存在引用标准\n或者为水压系数维护的基础标准,无法保存!");
- return;
- }
- if (ccp.ReturnCode == -1)
- return;
- MessageUtil.ShowTips("保存成功!");
- DoQuery(false);
- }
- ArrayList param = new ArrayList();
- ArrayList paramUpdate = new ArrayList();
- List<string> stdList = new List<string>();
- private int GetData()
- {
- ultraGrid1.UpdateData();
- param = new ArrayList();
- paramUpdate = new ArrayList();
- stdList.Clear();
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- if (row.Cells["STD_NAME_C"].Text.Trim() == "")
- {
- MessageUtil.ShowWarning("请选择标准名称!");
- return -1;
- }
- if (row.Cells["STD_NAME"].Text.Trim() == "")
- {
- MessageUtil.ShowWarning("请选择引用标准名称!");
- return -1;
- }
- if (row.Cells["STD_CODE_C"].Value.ToString() == row.Cells["STD_CODE"].Value.ToString())
- {
- MessageUtil.ShowWarning("标准不能引用自身!");
- return -1;
- }
- if (row.Cells["VALIDFLAG"].Value.ToString() == "")
- {
- ArrayList list = new ArrayList();
- list.Add(row.Cells["ID_"].Value.ToString());
- list.Add(row.Cells["STD_CODE_C"].Value.ToString());
- list.Add(row.Cells["STD_NAME_C"].Text.Trim());
- list.Add(row.Cells["STD_STYLE_C"].Value.ToString());
- list.Add(row.Cells["STD_STYLE_DESC_C"].Value.ToString());
- list.Add(row.Cells["STD_CODE"].Value.ToString());
- list.Add(row.Cells["STD_NAME"].Text.Trim());
- list.Add(row.Cells["STD_STYLE"].Value.ToString());
- list.Add(row.Cells["STD_STYLE_DESC"].Value.ToString());
- list.Add(this.UserInfo.GetUserName());
- list.Add(row.Cells["MEMO"].Value.ToString());
- param.Add(list);
- stdName = row.Cells["STD_NAME_C"].Value.ToString();
- }
- else
- {
- ArrayList list = new ArrayList();
- list.Add(row.Cells["ID_"].Value.ToString());
- list.Add(row.Cells["STD_CODE_C"].Value.ToString());
- list.Add(row.Cells["STD_NAME_C"].Text.Trim());
- list.Add(row.Cells["STD_STYLE_C"].Value.ToString());
- list.Add(row.Cells["STD_STYLE_DESC_C"].Value.ToString());
- list.Add(row.Cells["STD_CODE"].Value.ToString());
- list.Add(row.Cells["STD_NAME"].Text.Trim());
- list.Add(row.Cells["STD_STYLE"].Value.ToString());
- list.Add(row.Cells["STD_STYLE_DESC"].Value.ToString());
- list.Add(this.UserInfo.GetUserName());
- list.Add(row.Cells["MEMO"].Value.ToString());
- list.Add(row.Cells["STD_CODE_OLD"].Value.ToString());
- paramUpdate.Add(list);
- stdName = row.Cells["STD_NAME_C"].Value.ToString();
- }
- stdList.Add(row.Cells["STD_NAME_C"].Text.Trim());
- }
- }
- return 0;
- }
- private void DoQuery(bool flag)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.WaterRatioRStd.query", new object[] { flag }, this._ob);
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["STD_NAME_C"].Value.ToString() == stdName)
- {
- row.Activate();
- break;
- }
- }
- stdName = "";
- }
- private void DoRefresh()
- {
- Init();
- }
- private void DeleteOrResume(bool flag)
- {
- ultraGrid1.UpdateData();
- UltraGridRow[] dr = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHK" }, new string[] { "True" });
- if (dr.Length <= 0)
- {
- MessageUtil.ShowWarning("请选择你要操作的记录!");
- return;
- }
- ArrayList deleteParm = new ArrayList();
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- if (flag) //删除
- {
- if (row.Cells["VALIDFLAG"].Value.ToString() == "")
- {
- MessageUtil.ShowTips("数据尚未写进数据库!");
- return;
- }
- deleteParm.Add(row.Cells["ID_"].Value.ToString());
- }
- }
- }
- if (MessageBox.Show("是否确认" + (flag ? "删除" : "恢复") + "所选数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- int count = ServerHelper.SetData("com.steering.pss.qcm.WaterRatioRStd.delete",
- new object[] { deleteParm }, this._ob);
- if (count > 0)
- {
- MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!");
- DoQuery(false);
- }
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
- if (ugr == null)
- return;
- //if (e.Cell.Column.Key.Equals("STD_NAME_C"))
- //{
- // if (e.Cell.Text != "")
- // {
- // DataRow[] dr = ((DataTable)stdCombo.DataSource).Select("ID_CODE ='" + e.Cell.Value.ToString() + "'");
- // if (dr.Length > 0)
- // {
- // ugr.Cells["STD_NAME_C"].Value= e.Cell.Value;
- // //ugr.Cells["STD_STYLE_C"].Value = dr[0][2];
- // string[] str = null;
- // if (dr[0][0].ToString().Contains("#####"))
- // {
- // str = dr[0][0].ToString().Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
- // // _stdCodeC = str[0];
- // ugr.Cells["STD_CODE_C"].Value = str[0];
- // if (str.Length == 2)
- // {
- // ugr.Cells["STD_STYLE_C"].Value = str[1];
- // }
- // }
- // ugr.Cells["STD_STYLE_DESC_C"].Value = dr[0][2];
- // }
- // // ugr.Cells["ID_"].Value = ugr.Cells["STD_CODE_C"].Value.ToString() + ugr.Cells["STD_STYLE_C"].Value.ToString();
- // }
- // else
- // {
- // ugr.Cells["STD_NAME_C"].Value = "";
- // ugr.Cells["STD_STYLE_C"].Value = "";
- // ugr.Cells["STD_STYLE_DESC_C"].Value = "";
- // }
- //}
- //else if (e.Cell.Column.Key.Equals("STD_NAME"))
- //{
- // if (e.Cell.Text != "")
- // {
- // DataRow[] dr = ((DataTable)stdComboRep.DataSource).Select("IDCODE ='" + e.Cell.Value.ToString() + "'" );
- // if (dr.Length > 0)
- // {
- // ugr.Cells["STD_NAME"].Value = e.Cell.Value;
- // //ugr.Cells["STD_STYLE"].Value = dr[0][2];
- // string[] str = null;
- // if (dr[0][0].ToString().Contains("#####"))
- // {
- // str=dr[0][0].ToString().Split(new char[]{'#'},StringSplitOptions.RemoveEmptyEntries);
- // //_stdCode = str[0];
- // ugr.Cells["STD_CODE"].Value = str[0];
- // if(str.Length==2)
- // {
- // ugr.Cells["STD_STYLE"].Value = str[1];
- // }
- // }
- // ugr.Cells["STD_STYLE_DESC"].Value = dr[0][2];
- // }
- // // ugr.Cells["ID_"].Value = ugr.Cells["STD_CODE_C"].Value.ToString() + ugr.Cells["STD_STYLE_C"].Value.ToString();
- // }
- // else
- // {
- // ugr.Cells["STD_NAME"].Value = "";
- // ugr.Cells["STD_STYLE"].Value = "";
- // ugr.Cells["STD_STYLE_DESC"].Value = "";
- // }
- //}
- else if (e.Cell.Column.Key.Equals("CHK"))
- {
- if (e.Cell.Value.ToString().ToUpper() != "TRUE")
- {
- ugr.Cells["STD_NAME_C"].Activation = Activation.ActivateOnly;
- ugr.Cells["STD_NAME"].Activation = Activation.ActivateOnly;
- ugr.Cells["MEMO"].Activation = Activation.ActivateOnly;
- }
- else
- {
- ugr.Cells["STD_NAME_C"].Activation = Activation.AllowEdit;
- ugr.Cells["STD_NAME"].Activation = Activation.AllowEdit;
- ugr.Cells["MEMO"].Activation = Activation.AllowEdit;
- }
- }
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效")
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- }
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- if (ugr.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- ugr.Cells["STD_NAME_C"].Activation = Activation.AllowEdit;
- ugr.Cells["STD_NAME"].Activation = Activation.AllowEdit;
- ugr.Cells["MEMO"].Activation = Activation.AllowEdit;
- }
- else
- {
- ugr.Cells["STD_NAME_C"].Activation = Activation.ActivateOnly;
- ugr.Cells["STD_NAME"].Activation = Activation.ActivateOnly;
- ugr.Cells["MEMO"].Activation = Activation.ActivateOnly;
- }
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- if (ugr.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- ugr.Cells["STD_NAME_C"].Activation = Activation.AllowEdit;
- ugr.Cells["STD_NAME"].Activation = Activation.AllowEdit;
- ugr.Cells["MEMO"].Activation = Activation.AllowEdit;
- }
- else
- {
- ugr.Cells["STD_NAME_C"].Activation = Activation.ActivateOnly;
- ugr.Cells["STD_NAME"].Activation = Activation.ActivateOnly;
- ugr.Cells["MEMO"].Activation = Activation.ActivateOnly;
- }
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- BaseInfoPopup popup;
- string key = ultraGrid1.ActiveCell.Column.Key;
- if (key == "STD_NAME_C")
- {
- this.Cursor = Cursors.WaitCursor;
- string stdCode = ultraGrid1.ActiveRow.GetValue("STD_CODE_C");
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.WaterRatioRStd.getStd",
- new object[] { }, _ob);
- dt.Columns["STD_NAME"].Caption = "标准名称";
- dt.Columns["STD_STYLE_DESC"].Caption = "标准类别";
- popup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE", "STD_STYLE");
- popup.Load += ((a, b) =>
- {
- var row = popup.UltraGrid1.Rows.Where(c => c.GetValue("STD_CODE") == stdCode).FirstOrDefault();
- if (row != null)
- {
- row.Activate();
- }
- this.Cursor = Cursors.Default;
- });
- if (popup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- ultraGrid1.SetActiveRowValue("STD_NAME_C", popup.ChoicedRow.GetValue("STD_NAME"));
- ultraGrid1.SetActiveRowValue("STD_CODE_C", popup.ChoicedRow.GetValue("STD_CODE"));
- ultraGrid1.SetActiveRowValue("STD_STYLE_DESC_C", popup.ChoicedRow.GetValue("STD_STYLE_DESC"));
- ultraGrid1.SetActiveRowValue("STD_STYLE_C", popup.ChoicedRow.GetValue("STD_STYLE"));
- ultraGrid1.ActiveRow.Update();
- }
- }
- else if (key == "STD_NAME")
- {
- this.Cursor = Cursors.WaitCursor;
- string stdCode = ultraGrid1.ActiveRow.GetValue("STD_CODE");
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.WaterRatioRStd.getStdReplace",
- new object[] { }, _ob);
- dt.Columns["STD_NAME"].Caption = "引用标准名称";
- dt.Columns["STD_STYLE_DESC"].Caption = "标准类别";
- popup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE", "STD_STYLE");
- popup.Load += ((a, b) =>
- {
- var row = popup.UltraGrid1.Rows.Where(c => c.GetValue("STD_CODE") == stdCode).FirstOrDefault();
- if (row != null)
- {
- row.Activate();
- }
- this.Cursor = Cursors.Default;
- });
- if (popup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- ultraGrid1.SetActiveRowValue("STD_NAME", popup.ChoicedRow.GetValue("STD_NAME"));
- ultraGrid1.SetActiveRowValue("STD_CODE", popup.ChoicedRow.GetValue("STD_CODE"));
- ultraGrid1.SetActiveRowValue("STD_STYLE_DESC", popup.ChoicedRow.GetValue("STD_STYLE_DESC"));
- ultraGrid1.SetActiveRowValue("STD_STYLE", popup.ChoicedRow.GetValue("STD_STYLE"));
- ultraGrid1.ActiveRow.Update();
- }
- }
- }
- }
- }
|