| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127 |
- 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 FrmWaterRatio : FrmBase
- {
- private string _stdCode = "";
- //private UltraComboEditor _uce;
- private DataTable copyTable = null;
- public DataTable CopyTable
- {
- get { return copyTable; }
- set { copyTable = value; }
- }
- private bool isPasting = false;
- public string StdCode
- {
- get { return _stdCode; }
- set { _stdCode = value; }
- }
- private string _steelCode = "";
- public string SteelCode
- {
- get { return _steelCode; }
- set { _steelCode = value; }
- }
- private string stdStyleCode = "1";
- public string StdStyleCode
- {
- get { return stdStyleCode; }
- set { stdStyleCode = value; }
- }
- private string stdCodeNk = "";
- public string StdCodeNk
- {
- get { return stdCodeNk; }
- set { stdCodeNk = value; }
- }
- public FrmWaterRatio()
- {
- InitializeComponent();
- ExceptionHelper.RegistException();
- }
- public void PopupLoad(string customInfo, OpeBase ob)
- {
- panel1.Visible = false;
- this.CustomInfo = customInfo;
- this.ob = ob;
- this.OnLoad(EventArgs.Empty);
- }
- ArrayList listA = new ArrayList(); //新增数据
- ArrayList listU = new ArrayList(); //修改数据
- ArrayList listS = new ArrayList(); //Grid2数据
- ArrayList listM = new ArrayList(); //Grid3数据
- int waterid = 0;
- private string _id = "";
- string copyStdCode = ""; //复制时的标准代码
- string pastStdCode = ""; //粘贴了的标准代码
- List<string> onlyList = new List<string>();
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- try
- {
- this.Cursor = Cursors.WaitCursor;
- doQuery(false);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- break;
- case "QueryV":
- try
- {
- this.Cursor = Cursors.WaitCursor;
- doQuery(true);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- break;
- case "Save":
- doSave();
- break;
- case "Delete":
- doDeleteOrResume(true);
- break;
- case "Resume":
- doDeleteOrResume(false);
- break;
- case "Refresh":
- doRefresh();
- break;
- case "CopyStd":
- CopyStd();
- break;
- case "Copy":
- Copy();
- break;
- case "Paste":
- isPasting = true;
- try
- {
- Paste();
- isPasting = false;
- }
- finally
- {
- isPasting = false;
- }
- break;
- case "WaterStd":
- ShowWindow();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- private void FrmWaterRatio_Load(object sender, EventArgs e)
- {
- InitCombox();
- doQuery(false);
- }
- private void CopyStd()
- {
- this.Cursor = Cursors.WaitCursor;
- var chkRow = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").FirstOrDefault();
- if (chkRow == null)
- {
- MessageUtil.ShowWarning("请选择一条记录!");
- this.Cursor = Cursors.Default;
- return;
- }
- string stdCode = chkRow.GetValue("STD_CODE");
- string stdName = chkRow.GetValue("STD_NAME");
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.GetStd",
- new object[] { _stdCode }, this.ob);
- dt.Columns["STD_NAME"].Caption = "新标准名称";
- BaseInfoPopup popup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE");
- popup.Text = "被复制标准" + stdName;
- 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)
- {
- ServerHelper.SetData("com.steering.pss.qcm.CoreWaterRatio.copyRatioByStd",
- new object[] { stdCode, popup.ChoicedRow.GetValue("STD_CODE"), popup.ChoicedRow.GetValue("STD_NAME") }, ob);
- MessageUtil.ShowTips("复制标准成功!");
- }
- }
- /// <summary>
- /// 复制一行数据
- /// </summary>
- private void Copy()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowWarning("请选择一行记录,再进行操作!");
- return;
- }
- ultraGrid1.UpdateData();
- copyTable = dataTable1.Copy();
- copyTable.Clear();
- DataRow dr = copyTable.NewRow();
- CopyRowToRow(((DataRowView)ultraGrid1.ActiveRow.ListObject).Row, dr);
- copyTable.Rows.Add(dr);
- waterid = Convert.ToInt32(ultraGrid1.GetActiveRowValue("RATIO_ID"));
- copyStdCode = ultraGrid1.GetActiveRowValue("STD_CODE");
- }
- private void CopyRowToRow(DataRow srcRow, DataRow desRow)
- {
- for (int i = 0; i < srcRow.Table.Columns.Count; i++)
- {
- string columnName = srcRow.Table.Columns[i].ColumnName;
- desRow[columnName] = srcRow[columnName];
- }
- }
- /// <summary>
- /// 粘贴
- /// </summary>
- private void Paste()
- {
- if (copyTable == null || copyTable.Rows.Count == 0)
- {
- MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
- return;
- }
- dataTable1.BeginInit();
- foreach (DataRow row in copyTable.Rows)
- {
- DataRow tempRow = dataTable1.NewRow();
- foreach (DataColumn column in dataTable1.Columns)
- {
- string columnName = column.ColumnName;
- List<string> notCopyColumns = new List<string>();
- notCopyColumns.AddRange("RATIO_ID", "CREATE_TIME", "CREATE_NAME", "UPDATE_TIME", "UPDATE_NAME",
- "DELETE_TIME", "DELETE_NAME", "VALIDFLAG");
- if (notCopyColumns.Contains(columnName) == true) continue;
- tempRow[columnName] = row[columnName];
- }
- tempRow["RATIO_ID"] = waterid;
- dataTable1.Rows.Add(tempRow);
- }
- dataTable1.EndInit();
- ultraGrid1.UpdateData();
- }
- private void InitCombox()
- {
- //_uce = new UltraComboEditor();
- //DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.GetStd",
- // new object[]{_stdCode}, this.ob);
- //if (dt != null && dt.Rows.Count > 0)
- //{
- // _uce.DataSource = dt;
- // _uce.DisplayMember = "STD_NAME";
- // _uce.ValueMember = "STD_CODE";
- //}
- //_uce.DropDownListWidth = -1;
- //this.Controls.Add(_uce);
- //_uce.Visible = false;
- //ClsBaseInfo.SetComboItemHeight(_uce);
- ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].EditorComponent = ultraTextEditor2;
- UltraComboEditor cmbStdNk = new UltraComboEditor();
- cmbStdNk.Visible = false;
- this.Controls.Add(cmbStdNk);
- QcmBaseQuery.NitializeInnerStandard(cmbStdNk, false, ob);
- if (stdCodeNk != "")
- {
- ((DataTable)cmbStdNk.DataSource).DefaultView.RowFilter = "STD_CODE = '" + stdCodeNk + "' OR STD_CODE = ''";
- }
- ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].EditorComponent = cmbStdNk;
- ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- //ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- UltraComboEditor uceStyle = new UltraComboEditor();
- this.Controls.Add(uceStyle);
- uceStyle.Visible = false;
- DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.getStdStyle", null, this.ob);
- if (dt1 != null && dt1.Rows.Count > 0)
- {
- Object[] obj = new Object[] { "", "" };
- DataRow dr = dt1.NewRow();
- dr.ItemArray = obj;
- dt1.Rows.InsertAt(dr, 0);
- uceStyle.DataSource = dt1;
- uceStyle.DisplayMember = "STD_STYLE_DESC";
- uceStyle.ValueMember = "STD_STYLE";
- }
- ClsBaseInfo.SetComboItemHeight(uceStyle);
- ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE"].EditorComponent = uceStyle;
- ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- ultraComboEditor3.SelectedIndex = 0;
- ClsBaseInfo.SetComboItemHeight(ultraComboEditor3);
- }
- private void doRefresh()
- {
- InitCombox();
- }
- private string ratioId = ""; //保存前一次激活的行
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- ((Form)ultraGrid1.TopLevelControl).Cursor = Cursors.WaitCursor;
- try
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = this.ultraGrid1.ActiveRow; //当前激活行
- if (ugr == null)
- return;
- //if (ugr.GetValue("RATIO_ID") != ratioId)
- //{
- // UltraGridRow[] rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("RATIO_ID") == ratioId).ToArray();
- // if (rows.Length > 0)
- // {
- // rows[0].Cells["CHK"].Value = false;
- // }
- //}
- ratioId = ugr.GetValue("RATIO_ID");
- if (ugr.Cells["VALIDFLAG"].Value.ToString() != "")
- GetSteel(ugr);
- else if (ugr.Cells["ISPASTED"].Text == "")
- GetSteelNew(ugr.Cells["RATIO_ID"].Value.ToString(), ugr.Cells["STD_CODE"].Value.ToString());
- else
- GetSteel(ugr);
- GetModel(ugr);
- ultraGrid1.UpdateData();
- }
- finally
- {
- ((Form)ultraGrid1.TopLevelControl).Cursor = Cursors.Default;
- }
- }
- private void GetSteel(UltraGridRow ugr)
- {
- if (ugr == null)
- return;
- string ratio_id = ugr.Cells["RATIO_ID"].Value.ToString();
- _id = ratio_id;
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.GetSteel", new Object[] { ratio_id }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
- //UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] };
- //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- ultraGrid2.Rows[i].Cells["RATIO_ID"].Value = ugr.Cells["RATIO_ID"].Value.ToString();
- }
- ultraGrid2.UpdateData();
- }
- public void GetSteelNew(string id, string stdname)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.getSteelNew", new object[] { stdname }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- ultraGrid2.Rows[i].Cells["RATIO_ID"].Value = id;
- }
- for (int i = 0; i < ultraGrid3.Rows.Count; i++)
- {
- ultraGrid3.Rows[i].Cells["RATIO_ID"].Value = id;
- }
- ultraGrid2.UpdateData();
- ultraGrid3.UpdateData();
- }
- private void GetModel(UltraGridRow ugr)
- {
- if (ugr == null)
- return;
- string ratio_id = ugr.Cells["RATIO_ID"].Value.ToString();
- _id = ratio_id;
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.getModel", new Object[] { ratio_id }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable3, true);
- for (int i = 0; i < ultraGrid3.Rows.Count; i++)
- {
- ultraGrid3.Rows[i].Cells["RATIO_ID"].Value = ugr.Cells["RATIO_ID"].Value.ToString();
- }
- ultraGrid3.UpdateData();
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- this.ultraGrid1.UpdateData();
- UltraGridRow ugr = this.ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- if (e.Cell.Column.Key.Equals("STD_NAME"))
- {
- e.Cell.Row.Cells["STD_CODE"].Value = e.Cell.Row.Cells["STD_CODE"].Value.ToString();
- if (e.Cell.Row.Cells["STD_CODE"].Value.ToString() == pastStdCode)
- GetSteel(e.Cell.Row);
- else
- GetSteelNew(e.Cell.Row.Cells["RATIO_ID"].Value.ToString(), e.Cell.Row.Cells["STD_CODE"].Value.ToString());
- }
- else if (e.Cell.Column.Key.Equals("STD_STYLE"))
- {
- e.Cell.Row.Cells["STD_STYLE_DESC"].Value = e.Cell.Row.Cells["STD_STYLE"].Text;
- }
- else if (e.Cell.Column.Key.Equals("CHK"))
- {
- if (e.Cell.Value.ToString().ToUpper() == "TRUE")
- {
- if (e.Cell.Row.Cells["VALIDFLAG"].Value.ToString() == "无效")
- {
- for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
- {
- if (e.Cell.Row.Cells[i] != e.Cell)
- e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- if (e.Cell.Column.Key == "CHK")
- {
- UltraGridRow chkRow = e.Cell.Row;
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["CHK"].Value.ToString() == "True" && row != chkRow)
- {
- row.Cells["CHK"].Value = "False";
- row.Update();
- }
- }
- }
- ultraGrid1.UpdateData();
- }
- private void ultraGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = this.ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- this.ultraGrid1.UpdateData();
- DataRow[] dr = dataTable1.Select("", "RATIO_ID DESC");
- int index = 0;
- if (dr.Length > 0)
- {
- index = Convert.ToInt32(dr[0]["RATIO_ID"]);
- index += 1;
- }
- else
- {
- index += 1;
- }
- ugr.Cells["RATIO_ID"].Value = index;
- ratioId = index.ToString();
- if (!Convert.ToBoolean(ugr.Cells["CHK"].Value))
- {
- for (int i = 0; i < ugr.Cells.Count; i++)
- {
- if (!ugr.Cells[i].Column.Key.Equals("CHK"))
- ugr.Cells[i].Activation = Activation.ActivateOnly;
- }
- }
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- ultraGrid2.Rows[i].Cells["RATIO_ID"].Value = ugr.Cells["RATIO_ID"].Value.ToString();
- }
- if (stdCodeNk != "")
- {
- ugr.Cells["STD_CODE_NK"].Value = stdCodeNk;
- }
- }
- private void doQuery(bool isValid)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.doQuery",
- new Object[] { _stdCode, stdStyleCode, isValid, stdCodeNk }, this.ob);
- ultraGrid1.BeginUpdate();
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- ActiveGridRow();
- //UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"],
- // this.ultraGrid1.DisplayLayout.Bands[0].Columns["RATIO_STD"],this.ultraGrid1.DisplayLayout.Bands[0].Columns["RATIO_ID"],
- //this.ultraGrid1.DisplayLayout.Bands[0].Columns["RATIO_REPLACE"]};
- //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["CHK"].Value.ToString().ToUpper() != "TRUE")
- {
- for (int j = 0; j < row.Cells.Count; j++)
- {
- if (!row.Cells[j].Column.Key.Equals("CHK"))
- row.Cells[j].Activation = Activation.ActivateOnly;
- }
- }
- if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
- {
- row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- row.Appearance.ForeColor = Color.Black;
- }
- }
- if (ultraCheckEditor1.Checked)
- {
- GetMatchRatioIdFrm();
- }
- ultraGrid1.EndUpdate();
- }
- private void GetMatchRatioIdFrm()
- {
- string stdName = ultraTextEditor1.Text.Trim();
- string stdStyleDesc = ultraComboEditor3.Value.ToString2();
- string dimater = ultraNumericEditor1.Value.ToString2();
- string steelName = ultraTextEditor3.Text.Trim();
- string modelDesc = ultraTextEditor4.Text.Trim();
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.getMatchRatioIdFrm",
- new object[] { stdName, dimater, stdStyleDesc, modelDesc, steelName }, ob);
- if (dt.Rows.Count > 0)
- {
- var rows = ultraGrid1.Rows.Where(a => dt.Select("RATIO_ID = '" + a.GetValue("RATIO_ID") + "'").Length > 0);
- ultraGrid1.BeginUpdate();
- foreach (var row in rows)
- {
- row.Appearance.BackColor = Color.FromArgb(124, 205, 124);
- }
- ultraGrid1.EndUpdate();
- }
- }
- private void doSave()
- {
- if (GetGrid1Data() == 0)
- {
- //List<string> tempList = onlyList.Distinct().ToList();
- //if (tempList.Count < onlyList.Count)
- //{
- // MessageUtil.ShowWarning("标准、标准类别、外径、试验压力系数、最大试验压力组成的记录重复!");
- // return;
- //}
- if (MessageBox.Show("是否保存选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
- ccp.ServerName = "com.steering.pss.qcm.CoreWaterRatio"; //服务名指的是服务端的包名+类名
- ccp.MethodName = "doSave"; //方法名指的是服务名指定类里的方法
- ccp.ServerParams = new object[] { listA, listU, listS, listM };//服务端方法的参数
- //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp != null)
- {
- if (ccp.ReturnInfo.ToString() == "FALSE####")
- {
- MessageUtil.ShowWarning("标准已引用了基础标准,不能再维护为基础标准!");
- return;
- }
- if (ccp.ReturnInfo.ToString() == "FALSE#Reapt")
- {
- MessageUtil.ShowWarning("标准、标准类别、外径、试验压力系数、最大试验压力组成的记录重复!");
- string tempstr = ccp.ReturnObject.ToString();
- int num = GetRowNum(tempstr);
- ultraGrid1.Rows[num].Activate();
- ultraGrid1.Rows[num].Selected = true;
- return;
- }
- }
- if (ccp.ReturnCode == -1)
- return;
- MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- doQuery(false);
- _id = "";
- }
- }
- /// <summary>
- /// 获取第几行
- /// </summary>
- /// <param name="parm">每一行的主键值</param>
- /// <returns>第几行</returns>
- private int GetRowNum(String parm)
- {
- int num = 0;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["RATIO_ID"].Value.ToString() == parm)
- {
- num = i;
- break;
- }
- }
- return num;
- }
- private void doDeleteOrResume(bool flag)
- {
- this.ultraGrid1.UpdateData();
- ArrayList parm = new ArrayList();
- int isselect = 0;
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- ArrayList list = new ArrayList();
- if (flag) //删除
- {
- if (row.Cells["VALIDFLAG"].Value.ToString() == "无效")
- {
- MessageBox.Show("无效数据,无法作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return;
- }
- isselect += 1;
- list.Add(this.UserInfo.GetUserName());
- list.Add(row.Cells["RATIO_ID"].Value.ToString());
- parm.Add(list);
- }
- else
- {
- if (row.Cells["VALIDFLAG"].Value.ToString() == "有效")
- {
- MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return;
- }
- ArrayList listR = new ArrayList();
- isselect += 1;
- listR.Add(row.Cells["STD_CODE"].Value.ToString());
- listR.Add(row.Cells["STD_STYLE"].Value.ToString());
- listR.Add(row.Cells["SIZE_MIN_SIGN"].Value.ToString());
- listR.Add(row.Cells["SIZE_MIN"].Value.ToString());
- listR.Add(row.Cells["SIZE_MAX_SIGN"].Value.ToString());
- listR.Add(row.Cells["SIZE_MAX"].Value.ToString());
- listR.Add(row.Cells["RATIO_STD"].Value.ToString());
- listR.Add(row.Cells["MAX_PRESS"].Value.ToString());
- listR.Add(row.Cells["RATIO_ID"].Value.ToString());
- parm.Add(listR);
- }
- _id = row.Cells["RATIO_ID"].Value.ToString();
- }
- }
- if (isselect == 0)
- {
- MessageBox.Show("请选择需要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (MessageBox.Show("确认" + (flag ? "作废" : "恢复") + "所选数据", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- // int count = ServerHelper.SetData("com.steering.pss.qcm.CoreWaterRatio.doDelete", new Object[] { parm, flag }, this.ob);
- CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
- ccp.ServerName = "com.steering.pss.qcm.CoreWaterRatio"; //服务名指的是服务端的包名+类名
- ccp.MethodName = "doDelete"; //方法名指的是服务名指定类里的方法
- ccp.ServerParams = new object[] { parm, flag };//服务端方法的参数
- //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp != null)
- {
- if (ccp.ReturnInfo == "ResumeFALSE##")
- {
- MessageUtil.ShowWarning("已存在相同的有效数据,无法恢复!");
- string tempstr = ccp.ReturnObject.ToString();
- int num = GetRowNum(tempstr);
- ultraGrid1.Rows[num].Activate();
- ultraGrid1.Rows[num].Selected = true;
- return;
- }
- }
- if (ccp.ReturnCode == -1)
- return;
- MessageBox.Show("数据" + (flag ? "作废" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
- doQuery(false);
- _id = "";
- }
- private int GetGrid1Data()
- {
- this.ultraGrid1.UpdateData();
- listA = new ArrayList();
- listU = new ArrayList();
- onlyList.Clear();
- dataTable1.AcceptChanges();
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- if (row.Cells["STD_NAME"].Value.ToString() == "")
- {
- MessageBox.Show("请选择标准名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Cells["STD_NAME"].Activate();
- return -1;
- }
- if (row.Cells["STD_CODE_NK"].Value.ToString() == "")
- {
- MessageBox.Show("请选择内控管理号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Cells["STD_CODE_NK"].Activate();
- return -1;
- }
- string min_sign = row.Cells["SIZE_MIN_SIGN"].Value.ToString();
- string min_val = row.Cells["SIZE_MIN"].Value.ToString();
- string max_sign = row.Cells["SIZE_MAX_SIGN"].Value.ToString();
- string max_val = row.Cells["SIZE_MAX"].Value.ToString();
- if (min_sign != "" && min_val == "")
- {
- MessageBox.Show("下限符号不为空,请输入下限值或清空下限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (min_sign == "" && min_val != "")
- {
- MessageBox.Show("下限值不为空,请选择下限符号或清空下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (max_sign != "" && max_val == "")
- {
- MessageBox.Show("上限限符号不为空,请输入上限值或清空上限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (max_sign == "" && max_val != "")
- {
- MessageBox.Show("上限值不为空,请选择上限符号或清空上限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (min_val != "")
- {
- if (!StringUtil.IsNumber(min_val))
- {
- MessageBox.Show("外径下限值 请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- }
- if (max_val != "")
- {
- if (!StringUtil.IsNumber(max_val))
- {
- MessageBox.Show("外径上限值 请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- }
- if (min_val != "" && max_val != "")
- {
- if (Convert.ToDouble(max_val) < Convert.ToDouble(min_val))
- {
- MessageBox.Show("外径上限值不能小于下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- }
- string ratio_std = row.Cells["RATIO_STD"].Value.ToString();
- string ratio_replace = row.Cells["RATIO_REPLACE"].Value.ToString();
- if (ratio_std == "")
- {
- MessageBox.Show("请输入标准试验压力系数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (!StringUtil.IsNumber(ratio_std))
- {
- MessageBox.Show("标准试验压力系数:请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (Convert.ToDouble(ratio_std) < 0 || Convert.ToDouble(ratio_std) > 1)
- {
- MessageBox.Show("标准试验压力系数输入值不合法(值在0-1之间)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (ratio_replace != "")
- {
- if (!StringUtil.IsNumber(ratio_replace))
- {
- MessageBox.Show("替代试验压力系数:请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- if (Convert.ToDouble(ratio_replace) < 0 || Convert.ToDouble(ratio_replace) > 1)
- {
- MessageBox.Show("替代试验压力系数输入值不合法(值在0-1之间)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- row.Activate();
- return -1;
- }
- }
- if (StringUtil.IsDouble(row.Cells["MAX_PRESS"].Value.ToString()) == false)
- {
- MessageUtil.ShowWarning("最大试验压力不是有效数字!");
- row.Activate();
- return -1;
- }
- else
- {
- if (double.Parse(row.Cells["MAX_PRESS"].Value.ToString()) > 250)
- {
- MessageUtil.ShowWarning("最大试验压力不能大于250MPa!");
- row.Activate();
- return -1;
- }
- }
- //验证重复
- string[] steels = ultraGrid2.Rows.Where(a => a.GetValue("CHK").ToUpper() == "TRUE").Select(a => a.GetValue("STEELCODE")).ToArray();
- string[] models = ultraGrid3.Rows.Where(a => a.GetValue("CHK").ToUpper() == "TRUE").Select(a => a.GetValue("MODEL_CODE")).ToArray();
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.existsWaterRatio",
- new object[] { row.GetValue("STD_CODE"), row.GetValue("STD_STYLE"), row.GetValue("SIZE_MIN_SIGN"),
- row.GetValue("SIZE_MIN"), row.GetValue("SIZE_MAX_SIGN"), row.GetValue("SIZE_MAX"), row.GetValue("RATIO_STD"),
- row.GetValue("MAX_PRESS"), steels, models, row.GetValue("RATIO_ID"),row.GetValue("STD_CODE_NK") }, ob);
- if (dt.Rows.Count > 0)
- {
- MessageUtil.ShowWarning("标准、标准类别、外径、试验压力系数、最大试验压力、钢级、扣型、内控管理号组成的记录与水压系数主键["
- + dt.Rows[0]["RATIO_ID"].ToString() + "]重复!");
- row.Activate();
- return -1;
- }
- if (row.Cells["VALIDFLAG"].Value.ToString() == "") //新增
- {
- ArrayList list = new ArrayList();
- list.Add(row.Cells["RATIO_ID"].Value.ToString());
- list.Add(row.Cells["STD_CODE"].Value.ToString());
- list.Add(row.Cells["STD_NAME"].Text);
- list.Add(min_sign);
- list.Add(min_val);
- list.Add(max_sign);
- list.Add(max_val);
- list.Add(row.Cells["RATIO_STD"].Value.ToString());
- list.Add(row.Cells["RATIO_REPLACE"].Value.ToString());
- list.Add(this.UserInfo.GetUserName());
- list.Add(row.Cells["MEMO"].Value.ToString());
- list.Add(row.Cells["MAX_PRESS"].Value.ToString());
- list.Add(row.Cells["STD_STYLE"].Value.ToString());
- list.Add(row.Cells["STD_STYLE_DESC"].Value.ToString());
- list.Add(row.Cells["STD_CODE_NK"].Value.ToString());
- listA.Add(list);
- //onlyList.Add(row.Cells["STD_CODE"].Value.ToString() + row.Cells["STD_STYLE"].Value.ToString() +
- // min_sign + min_val + max_sign + max_val + row.Cells["RATIO_STD"].Value.ToString() + row.Cells["MAX_PRESS"].Value.ToString());
- }
- else
- {
- string[] units = ClsBaseInfo.GetUnitByUserName(row.GetValue("CREATE_NAME"), ob, "002001007", "002001001", "002023005");
- if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
- {
- MessageUtil.ShowWarning("只有" + units[1] + "才能修改本条记录!");
- row.Activate();
- return -1;
- }
- ArrayList list = new ArrayList();
- list.Add(row.Cells["RATIO_ID"].Value.ToString());
- list.Add(row.Cells["STD_CODE"].Value.ToString());
- list.Add(row.Cells["STD_NAME"].Text);
- list.Add(min_sign);
- list.Add(min_val);
- list.Add(max_sign);
- list.Add(max_val);
- list.Add(row.Cells["RATIO_STD"].Value.ToString());
- list.Add(row.Cells["RATIO_REPLACE"].Value.ToString());
- list.Add(this.UserInfo.GetUserName());
- list.Add(row.Cells["MEMO"].Value.ToString());
- list.Add(row.Cells["MAX_PRESS"].Value.ToString());
- list.Add(row.Cells["STD_STYLE"].Value.ToString());
- list.Add(row.Cells["STD_STYLE_DESC"].Value.ToString());
- list.Add(row.Cells["STD_CODE_NK"].Value.ToString());
- listU.Add(list);
- onlyList.Add(row.Cells["STD_CODE"].Value.ToString() + row.Cells["STD_STYLE"].Value.ToString() +
- min_sign + min_val + max_sign + max_val + row.Cells["RATIO_STD"].Value.ToString() + row.Cells["MAX_PRESS"].Value.ToString());
- }
- }
- }
- if (GetGrid2Data() == -1)
- return -1;
- if (GetGrid3Data() == -1)
- return -1;
- return 0;
- }
- private int GetGrid2Data()
- {
- listS = new ArrayList();
- ultraGrid2.UpdateData();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- return -1;
- int i = 0;
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- i++;
- //if (ugr.Cells["VALIDFLAG"].Value.ToString() == "")
- //{
- // MessageBox.Show("当前激活的水压系数主键尚未写入数据,无法保存关联的钢级", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return -1;
- //}
- ArrayList list = new ArrayList();
- list.Add(row.Cells["RATIO_ID"].Value.ToString());
- list.Add(row.Cells["STEELCODE"].Value.ToString());
- list.Add(row.Cells["STEELNAME"].Value.ToString());
- list.Add(this.UserInfo.GetUserName());
- list.Add(row.Cells["MEMO"].Value.ToString());
- listS.Add(list);
- }
- }
- if (i == 0)
- {
- MessageUtil.ShowWarning("钢级至少选择一个!");
- return -1;
- }
- return 0;
- }
- private int GetGrid3Data()
- {
- listM = new ArrayList();
- ultraGrid3.UpdateData();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- return -1;
- int i = 0;
- foreach (UltraGridRow row in ultraGrid3.Rows)
- {
- if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
- {
- i++;
- ArrayList list = new ArrayList();
- list.Add(row.Cells["RATIO_ID"].Value.ToString());
- list.Add(row.Cells["MODEL_CODE"].Value.ToString());
- list.Add(row.Cells["MODEL_DESC"].Value.ToString());
- list.Add(this.UserInfo.GetUserName());
- list.Add(row.Cells["MEMO"].Value.ToString());
- listM.Add(list);
- }
- }
- if (i == 0)
- {
- MessageUtil.ShowWarning("扣型至少选择一个!");
- return -1;
- }
- return 0;
- }
- private void ActiveGridRow()
- {
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["RATIO_ID"].Value.ToString().Equals(_id))
- {
- row.Activate();
- break;
- }
- }
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- List<string> listNoEdit = new List<string>();
- listNoEdit.Add("有效标志");
- listNoEdit.Add("创建人");
- listNoEdit.Add("创建时间");
- listNoEdit.Add("修改人");
- listNoEdit.Add("修改时间");
- listNoEdit.Add("删除人");
- listNoEdit.Add("删除时间");
- listNoEdit.Add("水压系数主键");
- List<string> listDrop = new List<string>();
- listDrop.Add("标准名称");
- listDrop.Add("符号");
- ControlGridSelectEdit(e, listNoEdit, listDrop, "CHK");
- BandCombo(e);
- if (isPasting)
- {
- // e.Row.SetValue("CHK", "True");
- e.Row.SetValue("ISPASTED", "1");
- pastStdCode = copyStdCode;
- this.ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Activate();
- }
- }
- private void BandCombo(InitializeRowEventArgs e)
- {
- e.Row.Cells["STD_NAME"].EditorComponent = ultraTextEditor2;
- e.Row.Cells["SIZE_MIN_SIGN"].EditorComponent = ultraComboEditor1;
- e.Row.Cells["SIZE_MAX_SIGN"].EditorComponent = ultraComboEditor2;
- }
- public void ControlGridSelectEdit(InitializeRowEventArgs e, List<string> listNoEdit, List<string> listDrop, string CkbKey)
- {
- if (e == null)
- return;
- if (e.Row.Cells[CkbKey].Value.ToString() == "True")
- {
- foreach (UltraGridCell cell in e.Row.Cells)
- {
- if (cell.Column.Header.Caption == "选择") continue;
- if (listNoEdit.Contains(cell.Column.Header.Caption))
- {
- cell.Activation = Activation.ActivateOnly;
- }
- else if (listDrop.Contains(cell.Column.Header.Caption))
- {
- cell.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- cell.Activation = Activation.AllowEdit;
- }
- else
- {
- cell.Activation = Activation.AllowEdit;
- }
- }
- }
- else
- {
- foreach (UltraGridCell cell in e.Row.Cells)
- {
- if (cell.Column.Header.Caption == "选择") continue;
- if (listDrop.Contains(cell.Column.Header.Caption))
- {
- cell.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown;
- cell.Activation = Activation.ActivateOnly;
- }
- else
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- private void ShowWindow()
- {
- FrmWaterRatioStd wrs = new FrmWaterRatioStd();
- wrs.Ob = this.ob;
- wrs.ShowDialog();
- }
- private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
- {
- ultraGroupBox1.Enabled = ultraCheckEditor1.Checked;
- }
- private void ultraTextEditor2_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- this.Cursor = Cursors.WaitCursor;
- string stdCode = ultraGrid1.ActiveRow.GetValue("STD_CODE");
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreWaterRatio.GetStd",
- new object[] { _stdCode }, this.ob);
- dt.Columns["STD_NAME"].Caption = "标准名称";
- BaseInfoPopup popup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE");
- 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"));
- string s = popup.ChoicedRow.GetValue("STD_CODE");
- ultraGrid1.ActiveRow.Update();
- }
- ultraGrid1.ActiveRow.Cells["STD_CODE"].Value = ultraGrid1.ActiveRow.Cells["STD_CODE"].Value.ToString();
- if (ultraGrid1.ActiveRow.Cells["STD_CODE"].Value.ToString() == pastStdCode)
- GetSteel(ultraGrid1.ActiveRow);
- else
- GetSteelNew(ultraGrid1.ActiveRow.Cells["RATIO_ID"].Value.ToString(), ultraGrid1.ActiveRow.Cells["STD_CODE"].Value.ToString());
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- e.Cell.Row.Update();
- }
- private void ultraGrid3_CellChange(object sender, CellEventArgs e)
- {
- e.Cell.Row.Update();
- }
- }
- }
|