using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Qcm.model; 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.Windows.Forms; using System.Linq; namespace Core.StlMes.Client.Qcm { public partial class FrmComMSCStdProcess : FrmBase { public FrmComMSCStdProcess() { InitializeComponent(); ExceptionHelper.RegistException(); this.IsLoadUserView = true; } public void PopupLoad(string customInfo, OpeBase ob) { this.CustomInfo = customInfo; this.ob = ob; FrmComMSCStdProcess_Load(null, null); } private bool isPasting = false; //Global variable UltraComboEditor MscUce = new UltraComboEditor(); //MSC下拉框 UltraComboEditor StationUce = new UltraComboEditor(); //工序点下拉框 UltraComboEditor StdUce = new UltraComboEditor(); //标准下拉框 UltraComboEditor cmbProBigType = new UltraComboEditor(); private int _index = 1; //加工索引号 private string _gic = ""; //提示信息信息 private string errMessage = ""; //是否展开 private bool _isEx = false; private string gic = ""; public string Gic { get { return gic; } set { gic = value; } } private string msc = ""; public string Msc { get { return msc; } set { msc = value; } } private string codeJg = "DefaultValue"; public string CodeJg { get { return codeJg; } set { codeJg = value; } } private string stdCode = ""; public string StdCode { get { return stdCode; } set { stdCode = value; } } private ArrayList steelCodes = new ArrayList(); public ArrayList SteelCodes { get { return steelCodes; } set { steelCodes = value; } } private string produccodeNk = ""; public string ProduccodeNk { get { return produccodeNk; } set { produccodeNk = value; } } private string steelcodeNk = ""; public string SteelcodeNk { get { return steelcodeNk; } set { steelcodeNk = value; } } private string processCode = ""; public string ProcessCode { get { return processCode; } set { processCode = value; } } private string modelCode = ""; public string ModelCode { get { return modelCode; } set { modelCode = value; } } private string acceptBid = ""; public string AcceptBid { get { return acceptBid; } set { acceptBid = value; } } private void FrmComMSCStdProcess_Load(object sender, EventArgs e) { HideCols(); Init(); } private void HideCols() { if (this.CustomInfo == "1") { ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_DESC"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC_NK"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCCODE_NK"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME_NK"].Hidden = true; //ultraGrid1.DisplayLayout.Bands[1].Groups[0].Hidden = true; //ultraGrid1.DisplayLayout.Bands[1].Groups[1].Hidden = true; } if (this.CustomInfo == "2") { ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].Header.Caption = "内控管理编号"; ultraCheckMSC.Visible = false; ultraTextMSC.Visible = false; } } private void DoRefresh() { Init(); } public void PopupRefresh() { if (CustomInfo == "1") //MSC { //--------MSC--------------- this.Controls.Add(MscUce); MscUce.Visible = false; QcmBaseQuery.NitializeMSC(MscUce, false, this.ob, msc); QcmBaseQuery.BindColumn(MscUce, "MSC", ultraGrid1.DisplayLayout.Bands[0]); //---------MSC END---------- } } private void Init() { if (CustomInfo == "1") //MSC { //--------MSC--------------- this.Controls.Add(MscUce); MscUce.Visible = false; QcmBaseQuery.NitializeMSC(MscUce, false, this.ob, msc); QcmBaseQuery.BindColumn(MscUce, "MSC", ultraGrid1.DisplayLayout.Bands[0]); //---------MSC END---------- } if (CustomInfo == "2") //内控标准 { InnerChange(); this.Controls.Add(StdUce); StdUce.Visible = false; QcmBaseQuery.NitializeInnerStandard(StdUce, false, this.ob); QcmBaseQuery.BindColumn(StdUce, "STD_CODE_NK", ultraGrid1.DisplayLayout.Bands[0]); UltraComboEditor uce = new UltraComboEditor(); this.Controls.Add(uce); uce.Visible = false; DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getProcess", null, this.ob); uce.DataSource = dt1; uce.ValueMember = "PROCESS_CDOE"; uce.DisplayMember = "PROCESS_DESC"; QcmBaseQuery.BindColumn(uce, "PROCESS_CDOE", ultraGrid1.DisplayLayout.Bands[0]); } QcmBaseQuery.NitializeSignMin(ultraComSignMin); QcmBaseQuery.NitializeSignMax(ultraComSignMax); //---子表工序点名称-------- this.Controls.Add(MscUce); MscUce.Visible = false; this.Controls.Add(StationUce); StationUce.Visible = false; DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getStation", null, this.ob); StationUce.DataSource = dt; StationUce.DisplayMember = "STATION_DESC"; StationUce.ValueMember = "STATION_CODE"; QcmBaseQuery.BindColumn(StationUce, "STATION_CODE", ultraGrid1.DisplayLayout.Bands[1]); cmbProBigType.Visible = false; this.Controls.Add(cmbProBigType); QcmBaseQuery.NitializeProductBigType(cmbProBigType, true, ob); QcmBaseQuery.BindColumn(cmbProBigType, "PRODUC_HEAD", ultraGrid1.DisplayLayout.Bands[0]); ClsBaseInfo.SetComboItemHeight(cmbProBigType); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": DoQuery(); break; case "Save": DoSave(); break; case "Delete": DoDeleteOrResume(true); break; case "Resume": DoDeleteOrResume(false); break; case "Copy": Copy(); break; case "Paste": isPasting = true; try { Paste(); } finally { isPasting = false; } break; case "Refresh": DoRefresh(); break; case "Group": DoGroup(); break; case "CancleGroup": CancleGroup(); break; case "Close": this.Close(); break; } } private void DoGroup() { ArrayList list = new ArrayList(); int ischeck = 0; //是否勾选 int isselect = 0; //勾选项是否已写入数据库 int isvalid = 0; //是否有效 foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.HasChild() && row.Cells["CHC"].Value.ToString().ToUpper() == "TRUE") { MessageBox.Show("主表不能进行分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ArrayList plist = new ArrayList(); //分为几组。 foreach (UltraGridRow crow in row.ChildBands[0].Rows) { ArrayList clist = new ArrayList(); //哪些分为一组。 if (crow.Cells["CHC"].Value.ToString().ToUpper() == "TRUE") { if (crow.Cells["VALIDFLAG"].Value.ToString().Equals("")) { isselect += 1; } if (crow.Cells["VALIDFLAG"].Value.ToString().Equals("无效")) { isvalid += 1; } ischeck += 1; clist.Add(crow.Cells["GIC"].Value.ToString()); clist.Add(crow.Cells["XH"].Value.ToString()); plist.Add(clist); _gic = crow.Cells["GIC"].Value.ToString(); _isEx = true; } } list.Add(plist); } if (ischeck == 0) { MessageBox.Show("请选择你要分组的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (isselect > 0) { MessageBox.Show("您选择的分组记录中存在未保存的项,请先保存后再分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (isvalid > 0) { MessageBox.Show("您选择的分组记录中存在无效数据,无法分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("是否确认对所选项进行分组?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。 ccp.ServerName = "com.steering.pss.qcm.CoreComMscStdProcess"; //服务名指的是服务端的包名+类名 ccp.MethodName = "doGroup"; //方法名指的是服务名指定类里的方法 ccp.ServerParams = new object[] { list };//服务端方法的参数 //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。 ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageBox.Show("分组成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DoQuery(); //ExpandRow(); //PicCode.Clear(); } /// /// 复制 /// private void Copy() { if (ultraGrid1.ActiveRow == null) { MessageUtil.ShowWarning("请选择记录后,再进行操作!"); return; } ultraGrid1.UpdateData(); DataTable copyTab = dataTable2.Copy(); DataTable copyTab2 = dataTable1.Copy(); copyTab.Clear(); copyTab2.Clear(); if (ultraGrid1.ActiveRow.HasParent()) { foreach (UltraGridRow row in ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows) { if (row.GetValue("CHC") != "True") continue; DataRow dr = copyTab.NewRow(); CopyRowToRow(((DataRowView)row.ListObject).Row, dr); copyTab.Rows.Add(dr); } } else { foreach (UltraGridRow row in ultraGrid1.ActiveRow.ChildBands[0].Rows) { DataRow dr = copyTab.NewRow(); CopyRowToRow(((DataRowView)row.ListObject).Row, dr); copyTab.Rows.Add(dr); } DataRow dr2 = copyTab2.NewRow(); CopyRowToRow(((DataRowView)ultraGrid1.ActiveRow.ListObject).Row, dr2); copyTab2.Rows.Add(dr2); } DataTable[] copyTabs = new DataTable[] { copyTab, copyTab2 }; Clipboard.SetData("Gic", copyTabs); } 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]; } } /// /// 粘贴 /// private void Paste() { DataTable[] copyTabs = (DataTable[])Clipboard.GetData("Gic"); if (copyTabs == null) { MessageUtil.ShowWarning("没有数据,请复制后再进行操作!"); return; } DataTable copyTab = copyTabs[0]; DataTable copyTab2 = copyTabs[1]; if (copyTab == null || copyTab.Rows.Count == 0) { MessageUtil.ShowWarning("没有数据,请复制后再进行操作!"); return; } dataTable2.BeginInit(); string gic = ""; UltraGridRow rowParent; if (ultraGrid1.ActiveRow.HasParent()) { //if (ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows.Count > 0) //{ // MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!"); // return; //} gic = ultraGrid1.ActiveRow.ParentRow.GetValue("GIC"); rowParent = ultraGrid1.ActiveRow.ParentRow; } else { //if (ultraGrid1.ActiveRow.ChildBands[0].Rows.Count > 0) //{ // MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!"); // return; //} gic = ultraGrid1.GetActiveRowValue("GIC"); rowParent = ultraGrid1.ActiveRow; } List notCopyColumns = new List(); notCopyColumns.AddRange("CHC", "CREATE_TIME", "CREATE_NAME", "UPDATE_TIME", "UPDATE_NAME", "DELETE_TIME", "DELETE_NAME", "VALIDFLAG", "GIC", "MSC", "STD_CODE_NK", "STD_NAME_NK", "STDSTYLE", "PSC_DESC", "PSC", "PROCESS_CODE", "PRODUCNAME", "STEELNAME", "STD_NAME", "STD_STYLE_DESC", "PRODUCCODE_NK", "PRODUCNAME_NK", "PROCESS_CDOE", "PROCESS_DESC", "STEELCODE_NK", "STEELNAME_NK"); if (copyTab2.Rows.Count > 0) { DataRow drParent = ((DataRowView)rowParent.ListObject).Row; foreach (DataColumn column in dataTable1.Columns) { string columnName = column.ColumnName; if (notCopyColumns.Contains(columnName) == true) continue; drParent[columnName] = copyTab2.Rows[0][columnName]; } } foreach (DataRow row in copyTab.Rows) { DataRow tempRow = dataTable2.NewRow(); foreach (DataColumn column in dataTable2.Columns) { string columnName = column.ColumnName; bool isCopyProcess = (columnName == "PROCESS_CDOE") || (columnName == "PROCESS_DESC") ? true : false; if (notCopyColumns.Contains(columnName) && !isCopyProcess) continue; tempRow[columnName] = row[columnName]; } tempRow["GIC"] = gic; dataTable2.Rows.Add(tempRow); } dataTable2.EndInit(); if (copyTab.Rows.Count > 0 && ultraGrid1.ActiveRow != null) { ultraGrid1.ActiveRow.ExpandAll(); } ultraGrid1.UpdateData(); } /// /// 取消分组 /// private void CancleGroup() { int ischeck = 0; //是否勾选 int isselect = 0; //勾选项是否已写入数据库 int isvalid = 0; //是否有效 int hasindex = 0; ArrayList plist = new ArrayList(); foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.HasChild() && row.Cells["CHC"].Value.ToString().ToUpper() == "TRUE") { MessageBox.Show("主表不能进行取消分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } foreach (UltraGridRow crow in row.ChildBands[0].Rows) { ArrayList clist = new ArrayList(); //需要取消的GIC和XH if (crow.Cells["CHC"].Value.ToString().ToUpper() == "TRUE") { if (crow.Cells["VALIDFLAG"].Value.ToString().Equals("")) { isselect += 1; } if (crow.Cells["VALIDFLAG"].Value.ToString().Equals("无效")) { isvalid += 1; } if (crow.Cells["GROUP_SEQ"].Value.ToString().Equals("")) { hasindex += 1; } ischeck += 1; clist.Add(crow.Cells["GIC"].Value.ToString()); clist.Add(crow.Cells["XH"].Value.ToString()); plist.Add(clist); _gic = crow.Cells["GIC"].Value.ToString(); _isEx = true; } } } if (ischeck == 0) { MessageBox.Show("请选择你要取消分组的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (isselect > 0) { MessageBox.Show("您选择的记录中存在未保存的项,不能对其进行取消分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (isvalid > 0) { MessageBox.Show("您选择的记录中存在无效数据,无法取消分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (hasindex > 0) { MessageBox.Show("您选择的记录中存在未分组的数据,无法取消分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("是否确认对所选项进行取消分组?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int count = ServerHelper.SetData("com.steering.pss.qcm.CoreComMscStdProcess.cancleGroup", new Object[] { plist }, this.ob); if (count > 0) { MessageBox.Show("取消分组成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DoQuery(); } } /// /// 查询条件 /// /// private ArrayList GetQueryData() { ArrayList list = new ArrayList(); //标准名称 string stdName = ""; if (ultraCheckStd.Checked) stdName = ultraTextStd.Text.Trim(); list.Add(stdName); //冶金规范码 string msc = ""; if (ultraCheckMSC.Checked) { msc = ultraTextMSC.Text.Trim(); } list.Add(msc); //是否包含无效 string valid = "1"; if (ultraCheckValid.Checked) valid = "0"; list.Add(valid); list.Add(stdCode); return list; } private void DoQuery() { //查询交付标准、内控标准或者Alpha ArrayList QueryConditon = GetQueryData(); //主表查询 dataTable2.Clear(); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getMscStdProcess", new Object[] { QueryConditon, CustomInfo, gic, msc, codeJg, produccodeNk, steelcodeNk, processCode, modelCode }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true); //从表查询 DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getMscStdProcessC", new Object[] { QueryConditon, CustomInfo, gic, msc, codeJg, produccodeNk, steelcodeNk, processCode, modelCode }, this.ob); GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true); //不同颜色区分是否有效数据 QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效"); QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1); UltraGridBand bc = ultraGrid1.DisplayLayout.Bands[0]; UltraGridBand bcC = ultraGrid1.DisplayLayout.Bands[1]; UltraGridColumn[] col = new UltraGridColumn[] { bc.Columns["MEMO"], bc.Columns["MSC"], bc.Columns["MODEL_DESC"] }; GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col); //isSelect = 0; //定位行和展开行 UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "GIC" }, new string[] { _gic }); if (rows1.Length > 0) { rows1[0].Activate(); if (_isEx) rows1[0].ExpandAll(); } foreach (UltraGridRow ugr in ultraGrid1.Rows) { ugr.Cells["CHKNK"].Value = "选择"; } _isEx = false; _gic = ""; dataTable1.AcceptChanges(); dataTable2.AcceptChanges(); //清空复制数据 //_copyedRows.Clear(); } public void QueryPurchaseAgreement(string stdCodeNk) { dataTable2.Clear(); dataTable1.Clear(); DataTable dtP = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getPurchaseAgreementGic", new object[] { stdCodeNk }, ob); GridHelper.CopyDataToDatatable(ref dtP, ref this.dataTable1, true); DataTable dtC = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getPurchaseAgreementProc", new object[] { stdCodeNk }, ob); GridHelper.CopyDataToDatatable(ref dtC, ref this.dataTable2, true); QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效"); QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1); } public void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow; if (e.Cell.Column.Key.Equals("MSC"))//冶金规范码 { string msc = ugr.Cells["MSC"].Value.ToString(); DataRow[] dr = ((DataTable)MscUce.DataSource).Select("MSC='" + msc + "'"); if (dr.Length > 0) { ugr.Cells["PSC"].Value = dr[0][2]; ugr.Cells["PSC_DESC"].Value = dr[0][3]; ugr.Cells["PRODUCNAME"].Value = dr[0][4]; ugr.Cells["STD_NAME"].Value = dr[0][5]; ugr.Cells["STEELNAME"].Value = dr[0][6]; ugr.Cells["STD_STYLE_DESC"].Value = dr[0][7]; ugr.Cells["STDSTYLE"].Value = dr[0][8]; } } if (e.Cell.Column.Key.Equals("STATION_CODE")) //子表工序点 { string stationcode = ugr.Cells["STATION_CODE"].Value.ToString(); DataRow[] dr = ((DataTable)StationUce.DataSource).Select("STATION_CODE='" + stationcode + "'"); if (dr.Length > 0) { ugr.Cells["PROCESS_CDOE"].Value = dr[0][2]; ugr.Cells["PROCESS_DESC"].Value = dr[0][3]; } } if (e.Cell.Column.Key.Equals("STD_CODE_NK")) //标准下拉框选择 { ugr.Cells["STD_NAME_NK"].Value = ugr.Cells["STD_CODE_NK"].Text; DataRow[] dr = ((DataTable)StdUce.DataSource).Select("STD_CODE='" + ugr.Cells["STD_CODE_NK"].Value + "'"); if (dr.Length > 0) ugr.Cells["STDSTYLE"].Value = dr[0][2]; } if (e.Cell.Column.Key.Equals("PROCESS_CDOE")) { ugr.Cells["PROCESS_DESC"].Value = e.Cell.Text; } if (e.Cell.Column.Key.Equals("CHC")) // { 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("CHC")) { e.Cell.Row.Cells[i].Activation = activation; } } } } private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e) { string style = ""; if (CustomInfo == "1") style = "G"; if (CustomInfo == "2") style = "N"; //if (CustomInfo == "3") // style = "K"; //if (CustomInfo == "4") // style = "S"; UltraGridRow ugr = ultraGrid1.ActiveRow; if (!ugr.HasParent()) { string gicStr = ""; string gic = ""; DataRow[] dr = dataTable1.Select("", "GIC DESC"); if (dr.Length > 0) { gic = dr[0]["GIC"].ToString(); } if (!gic.Equals("")) { int number = int.Parse(gic.Substring(4, 6)); gicStr = "GIC" + style + string.Format("{0:000000}", number + 1); _index = number + 1; } else { gicStr = "GIC" + style + string.Format("{0:000000}", _index); _index = _index + 1; } //赋值理化索引号 ugr.Cells["GIC"].Value = gicStr; ugr.Cells["PROCESS_CDOE"].Value = "G"; ugr.Cells["PROCESS_DESC"].Value = ugr.Cells["PROCESS_CDOE"].Text; } else { int indexSeq = 0; DataRow[] dr = dataTable2.Select("GIC='" + ugr.Cells["GIC"].Value.ToString() + "'", "XH DESC"); if (dr.Length > 0) { indexSeq = Convert.ToInt32(dr[0]["XH"]); } indexSeq += 1; //赋值序号 this.ultraGrid1.DisplayLayout.ActiveRow.Cells["XH"].Value = indexSeq; } //增加行如果没有勾选则不可编辑 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; if (ugr.Cells[i].Column.Key.Equals("CHKNK")) ugr.Cells["CHKNK"].Value = "选择"; } } e.Row.Update(); } FrmComMSCStdProcess _frmComMSCStdProcess = null; private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e) { if (e.Cell.Column.Key.Equals("MODEL_DESC") && ultraGrid1.DisplayLayout.ActiveRow.Cells["CHC"].Value.ToString().ToUpper() == "TRUE") { UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow; FrmModel frms = new FrmModel(); frms.FrmOb = this.ob; frms.Desc = row.Cells["MODEL_DESC"].Value.ToString(); frms.ShowDialog(); row.Cells["MODEL_CODE"].Value = frms.Code; row.Cells["MODEL_DESC"].Value = frms.Desc; } if (e.Cell.Column.Key.Equals("CHKNK")) { UltraGridRow ugr = ultraGrid1.ActiveRow; _frmComMSCStdProcess = new FrmComMSCStdProcess(); _frmComMSCStdProcess.PopupLoad("3", ob); _frmComMSCStdProcess.UltraPanel1.Visible = false; _frmComMSCStdProcess.ultraToolbarsManager1.Visible = true; _frmComMSCStdProcess.Msc = msc; _frmComMSCStdProcess.CodeJg = ""; _frmComMSCStdProcess.DoQuery1(); if (_frmComMSCStdProcess.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DataRow CurRow, NewRow; for (int i = 0; i < _frmComMSCStdProcess.dataTable2.Rows.Count; i++) { CurRow = _frmComMSCStdProcess.dataTable2.Rows[i]; NewRow = dataTable2.NewRow(); if (!_frmComMSCStdProcess.Ids.Contains(CurRow["GIC"].ToString2())) { continue; } for (int j = 0; j < _frmComMSCStdProcess.dataTable2.Columns.Count; j++) { try { if (dataTable2.Columns.Contains(_frmComMSCStdProcess.dataTable2.Columns[j].ColumnName)) { if (_frmComMSCStdProcess.dataTable2.Columns[j].ColumnName == "GIC") { NewRow[_frmComMSCStdProcess.dataTable2.Columns[j].ColumnName] = ultraGrid1.ActiveRow.GetValue("GIC"); } else { NewRow[_frmComMSCStdProcess.dataTable2.Columns[j].ColumnName] = CurRow[j]; } } } catch { } } dataTable2.Rows.Add(NewRow); } ultraGrid1.UpdateData(); ultraGrid1.ActiveRow.ExpandAll(); } } } private int GetGridSelectCount() { foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.Cells["CHC"].Value.ToString() == "True") { return 1; } UltraGridRow[] rows = GridHelper.GetRowsWithKey(row.ChildBands[0], new string[] { "CHC" }, new string[] { "True" }); if (rows.Length > 0) { return 1; } } return 0; } private DataRow GetComBaseStdRowByPk(string stdCode) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getComBaseStdByPk", new object[] { stdCode }, ob); return dt.Rows[0]; } private void DoSave() { string style = "G"; DataRow comBaseStdRow = null; if (CustomInfo == "2") { comBaseStdRow = GetComBaseStdRowByPk(stdCode); if (comBaseStdRow["ACCEPT_BID"].ToString() == "1") { style = "N"; } else { style = "L"; } } if (GetGridSelectCount() == 0) { MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (CustomInfo == "2") { if (comBaseStdRow["ACCEPT_BID"].ToString() == "1" && comBaseStdRow["UNIT_CODE"].ToString() != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && UserInfo.GetUserID() != "longjinhua") { MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能操作!"); return; } } ArrayList baseData = new ArrayList(); ArrayList childData = new ArrayList(); for (int i = 0; i < ultraGrid1.Rows.Count; i++) { UltraGridRow ugr = ultraGrid1.Rows[i]; DataRow rowGic = null; //主表操作 if (Convert.ToBoolean(ugr.Cells["CHC"].Value)) { if (ugr.GetValue("VALIDFLAG") != "") { rowGic = GetMscGicByGic(ugr.GetValue("GIC")); } if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowGic != null) { string[] units = ClsBaseInfo.GetUnitByUserName(rowGic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005"); if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin") { MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!"); ugr.Activate(); return; } } ComMscStdProcessEntity com = GetBaseData(ugr, rowGic); if (com == null) { MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } _gic = com.Gic; baseData.Add(JSONFormat.Format(com)); } //从表操作 if (ugr.HasChild()) { if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("") && !Convert.ToBoolean(ugr.Cells["CHC"].Value)) { MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++) { UltraGridRow ugrc = ugr.ChildBands[0].Rows[j]; if (Convert.ToBoolean(ugrc.Cells["CHC"].Value)) { if (ugr.GetValue("VALIDFLAG") != "") { rowGic = GetMscGicByGic(ugr.GetValue("GIC")); } if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowGic != null) { string[] units = ClsBaseInfo.GetUnitByUserName(rowGic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005"); if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin") { MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!"); ugrc.Activate(); return; } } ComMscStdProcessCEntity comc = GetChildData(ugrc, rowGic); if (comc == null) { MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } _gic = comc.Gic; _isEx = true; childData.Add(JSONFormat.Format(comc)); } } } } if (MessageBox.Show("是否保存选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } if (baseData.Count > 0 || childData.Count > 0) { int count = ServerHelper.SetData("com.steering.pss.qcm.CoreComMscStdProcess.saveMscStdProcess", new Object[] { baseData, childData, style }, this.ob); if (count > 0) { MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DoQuery(); } } } private void DoDeleteOrResume(Boolean flag) { if (GetGridSelectCount() == 0) { MessageBox.Show("请选择记录", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataRow comBaseStdRow = null; if (CustomInfo == "2") { comBaseStdRow = GetComBaseStdRowByPk(stdCode); if (comBaseStdRow["ACCEPT_BID"].ToString() == "1" && comBaseStdRow["UNIT_CODE"].ToString() != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin") { MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能" + (flag ? "作废" : "恢复") + "!"); return; } } ArrayList baseList = new ArrayList(); ArrayList childList = new ArrayList(); foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHC"].Value.ToString())) { DataRow rowGic = null; if (ugr.GetValue("VALIDFLAG") != "") { rowGic = GetMscGicByGic(ugr.GetValue("GIC")); } if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowGic != null) { string[] units = ClsBaseInfo.GetUnitByUserName(rowGic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005"); if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin") { MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!"); ugr.Activate(); return; } } if (CheckAuthority(ugr) == false) { MessageUtil.ShowWarning(errMessage); return; } if (CheckRows(ugr) && flag) { MessageBox.Show("无效记录不能作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (flag && (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("提交审核") || ugr.Cells["VALIDFLAG"].Value.ToString().Equals("已审核"))) { MessageBox.Show("提交审核或已审核记录不能作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!CheckRows(ugr) && !flag) { MessageBox.Show("有效记录不能恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ComMscStdProcessEntity com = new ComMscStdProcessEntity(); com.Gic = ugr.Cells["GIC"].Value.ToString(); com.DeleteName = UserInfo.GetUserName(); baseList.Add(JSONFormat.Format(com)); if (flag && ugr.HasChild()) { if (MessageBox.Show("所对应子记录都将作废!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } foreach (UltraGridRow ugrC in ugr.ChildBands[0].Rows) { ComMscStdProcessCEntity comC = new ComMscStdProcessCEntity(); comC.Gic = ugrC.Cells["GIC"].Value.ToString(); comC.Xh = ugrC.Cells["XH"].Value.ToString(); comC.DeleteName = UserInfo.GetUserName(); childList.Add(JSONFormat.Format(comC)); } } _gic = ugr.Cells["GIC"].Value.ToString(); } //如果主表行拥有子项 if (ugr.HasChild()) { foreach (UltraGridRow ugrC in ugr.ChildBands[0].Rows) { //如果子项被勾选 if (Convert.ToBoolean(ugrC.Cells["CHC"].Value.ToString())) { DataRow rowGic = null; if (ugr.GetValue("VALIDFLAG") != "") { rowGic = GetMscGicByGic(ugr.GetValue("GIC")); } if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowGic != null) { string[] units = ClsBaseInfo.GetUnitByUserName(rowGic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005"); if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin") { MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!"); ugrC.Activate(); return; } } if (CheckAuthority(ugr) == false) { MessageUtil.ShowWarning(errMessage); return; } if (!flag && CheckRows(ugrC.ParentRow) && !Convert.ToBoolean(ugrC.ParentRow.Cells["CHC"].Value)) { MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (CheckRows(ugrC) && flag) { MessageBox.Show("无效记录不能作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!CheckRows(ugrC) && !flag) { MessageBox.Show("有效记录不能恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (flag) { if (ugrC.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "录入状态" && ugrC.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "无效" && ugr.Cells["VALIDFLAG"].Value.ToString() != "") { MessageUtil.ShowWarning("主记录为提交审核或已审核状态时,无法作废"); return; } } ComMscStdProcessCEntity comC = new ComMscStdProcessCEntity(); comC.Gic = ugrC.Cells["GIC"].Value.ToString(); comC.Xh = ugrC.Cells["XH"].Value.ToString(); comC.DeleteName = UserInfo.GetUserName(); childList.Add(JSONFormat.Format(comC)); _gic = ugr.Cells["GIC"].Value.ToString(); _isEx = true; } } } } if (MessageBox.Show("是否" + (flag ? "作废" : "恢复") + "选择记录", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } if (baseList.Count > 0 || childList.Count > 0) { int count = ServerHelper.SetData("com.steering.pss.qcm.CoreComMscStdProcess.deleteOrResume", new Object[] { baseList, childList, flag }, this.ob); if (count > 0) { DoQuery(); MessageBox.Show((flag ? "作废" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } } } /// /// 行记录是否有效 /// /// /// private bool CheckRows(UltraGridRow ugr) { if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("无效")) return true; else return false; } private DataTable GetMscTabByMsc(string msc) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.getComMscByMsc", new object[] { msc }, ob); return dt; } private string GetMscByGic(string gic) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getComGicByGic", new object[] { gic }, ob); if (dt.Rows.Count > 0) { return dt.Rows[0]["MSC"].ToString(); } return ""; } /// /// 通过主键查询加工主表 /// /// /// private DataRow GetMscGicByGic(string gic) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getComGicByGic", new object[] { gic }, ob); if (dt.Rows.Count == 0) { return null; } else { return dt.Rows[0]; } } private bool CheckAuthority(UltraGridRow row) { if (CustomInfo == "1") { string mscOld; if (row.GetValue("VALIDFLAG") != "") { mscOld = GetMscByGic(row.GetValue("GIC")); } else { mscOld = row.HasParent() ? row.ParentRow.GetValue("MSC") : row.GetValue("MSC"); } DataTable dtMsc = GetMscTabByMsc(mscOld); //if (dtMsc.Rows[0]["UNIT_CODE"].ToString() != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin") //{ // errMessage = "该条记录对应的冶金规范是[" + dtMsc.Rows[0]["UNIT_DESC"].ToString() + "]科室维护的,您没有权限!"; // row.Activate(); // return false; //} } return true; } /// /// 主项数据 /// /// UltraGridRow /// private ComMscStdProcessEntity GetBaseData(UltraGridRow ugr, DataRow rowGic) { ComMscStdProcessEntity com = new ComMscStdProcessEntity(); com.Gic = ugr.Cells["GIC"].Value.ToString().Trim(); com.Psc = ugr.Cells["PSC"].Value.ToString().Trim(); com.Msc = ugr.Cells["MSC"].Value.ToString(); if (CustomInfo == "1" && com.Msc.Equals("")) { errMessage = "请选择冶金规范码"; return null; } if (CheckAuthority(ugr) == false) return null; com.Stdstyle = ugr.Cells["STDSTYLE"].Value.ToString().Trim(); if (com.Stdstyle.Equals("订货标准")) com.Stdstyle = "G"; else if (com.Stdstyle.Equals("协议标准")) com.Stdstyle = "X"; else if (com.Stdstyle.Equals("Alpha")) com.Stdstyle = "K"; else if (com.Stdstyle.Equals("内控")) com.Stdstyle = "N"; else if (com.Stdstyle.Equals("试验标准")) com.Stdstyle = "S"; else com.Stdstyle = "P"; com.StdCodeNk = ugr.Cells["STD_CODE_NK"].Value.ToString().Trim(); com.StdNameNk = ugr.Cells["STD_NAME_NK"].Value.ToString().Trim(); if (CustomInfo != "1" && com.StdNameNk.Equals("")) { errMessage = "请选择标准名称"; return null; } com.ProcessCdoe = ugr.Cells["PROCESS_CDOE"].Value.ToString().Trim(); com.ProcessDesc = ugr.Cells["PROCESS_DESC"].Value.ToString().Trim(); com.CreateName = UserInfo.GetUserName(); com.CreateTime = ugr.Cells["CREATE_TIME"].Value.ToString().Trim(); com.UpdateName = UserInfo.GetUserName(); com.Memo = ugr.Cells["MEMO"].Value.ToString(); com.ProducHead = ugr.GetValue("PRODUC_HEAD"); com.Validflag = ugr.Cells["VALIDFLAG"].Value.ToString().Trim(); com.ModelCode = ugr.Cells["MODEL_CODE"].Value.ToString(); com.ModelDesc = ugr.Cells["MODEL_DESC"].Value.ToString(); com.Validflag = ugr.Cells["VALIDFLAG"].Value.ToString(); com.CodeJg = codeJg == "DefaultValue" ? "" : codeJg; com.SteelcodeNk = ugr.GetValue("STEELCODE_NK"); com.SteelnameNk = ugr.GetValue("STEELNAME_NK"); com.ModelCodeNk = ugr.GetValue("MODEL_CODE_NK"); com.ModelDescNk = ugr.GetValue("MODEL_DESC_NK"); com.ProduccodeNk = ugr.GetValue("PRODUCCODE_NK"); com.ProducnameNk = ugr.GetValue("PRODUCNAME_NK"); if (rowGic != null && (rowGic["VALIDFLAG"].ToString() == "2" || rowGic["VALIDFLAG"].ToString() == "3")) { errMessage = "提交审核或已审核记录不能保存"; return null; } //if (CustomInfo == "2" && com.ProduccodeNk == "") //{ // errMessage = "请选择品名!"; // return null; //} return com; } /// /// 从表数据 /// /// UltraGridRow /// private ComMscStdProcessCEntity GetChildData(UltraGridRow ugr, DataRow rowGic) { if (CheckAuthority(ugr) == false) return null; if (rowGic != null && (rowGic["VALIDFLAG"].ToString() == "2" || rowGic["VALIDFLAG"].ToString() == "3")) { errMessage = "主记录为提交审核或已审核状态时,无法修改"; return null; } string gic = ugr.Cells["GIC"].Value.ToString().Trim(); string xh = ugr.Cells["XH"].Value.ToString().Trim(); string stationcode = ugr.Cells["STATION_CODE"].Value.ToString().Trim(); if (stationcode.Equals("")) { errMessage = "请选择工序点名称"; return null; } //string processcode = ugr.Cells["PROCESS_CDOE"].Value.ToString().Trim(); //if (processcode.Equals("")) //{ // errMessage = "请选择工序名称"; // return null; //} //string processcodec = ugr.Cells["PROCESS_CDOE_C"].Value.ToString().Trim(); //if (processcodec.Equals("")) //{ // errMessage = "请选择二级工序名称"; // return null; //} string valueText = ugr.Cells["VALUE_TEXT"].Value.ToString(); string valueNum = ugr.Cells["VALUE_NUM"].Value.ToString(); if (valueText == "" && valueNum == "") { errMessage = "文本值和数值必须输入一个"; return null; } if (valueText != "" && valueNum != "") { errMessage = "文本值和数值只能输入一个"; return null; } ComMscStdProcessCEntity com = new ComMscStdProcessCEntity(); com.Gic = gic; com.Xh = xh; com.StationCode = stationcode; com.StationDesc = ugr.Cells["STATION_CODE"].Text; com.ProcessCdoe = ugr.Cells["PROCESS_CDOE"].Value.ToString().Trim(); com.ProcessDesc = ugr.Cells["PROCESS_DESC"].Value.ToString(); com.ProcessCdoeC = ugr.Cells["PROCESS_CDOE"].Value.ToString().Trim(); com.ProcessDescC = ugr.Cells["PROCESS_DESC_C"].Value.ToString(); com.ValueText = ugr.Cells["VALUE_TEXT"].Value.ToString(); com.ValueNum = ugr.Cells["VALUE_NUM"].Value.ToString(); com.ValueMemo = ugr.Cells["VALUE_MEMO"].Value.ToString(); com.CreateName = this.UserInfo.GetUserName(); com.UpdateName = this.UserInfo.GetUserName(); com.Memo = ugr.Cells["MEMO"].Value.ToString(); com.Validflag = ugr.Cells["VALIDFLAG"].Value.ToString(); com.GroupSeq = ugr.Cells["GROUP_SEQ"].Value.ToString(); com.MinD = ugr.Cells["MIN_D"].Value.ToString(); com.MaxD = ugr.Cells["MAX_D"].Value.ToString(); com.MinH = ugr.Cells["MIN_H"].Value.ToString(); com.MaxH = ugr.Cells["MAX_H"].Value.ToString(); com.MinDSign = ugr.Cells["MIN_D_SIGN"].Value.ToString(); com.MaxDSign = ugr.Cells["MAX_D_SIGN"].Value.ToString(); com.MinHSign = ugr.Cells["MIN_H_SIGN"].Value.ToString(); com.MaxHSign = ugr.Cells["MAX_H_SIGN"].Value.ToString(); if (CustomInfo == "2") { if (com.MinDSign != "" && com.MinD == "") { errMessage = "请输入外径下限值!"; ugr.SetCellActive("MIN_D"); return null; } else if (com.MinDSign == "" && com.MinD != "") { errMessage = "请选择外径下限符号!"; ugr.SetCellActive("MIN_D_SIGN"); return null; } else if (com.MaxDSign != "" && com.MaxD == "") { errMessage = "请输入外径上限值!"; ugr.SetCellActive("MAX_D"); return null; } else if (com.MaxDSign == "" && com.MaxD != "") { errMessage = "请选择外径上限符号!"; ugr.SetCellActive("MAX_D_SIGN"); return null; } else if (com.MinHSign != "" && com.MinH == "") { errMessage = "请输入壁厚下限值!"; ugr.SetCellActive("MIN_H"); return null; } else if (com.MinHSign == "" && com.MinH != "") { errMessage = "请选择壁厚下限符号!"; ugr.SetCellActive("MIN_H_SIGN"); return null; } else if (com.MaxHSign != "" && com.MaxH == "") { errMessage = "请输入壁厚上限值!"; ugr.SetCellActive("MAX_H"); return null; } else if (com.MaxHSign == "" && com.MaxH != "") { errMessage = "请选择壁厚上限符号!"; ugr.SetCellActive("MAX_H_SIGN"); return null; } else if (com.MinDSign == "=" && com.MaxDSign != "") { errMessage = "外径下限符号为等号时,不能存在外径上限符号和外径上限值!"; ugr.SetCellActive("MAX_D_SIGN"); return null; } else if (com.MinHSign == "=" && com.MaxHSign != "") { errMessage = "壁厚下限符号为等号时,不能存在壁厚上限符号和壁厚上限值!"; ugr.SetCellActive("MAX_H_SIGN"); return null; } else if (com.MinD != "" && com.MaxD != "" && decimal.Parse(com.MinD) >= decimal.Parse(com.MaxD)) { errMessage = "外径下限值不能大于等于外径上限值!"; ugr.SetCellActive("MIN_D"); return null; } else if (com.MinH != "" && com.MaxH != "" && decimal.Parse(com.MinH) >= decimal.Parse(com.MaxH)) { errMessage = "壁厚下限值不能大于等于壁厚上限值!"; ugr.SetCellActive("MIN_H"); return null; } } return com; } private void ultraCheckStd_CheckedChanged(object sender, EventArgs e) { if (ultraCheckStd.Checked) { ultraTextStd.ReadOnly = false; } else { ultraTextStd.ReadOnly = true; } } private void ultraCheckMSC_CheckedChanged(object sender, EventArgs e) { if (ultraCheckMSC.Checked) { ultraTextMSC.ReadOnly = false; } else { ultraTextMSC.ReadOnly = true; } } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (isPasting) { e.Row.SetValue("CHC", "True"); } } /// /// 2015-07-15 PDY /// private void InnerChange() { ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_CDOE"].CellActivation = Activation.ActivateOnly; ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].CellActivation = Activation.ActivateOnly; ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC"].Hidden = true; } private void ultraTextEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (ultraGrid1.ActiveCell.Column.Key == "PROCESS_DESC") { string processCodes = ultraGrid1.ActiveRow.GetValue("PROCESS_CDOE"); ChoiceProcessPopup choiceProcessPopup = new ChoiceProcessPopup(processCodes, this.ob); if (choiceProcessPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getProcessByStdCode", new object[] { this.stdCode }, ob); string stdProcessCodes = dt.Rows[0]["PROCESS_CODE"].ToString(); string[] processCodesAry = choiceProcessPopup.ProcessCodes.Split(','); for (int i = 0; i < processCodesAry.Length; i++) { if (!stdProcessCodes.Contains(processCodesAry[i].Trim())) { DataTable dtBaseProcess = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getProcessDescByCode", new object[] { processCodesAry[i].Trim() }, ob); string processDesc = dtBaseProcess.Rows[0]["PROCESS_DESC"].ToString(); MessageUtil.ShowWarning("该标准下不包含工序" + processDesc + ", 不能选择!"); return; } } ultraGrid1.ActiveRow.SetValue("PROCESS_CDOE", choiceProcessPopup.ProcessCodes); ultraGrid1.ActiveRow.SetValue("PROCESS_DESC", choiceProcessPopup.ProcessDescs); } } else if (ultraGrid1.ActiveCell.Column.Key == "STEELNAME_NK") { FrmRepSteel frmSteel = new FrmRepSteel(); frmSteel.Ob1 = this.ob; frmSteel.Code = ultraGrid1.ActiveRow.GetValue("STEELCODE_NK"); if (frmSteel.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("STEELCODE_NK", frmSteel.Code); ultraGrid1.ActiveRow.SetValue("STEELNAME_NK", frmSteel.Desc); } } else if (ultraGrid1.ActiveCell.Column.Key == "MODEL_DESC_NK") { FrmModel frmMode = new FrmModel(); frmMode.FrmOb = this.ob; frmMode.Code = ultraGrid1.ActiveRow.GetValue("MODEL_CODE_NK"); frmMode.Desc = ultraGrid1.ActiveRow.GetValue("MODEL_DESC_NK"); if (frmMode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("MODEL_CODE_NK", frmMode.Code); ultraGrid1.ActiveRow.SetValue("MODEL_DESC_NK", frmMode.Desc); } } else if (ultraGrid1.ActiveCell.Column.Key == "PRODUCNAME_NK") { PopupProductName popupProductName = new PopupProductName( ultraGrid1.ActiveRow.GetValue("PRODUCCODE_NK"), ob); if (popupProductName.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("PRODUCCODE_NK", popupProductName.ProductCodes); ultraGrid1.ActiveRow.SetValue("PRODUCNAME_NK", popupProductName.ProductNames); } } } private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows) { ugr.Cells["CHC"].Value = true; Activation activation = Activation.ActivateOnly; if (Convert.ToBoolean(ugr.Cells["CHC"].Value)) { activation = Activation.AllowEdit; //isSelect += 1; } //else //isSelect -= 1; CellsCollection cells = ugr.Cells; for (int i = 0; i < cells.Count; i++) { if (!cells[i].Column.Key.Equals("CHC")) { ugr.Cells[i].Activation = activation; } } } } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "查询": DoQuery1(); break; case "确认选择": Choice(); break; } } private void DoQuery1() { //查询交付标准、内控标准或者Alpha ArrayList QueryConditon = GetQueryData(); //主表查询 dataTable2.Clear(); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getComProcessNK", new Object[] { msc}, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true); //从表查询 DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getComProcessNKC", new Object[] { msc }, this.ob); GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true); //不同颜色区分是否有效数据 QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效"); QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1); UltraGridBand bc = ultraGrid1.DisplayLayout.Bands[0]; UltraGridBand bcC = ultraGrid1.DisplayLayout.Bands[1]; UltraGridColumn[] col = new UltraGridColumn[] { bc.Columns["MEMO"], bc.Columns["MSC"], bc.Columns["MODEL_DESC"] }; GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col); //isSelect = 0; //定位行和展开行 UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "GIC" }, new string[] { _gic }); if (rows1.Length > 0) { rows1[0].Activate(); if (_isEx) rows1[0].ExpandAll(); } _isEx = false; _gic = ""; dataTable1.AcceptChanges(); dataTable2.AcceptChanges(); //清空复制数据 //_copyedRows.Clear(); } private DataRow[] rows; public DataRow[] Rows { get { return rows; } set { rows = value; } } List ids; public List Ids { get { return ids; } set { ids = value; } } private void Choice() { ultraGrid1.UpdateData(); int count = ultraGrid1.Rows.Where(a => Convert.ToBoolean(a.GetValue("CHC"))).Count(); if (count > 1) { MessageUtil.ShowTips("请选择一条数据!"); return; } foreach (UltraGridRow ugr in ultraGrid1.Rows.Where(a => Convert.ToBoolean(a.GetValue("CHC")))) { //从表操作 if (ugr.HasChild()) { Ids = ugr.ChildBands[0].Rows.Select(p => p.GetValue("GIC")).ToList(); Rows = dataTable2.Select("GIC IN ('" + string.Join("','", Ids) + "')"); } } this.DialogResult = System.Windows.Forms.DialogResult.OK; } } }