| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645 |
- 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();
- }
- /// <summary>
- /// 复制
- /// </summary>
- 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];
- }
- }
- /// <summary>
- /// 粘贴
- /// </summary>
- 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<string> notCopyColumns = new List<string>();
- 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();
- }
- /// <summary>
- /// 取消分组
- /// </summary>
- 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();
- }
- }
- /// <summary>
- /// 查询条件
- /// </summary>
- /// <returns></returns>
- 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);
- }
- }
- }
- /// <summary>
- /// 行记录是否有效
- /// </summary>
- /// <param name="ugr"></param>
- /// <returns></returns>
- 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 "";
- }
- /// <summary>
- /// 通过主键查询加工主表
- /// </summary>
- /// <param name="gic"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 主项数据
- /// </summary>
- /// <param name="ugr">UltraGridRow</param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 从表数据
- /// </summary>
- /// <param name="ugr">UltraGridRow</param>
- /// <returns></returns>
- 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");
- }
- }
- /// <summary>
- /// 2015-07-15 PDY
- /// </summary>
- 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<string> ids;
- public List<string> 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;
- }
- }
- }
|