| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180 |
- 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.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- /// <summary>
- /// 公差标准管理
- /// </summary>
- public partial class FrmTolerancesStandard : FrmBase
- {
- private bool isPasting = false;
- /// <summary>
- /// 公差索引号
- /// </summary>
- private string sic = "";
- public string Sic
- {
- get { return sic; }
- set { sic = 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 string errMessage = "";
- //用于展开项和定位到操作项
- private string _sic = "";
- private bool _isEx = false;
- //用于判断是否勾选
- //public int isSelect = 0;
- //初始下拉框
- private UltraComboEditor[] ultras = new UltraComboEditor[9];
- public FrmTolerancesStandard()
- {
- IsLoadUserView = true;
- InitializeComponent();
- ExceptionHelper.RegistException();
- }
- public void PopupLoad(string customInfo, OpeBase ob)
- {
- this.CustomInfo = customInfo;
- this.ob = ob;
- FrmTolerancesStandard_Load(null, null);
- }
- /// <summary>
- /// 登入初始化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FrmTolerancesStandard_Load(object sender, EventArgs e)
- {
- HideColumn();
- InitDrop();
- }
- public void PopupRefresh()
- {
- UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
- if (CustomInfo == "1")
- { //冶金规范码
- QcmBaseQuery.NitializeMSC(ultras[0], false, this.ob, msc);
- QcmBaseQuery.BindColumn(ultras[0], "MSC", ugb);
- }
- }
- /// <summary>
- /// 初始化下拉框
- /// </summary>
- private void InitDrop()
- {
- for (int i = 0; i < ultras.Length; i++)
- {
- ultras[i] = new UltraComboEditor();
- Controls.Add(ultras[i]);
- ultras[i].Visible = false;
- ultras[i].DropDownListWidth = -1;
- }
- //主表
- UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
- //从表
- UltraGridBand ugbC = ultraGrid1.DisplayLayout.Bands[1];
- if (CustomInfo == "1")
- { //冶金规范码
- QcmBaseQuery.NitializeMSC(ultras[0], false, this.ob, msc);
- QcmBaseQuery.BindColumn(ultras[0], "MSC", ugb);
- }
- //下限符号
- QcmBaseQuery.NitializeSignMin(ultras[1]);
- //公差约束项一下限符号
- QcmBaseQuery.BindColumn(ultras[1], "ZMIN_SIGN", ugbC);
- //公差约束项二下限符号
- QcmBaseQuery.BindColumn(ultras[1], "CMIN_SIGN", ugbC);
- //公差约束项三下限符号
- QcmBaseQuery.BindColumn(ultras[1], "SMIN_SIGN", ugbC);
- //上限符号
- QcmBaseQuery.NitializeSignMax(ultras[2]);
- //公差约束项一上限符号
- QcmBaseQuery.BindColumn(ultras[2], "ZMAX_SIGN", ugbC);
- //公差约束项二上限符号
- QcmBaseQuery.BindColumn(ultras[2], "CMAX_SIGN", ugbC);
- //公差约束项三上限符号
- QcmBaseQuery.BindColumn(ultras[2], "SMAX_SIGN", ugbC);
- //公差项
- QcmBaseQuery.NitializeTolerance(ultras[3], false, this.ob);
- QcmBaseQuery.BindColumn(ultras[3], "BIAS_CODE", ugbC);
- //精度等级
- QcmBaseQuery.NitializePrecision(ultras[4], true, this.ob);
- QcmBaseQuery.BindColumn(ultras[4], "LV", ugbC);
- if (CustomInfo != "1")
- { //标准名称
- //标准名称
- if (CustomInfo == "2")
- QcmBaseQuery.NitializeInnerStandard(ultras[5], false, this.ob);
- else if (CustomInfo == "3")
- QcmBaseQuery.NitializeAlphaStandard(ultras[5], false, this.ob);
- else
- QcmBaseQuery.NitializeOtherStandard(ultras[5], false, this.ob);
- QcmBaseQuery.BindColumn(ultras[5], "STD_CODE", ugb);
- //工序
- QcmBaseQuery.NitializeProcess(ultras[6], true, this.ob);
- QcmBaseQuery.BindColumn(ultras[6], "PROCESS_CODE", ugb);
- }
- //公差约束项
- QcmBaseQuery.NitializeToleranceRestrain(ultras[7], true, this.ob);
- QcmBaseQuery.BindColumn(ultras[7], "BIAS_CODE_Z", ugbC);
- QcmBaseQuery.BindColumn(ultras[7], "BIAS_CODE_C", ugbC);
- QcmBaseQuery.BindColumn(ultras[7], "BIAS_CODE_S", ugbC);
- QcmBaseQuery.NitializeProductBigType(ultras[8], false, ob);
- QcmBaseQuery.BindColumn(ultras[8], "PRODUC_HEAD", ugb);
- ClsBaseInfo.SetComboItemHeight(ultras[8]);
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- this.DoQuery();
- break;
- case "Save":
- this.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":
- InitDrop();
- break;
- case "Group":
- Group(true);
- break;
- case "Cancel":
- Group(false);
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <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("Sic", 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("Sic");
- 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 sic = "";
- UltraGridRow rowParent;
- if (ultraGrid1.ActiveRow.HasParent())
- {
- //if (ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows.Count > 0)
- //{
- // MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!");
- // return;
- //}
- sic = ultraGrid1.ActiveRow.ParentRow.GetValue("SIC");
- rowParent = ultraGrid1.ActiveRow.ParentRow;
- }
- else
- {
- //if (ultraGrid1.ActiveRow.ChildBands[0].Rows.Count > 0)
- //{
- // MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!");
- // return;
- //}
- sic = ultraGrid1.GetActiveRowValue("SIC");
- 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", "SIC", "MSC", "PSC_DESC", "PSC", "STD_CODE", "STD_NAME", "STDSTYLE",
- "STEELNAME", "PRODUCNAME", "PROCESS_CODE", "STD_STYLE_DESC", "PRODUCCODE_NK", "PRODUCNAME_NK",
- "PROCESS_CODE", "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;
- if (notCopyColumns.Contains(columnName) == true) continue;
- tempRow[columnName] = row[columnName];
- }
- tempRow["SIC"] = sic;
- dataTable2.Rows.Add(tempRow);
- }
- dataTable2.EndInit();
- if (copyTab.Rows.Count > 0 && ultraGrid1.ActiveRow != null)
- {
- ultraGrid1.ActiveRow.ExpandAll();
- }
- ultraGrid1.UpdateData();
- }
- /// <summary>
- /// 根据内控、交付标准分别隐藏不同列
- /// </summary>
- private void HideColumn()
- {
- if (CustomInfo == "1")
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPECIAL_PATH"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_DESC"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"].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;
- }
- if (CustomInfo == "2" || CustomInfo == "4")
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true;
- if (CustomInfo == "2")
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"].Header.Caption = "内控管理编号";
- }
- this.ultraCheckMSC.Visible = false;
- this.TextMSC.Visible = false;
- InnerChange();
- }
- if (CustomInfo == "3")
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPECIAL_PATH"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true;
- this.ultraCheckMSC.Visible = false;
- this.TextMSC.Visible = false;
- 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;
- }
- }
- /// <summary>
- /// 查询条件
- /// </summary>
- /// <returns></returns>
- private ArrayList QueryCodition()
- {
- ArrayList list = new ArrayList();
- //标准名称
- string stand = "";
- if (this.ultraCheckStand.Checked)
- stand = TextStd.Text.Trim();
- list.Add(stand);
- //冶金规范码
- string msc = "";
- if (CustomInfo == "1")
- {
- if (ultraCheckMSC.Checked)
- msc = TextMSC.Text.Trim();
- }
- list.Add(msc);
- //是否包含无效
- string valid = "1";
- if (chkValid.Checked)
- valid = "0";
- list.Add(valid);
- list.Add(stdCode);
- return list;
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery()
- {
- ArrayList list = QueryCodition();
- //主表查询
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getCoreTolerances",
- new Object[] { list, CustomInfo, sic, msc, codeJg, producCodeNk, steelcodeNk, processCode, modelCode }, this.ob);
- dataTable2.Clear();
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //从表查询
- string valid = "1";
- if (chkValid.Checked)
- valid = "0";
- DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getCoreTolerancesC",
- new Object[] { CustomInfo, valid, stdCode, msc, codeJg, producCodeNk, steelcodeNk, processCode, modelCode }, this.ob);
- dt1 = QcmBaseCommon.FilterTable(dt, dt1, "SIC");
- GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
- //不同颜色区分是否有效数据
- QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
- //isSelect = 0;
- QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
- UltraGridColumn[] col = new UltraGridColumn[] {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STDMEMO"],
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"],
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"],
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"],
- this.ultraGrid1.DisplayLayout.Bands[1].Columns["BIAS_CODE"]};
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
- //展开或者定位
- UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "SIC" }, new string[] { _sic });
- if (rows1.Length > 0)
- {
- rows1[0].Activate();
- if (_isEx)
- rows1[0].ExpandAll();
- }
- _isEx = false;
- _sic = "";
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- ugr.Cells["CHKNK"].Value = "选择";
- }
- dataTable1.AcceptChanges();
- dataTable2.AcceptChanges();
- //清空复制数据
- //_copyedRows.Clear();
- }
- private void DoQuery1()
- {
- ArrayList list = QueryCodition();
- //主表查询
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getComSpecNK",
- new Object[] { msc }, this.ob);
- dataTable2.Clear();
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //从表查询
- string valid = "1";
- if (chkValid.Checked)
- valid = "0";
- DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getComSpecNKC",
- new Object[] { msc }, this.ob);
- dt1 = QcmBaseCommon.FilterTable(dt, dt1, "SIC");
- GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
- //不同颜色区分是否有效数据
- QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
- //isSelect = 0;
- QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
- UltraGridColumn[] col = new UltraGridColumn[] {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STDMEMO"],
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"],
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"],
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"],
- this.ultraGrid1.DisplayLayout.Bands[1].Columns["BIAS_CODE"]};
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
- //展开或者定位
- UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "SIC" }, new string[] { _sic });
- if (rows1.Length > 0)
- {
- rows1[0].Activate();
- if (_isEx)
- rows1[0].ExpandAll();
- }
- _isEx = false;
- _sic = "";
- dataTable1.AcceptChanges();
- dataTable2.AcceptChanges();
- //清空复制数据
- //_copyedRows.Clear();
- }
- public void QueryPurchaseAgreement(string stdCodeNk)
- {
- dataTable2.Clear();
- dataTable1.Clear();
- DataTable dtP = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getPurchaseAgreementSic",
- new object[] { stdCodeNk }, ob);
- GridHelper.CopyDataToDatatable(ref dtP, ref this.dataTable1, true);
- DataTable dtC = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getPurchaseAgreementSpec",
- new object[] { stdCodeNk }, ob);
- GridHelper.CopyDataToDatatable(ref dtC, ref this.dataTable2, true);
- QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
- QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
- }
- 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];
- }
- /// <summary>
- /// 保存
- /// </summary>
- private void DoSave()
- {
- ultraGrid1.UpdateData();
- if (GetGridSelectCount() == 0)
- {
- MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- 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" && UserInfo.GetUserID() != "longjinhua" && !"002023005003".Equals(UserInfo.GetDeptid()))
- {
- MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能操作!");
- return;
- }
- }
- string style = "G";
- if (CustomInfo == "2")
- {
- if (comBaseStdRow["ACCEPT_BID"].ToString() == "1")
- {
- style = "N";
- }
- else
- {
- style = "L";
- }
- }
- if (CustomInfo == "3")
- style = "K";
- if (CustomInfo == "4")
- style = "S";
- ArrayList baseList = new ArrayList();
- ArrayList childList = new ArrayList();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- UltraGridRow ugr = ultraGrid1.Rows[i];//主项
- DataRow rowSic = null;
- if (Convert.ToBoolean(ugr.Cells["CHC"].Value))//是否选择
- {
- if (ugr.GetValue("VALIDFLAG") != "")
- {
- rowSic = GetMscSicBySic(ugr.GetValue("SIC"));
- }
- if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowSic != null)
- {
- string[] units = ClsBaseInfo.GetUnitByUserName(rowSic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
- if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && !"002023005003".Equals(UserInfo.GetDeptid()))
- {
- MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
- ugr.Activate();
- return;
- }
- }
- SpecObject com = GetMasterData(ugr, rowSic);
- if (com == null)
- {
- MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- baseList.Add(JSONFormat.Format(com));
- _sic = com.Sic;
- }
- if (ugr.HasChild()) //子项
- {
- if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("") && !Convert.ToBoolean(ugr.Cells["CHC"].Value))
- {
- MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++)
- {
- UltraGridRow ugrChild = ugr.ChildBands[0].Rows[j];
- if (Convert.ToBoolean(ugrChild.Cells["CHC"].Value))
- {
- if (ugr.GetValue("VALIDFLAG") != "")
- {
- rowSic = GetMscSicBySic(ugr.GetValue("SIC"));
- }
- if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowSic != null)
- {
- string[] units = ClsBaseInfo.GetUnitByUserName(rowSic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
- if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && !"002023005003".Equals(UserInfo.GetDeptid()))
- {
- MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
- ugrChild.Activate();
- return;
- }
- }
- SpecCObject comC = GetFromData(ugrChild, rowSic);
- if (comC == null)
- {
- MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- childList.Add(JSONFormat.Format(comC));
- _sic = comC.Sic;
- _isEx = true;
- }
- }
- }
- }
- if (MessageBox.Show("是否保存选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- if (baseList.Count > 0 || childList.Count > 0)
- {
- int count = ServerHelper.SetData("com.steering.pss.qcm.CoreTolerances.saveCoreTolerances",
- new Object[] { baseList, childList, style }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- DoQuery();
- }
- }
- }
- /// <summary>
- /// 删除或者恢复
- /// </summary>
- /// <param name="flag">true 删除 false 恢复</param>
- private void DoDeleteOrResume(Boolean flag)
- {
- ultraGrid1.UpdateData();
- if (GetGridSelectCount() == 0)
- {
- MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- 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();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- UltraGridRow ugr = ultraGrid1.Rows[i];
- if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
- {
- DataRow rowSic = null;
- if (ugr.GetValue("VALIDFLAG") != "")
- {
- rowSic = GetMscSicBySic(ugr.GetValue("SIC"));
- }
- if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowSic != null)
- {
- string[] units = ClsBaseInfo.GetUnitByUserName(rowSic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
- if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && !"002023005003".Equals(UserInfo.GetDeptid()))
- {
- MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
- ugr.Activate();
- return;
- }
- }
- if (CheckAuthority(ugr) == false)
- {
- MessageUtil.ShowWarning(errMessage);
- return;
- }
- if (ugr.Cells["VALIDFLAG"].Value.Equals("无效") && flag)
- {
- MessageBox.Show("无效记录不能作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (flag && (ugr.Cells["VALIDFLAG"].Value.Equals("提交审核") || ugr.Cells["VALIDFLAG"].Value.Equals("已审核")))
- {
- MessageBox.Show("提交审核或已审核记录不能作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ugr.Cells["VALIDFLAG"].Value.Equals("有效") && !flag)
- {
- MessageBox.Show("有效记录不能恢复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ugr.HasChild() && flag)
- {
- if (MessageBox.Show("对应子记录将全部作废!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- foreach (UltraGridRow ugrc in ugr.ChildBands[0].Rows)
- {
- SpecCObject comc = new SpecCObject();
- comc.Sic = ugrc.Cells["SIC"].Value.ToString();
- comc.DeleteName = UserInfo.GetUserName();
- comc.IndexSeq = ugrc.Cells["INDEX_SEQ"].Value.ToString();
- childList.Add(JSONFormat.Format(comc));
- }
- }
- SpecObject com = new SpecObject();
- com.Sic = ugr.Cells["SIC"].Value.ToString();
- com.DeleteName = UserInfo.GetUserName();
- baseList.Add(JSONFormat.Format(com));
- _sic = com.Sic;
- }
- if (ugr.HasChild())
- {
- 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))
- {
- DataRow rowSic = null;
- if (ugr.GetValue("VALIDFLAG") != "")
- {
- rowSic = GetMscSicBySic(ugr.GetValue("SIC"));
- }
- if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowSic != null)
- {
- string[] units = ClsBaseInfo.GetUnitByUserName(rowSic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
- if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && !"002023005003".Equals(UserInfo.GetDeptid()))
- {
- MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
- ugrc.Activate();
- return;
- }
- }
- if (CheckAuthority(ugrc) == false)
- {
- MessageUtil.ShowWarning(errMessage);
- return;
- }
- if (!flag && ugrc.ParentRow.Cells["VALIDFLAG"].Value.Equals("无效") && !Convert.ToBoolean(ugrc.ParentRow.Cells["CHC"].Value))
- {
- MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ugrc.Cells["VALIDFLAG"].Value.Equals("无效") && flag)
- {
- MessageBox.Show("无效记录不能作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ugrc.Cells["VALIDFLAG"].Value.Equals("有效") && !flag)
- {
- MessageBox.Show("有效记录不能恢复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (flag)
- {
- if (ugrc.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "录入状态"
- && ugrc.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "无效"
- && ugr.Cells["VALIDFLAG"].Value.ToString() != "")
- {
- MessageUtil.ShowWarning("主记录为提交审核或已审核状态时,无法作废");
- return;
- }
- }
- SpecCObject comc = new SpecCObject();
- comc.Sic = ugrc.Cells["SIC"].Value.ToString();
- comc.DeleteName = UserInfo.GetUserName();
- comc.IndexSeq = ugrc.Cells["INDEX_SEQ"].Value.ToString();
- childList.Add(JSONFormat.Format(comc));
- _sic = comc.Sic;
- _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.CoreTolerances.deleteOrResume", new Object[] { baseList, childList, flag }, this.ob);
- if (count > 0)
- {
- DoQuery();
- MessageBox.Show((flag ? "作废" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- /// <summary>
- /// 分组
- /// </summary>
- private void Group(bool isGroup)
- {
- string str = isGroup ? "分组" : "取消分组";
- ArrayList list = new ArrayList();
- int cnt = 0;
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.GetValue("CHC") == "True")
- {
- MessageUtil.ShowWarning("不能对主记录进行" + str + "!");
- return;
- }
- ArrayList listSub = new ArrayList();
- listSub.Add(row.GetValue("SIC"));
- string strIndexs = "''";
- foreach (UltraGridRow row2 in row.ChildBands[0].Rows)
- {
- if (row2.GetValue("CHC") != "True") continue;
- if (row2.GetValue("CREATE_TIME") == "")
- {
- MessageUtil.ShowWarning("您选择的分组记录中存在未保存的项,请先保存后再" + str + "!");
- return;
- }
- if (row2.GetValue("VALIDFLAG") == "无效")
- {
- MessageUtil.ShowWarning("您选择的分组记录中存在无效数据,无法" + str + "!");
- return;
- }
- strIndexs += ", '" + row2.GetValue("INDEX_SEQ") + "'";
- cnt++;
- }
- strIndexs = strIndexs.Substring(1);
- strIndexs = strIndexs.Substring(0, strIndexs.Length - 1);
- listSub.Add(strIndexs);
- if (strIndexs != "")
- {
- _sic = row.GetValue("SIC");
- _isEx = true;
- list.Add(listSub);
- }
- }
- if (cnt == 0)
- {
- MessageUtil.ShowWarning("请选择您要" + str + "的记录!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认" + str + "!") == DialogResult.No)
- {
- return;
- }
- ServerHelper.SetData("com.steering.pss.qcm.CoreTolerances.group",
- new object[] { list, isGroup }, this.ob);
- MessageUtil.ShowTips(str + "成功!");
- DoQuery();
- }
- /// <summary>
- /// 增加一行事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
- string style = "G";
- if (CustomInfo == "2")
- style = "N";
- if (CustomInfo == "3")
- style = "K";
- if (CustomInfo == "4")
- style = "S";
- if (!ugr.HasParent()) //主表自动填充主键(成分索引号)
- {
- string sic = "";
- int temp = 0;
- for (int i = 0; i < ultraGrid1.Rows.Count - 1; i++)
- {
- string str = ultraGrid1.Rows[i].Cells["SIC"].Value.ToString().Substring(4, 6);
- if (Convert.ToInt32(str) > temp)
- temp = Convert.ToInt32(str);
- }
- sic = "SIC" + style + string.Format("{0:000000}", temp + 1);
- ugr.Cells["SIC"].Value = sic;
- }
- //从表自动填充序号
- if (ugr.HasParent())
- {
- int index = 0;
- string cic = ugr.Cells["SIC"].Value.ToString();
- foreach (UltraGridRow ug in ultraGrid1.Rows)
- {
- if (ug.Cells["SIC"].Value.ToString().Equals(cic))
- {
- for (int i = 0; i < ug.ChildBands[0].Rows.Count - 1; i++)
- {
- int indexSeq = Convert.ToInt32(ug.ChildBands[0].Rows[i].Cells["INDEX_SEQ"].Value.ToString());
- if (indexSeq > index)
- index = indexSeq;
- }
- }
- }
- ugr.Cells["INDEX_SEQ"].Value = index + 1;
- ugr.Cells["ISCHECK"].Value = true;
- ugr.Cells["STD_MIN_FORMULA_V"].Value = true;
- ugr.Cells["STD_MAX_FORMULA_V"].Value = false;
- }
- //增加行如果没有勾选则不可编辑
- 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();
- }
- /// <summary>
- /// 下拉事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
- if (ugr == null)
- return;
- if (e.Cell.Column.Key.Equals("MSC"))//冶金规范码
- {
- string msc = ugr.Cells["MSC"].Value.ToString();
- DataRow[] dr = ((DataTable)ultras[0].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];
- }
- return;
- }
- if (e.Cell.Column.Key.Equals("STD_CODE")) //标准类型
- {
- string stdCode = ugr.Cells["STD_CODE"].Value.ToString();
- DataRow[] dr = ((DataTable)ultras[5].DataSource).Select("STD_CODE='" + stdCode + "'");
- if (dr.Length > 0)
- {
- ugr.Cells["STD_NAME"].Value = dr[0][1];
- ugr.Cells["STDSTYLE"].Value = dr[0][2];
- }
- }
- if (e.Cell.Column.Key.Equals("BIAS_CODE")) //公差主项
- {
- ugr.Cells["BIAS_NAME"].Value = ugr.Cells["BIAS_CODE"].Text;
- }
- if (e.Cell.Column.Key.Equals("BIAS_CODE_Z"))//公差约束项一
- {
- ugr.Cells["BIAS_NAME_Z"].Value = ugr.Cells["BIAS_CODE_Z"].Text;
- string biasnamez = ugr.Cells["BIAS_NAME_Z"].Value.ToString();
- string biasnames = ugr.Cells["BIAS_NAME_S"].Value.ToString();
- string biasnamec = ugr.Cells["BIAS_NAME_C"].Value.ToString();
- if (!biasnamez.Equals(""))
- {
- if (biasnamez.Equals(biasnames) || biasnamez.Equals(biasnamec))
- {
- ugr.Cells["BIAS_NAME_Z"].Value = "";
- ugr.Cells["BIAS_CODE_Z"].Value = "";
- MessageBox.Show("公差约束项不能相同", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- if (ugr.Cells["BIAS_CODE_Z"].Value.ToString() == "")
- {
- ugr.Cells["ZMIN_SIGN"].Value = "";
- ugr.Cells["ZMIN"].Value = "";
- ugr.Cells["ZMAX_SIGN"].Value = "";
- ugr.Cells["ZMAX"].Value = "";
- }
- }
- if (e.Cell.Column.Key.Equals("BIAS_CODE_C"))//公差约束项二
- {
- ugr.Cells["BIAS_NAME_C"].Value = ugr.Cells["BIAS_CODE_C"].Text;
- string biasnamez = ugr.Cells["BIAS_NAME_Z"].Value.ToString();
- string biasnames = ugr.Cells["BIAS_NAME_S"].Value.ToString();
- string biasnamec = ugr.Cells["BIAS_NAME_C"].Value.ToString();
- if (!biasnamec.Equals(""))
- {
- if (biasnamec.Equals(biasnames) || biasnamec.Equals(biasnamez))
- {
- ugr.Cells["BIAS_NAME_C"].Value = "";
- ugr.Cells["BIAS_CODE_C"].Value = "";
- MessageBox.Show("公差约束项不能相同", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- if (ugr.Cells["BIAS_CODE_C"].Value.ToString() == "")
- {
- ugr.Cells["CMIN_SIGN"].Value = "";
- ugr.Cells["CMIN"].Value = "";
- ugr.Cells["CMAX_SIGN"].Value = "";
- ugr.Cells["CMAX"].Value = "";
- }
- }
- if (e.Cell.Column.Key.Equals("BIAS_CODE_S"))//公差约束项三
- {
- ugr.Cells["BIAS_NAME_S"].Value = ugr.Cells["BIAS_CODE_S"].Text;
- string biasnamez = ugr.Cells["BIAS_NAME_Z"].Value.ToString();
- string biasnames = ugr.Cells["BIAS_NAME_S"].Value.ToString();
- string biasnamec = ugr.Cells["BIAS_NAME_C"].Value.ToString();
- if (!biasnames.Equals(""))
- {
- if (biasnames.Equals(biasnamec) || biasnames.Equals(biasnamez))
- {
- ugr.Cells["BIAS_NAME_S"].Value = "";
- ugr.Cells["BIAS_CODE_S"].Value = "";
- MessageBox.Show("公差约束项不能相同", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- if (ugr.Cells["BIAS_CODE_S"].Value.ToString() == "")
- {
- ugr.Cells["SMIN_SIGN"].Value = "";
- ugr.Cells["SMIN"].Value = "";
- ugr.Cells["SMAX_SIGN"].Value = "";
- ugr.Cells["SMAX"].Value = "";
- }
- }
- if (e.Cell.Column.Key.Equals("PROCESS_CODE")) //工序
- {
- ugr.Cells["PROCESS_DESC"].Value = ugr.Cells["PROCESS_CODE"].Text;
- }
- if (e.Cell.Column.Key.Equals("STD_MIN_FORMULA_V"))
- {
- if (Convert.ToBoolean(e.Cell.Value.ToString()) == true)
- {
- ugr.Cells["STD_MAX_FORMULA_V"].Value = false;
- }
- }
- if (e.Cell.Column.Key.Equals("STD_MAX_FORMULA_V"))
- {
- if (Convert.ToBoolean(e.Cell.Value.ToString()) == true)
- {
- ugr.Cells["STD_MIN_FORMULA_V"].Value = false;
- }
- }
- if (e.Cell.Column.Key.Equals("CHC"))//选择
- {
- Activation activation = Activation.ActivateOnly;
- if (Convert.ToBoolean(e.Cell.Value))
- {
- activation = Activation.AllowEdit;
- //isSelect += 1;
- }
- //else
- // isSelect -= 1;
- CellsCollection cells = e.Cell.Row.Cells;
- for (int i = 0; i < cells.Count; i++)
- {
- if (!cells[i].Column.Key.Equals("CHC"))
- {
- if (cells[i].Column.Key == "GROUP_SEQ") continue;
- e.Cell.Row.Cells[i].Activation = activation;
- }
- }
- }
- }
- private DataTable GetMscTabByMsc(string msc)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.getComMscByMsc",
- new object[] { msc }, ob);
- return dt;
- }
- private string GetMscBySic(string sic)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getComSicBySic",
- new object[] { sic }, ob);
- if (dt.Rows.Count > 0)
- {
- return dt.Rows[0]["MSC"].ToString();
- }
- return "";
- }
- /// <summary>
- /// 通过主键查询公差主表
- /// </summary>
- /// <param name="sic"></param>
- /// <returns></returns>
- private DataRow GetMscSicBySic(string sic)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getComSicBySic",
- new object[] { sic }, 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 = GetMscBySic(row.GetValue("SIC"));
- }
- 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="i">行</param>
- /// <returns></returns>
- private SpecObject GetMasterData(UltraGridRow ugr, DataRow rowSic)
- {
- string sic = ugr.Cells["SIC"].Text.ToString();
- string psc = ugr.Cells["PSC"].Text.ToString();
- string msc = ugr.Cells["MSC"].Value.ToString();
- if (CustomInfo == "1" && msc.Equals(""))
- if (msc.Equals(""))
- {
- errMessage = "请选择冶金规范码";
- return null;
- }
- if (CheckAuthority(ugr) == false) return null;
- string stdStyle = ugr.Cells["STDSTYLE"].Text.ToString();
- string stdCode = ugr.Cells["STD_CODE"].Value.ToString();
- string stdName = ugr.Cells["STD_NAME"].Text.ToString();
- if (CustomInfo != "1" && stdName.Equals(""))
- {
- errMessage = "请选择标准名称";
- return null;
- }
- if (stdStyle.Equals("内控"))
- stdStyle = "N";
- else if (stdStyle.Equals("订货标准"))
- stdStyle = "G";
- else if (stdStyle.Equals("协议标准"))
- stdStyle = "X";
- else if (stdStyle.Equals("Alpha"))
- stdStyle = "K";
- else if (stdStyle.Equals("试验标准"))
- stdStyle = "S";
- else if (stdStyle.Equals("成分偏差标准"))
- stdStyle = "P";
- else
- stdStyle = "";
- string processCode = ugr.Cells["PROCESS_CODE"].Value.ToString();
- string processDesc = ugr.Cells["PROCESS_DESC"].Text.ToString();
- string modelCode = ugr.Cells["MODEL_CODE"].Value.ToString();
- string modelDesc = ugr.Cells["MODEL_DESC"].Text.ToString();
- string stdmemo = ugr.Cells["STDMEMO"].Text.ToString();
- string userName = UserInfo.GetUserName();
- string createTime = ugr.Cells["CREATE_TIME"].Value.ToString();
- string userTime = System.DateTime.Now.ToString();
- string validflag = ugr.Cells["VALIDFLAG"].Value.ToString();
- string steelcodeNk = ugr.GetValue("STEELCODE_NK");
- string steelnameNk = ugr.GetValue("STEELNAME_NK");
- string modelCodeNk = ugr.GetValue("MODEL_CODE_NK");
- string modelDescNk = ugr.GetValue("MODEL_DESC_NK");
- string produccodeNk = ugr.GetValue("PRODUCCODE_NK");
- string producnameNk = ugr.GetValue("PRODUCNAME_NK");
- if (rowSic != null && (rowSic["VALIDFLAG"].ToString() == "2" || rowSic["VALIDFLAG"].ToString() == "3"))
- {
- errMessage = "提交审核或已审核记录不能保存!";
- return null;
- }
- String specialPath = ugr.Cells["SPECIAL_PATH"].Value.ToString();
- if (specialPath.Equals(""))
- {
- specialPath = "0";
- }
- else
- {
- if (Boolean.Parse(specialPath))
- {
- specialPath = "1";
- }
- else
- {
- specialPath = "0";
- }
- }
- //if(CustomInfo == "2" && produccodeNk == "")
- //{
- // errMessage = "请选择品名!";
- // return null;
- //}
- SpecObject com = new SpecObject();
- com.Sic = sic;
- com.Psc = psc;
- com.Msc = msc;
- com.StdCode = stdCode;
- com.StdStyle = stdStyle;
- com.StdName = stdName;
- com.ProcessCode = processCode;
- com.ProcessDesc = processDesc;
- com.ModelCode = modelCode;
- com.ModelDesc = modelDesc;
- com.StdMemo = stdmemo;
- com.ProducHead = ugr.GetValue("PRODUC_HEAD");
- com.CodeJg = codeJg == "DefaultValue" ? "" : codeJg;
- com.CreateName = userName;
- com.CreateTime = createTime;
- com.UpdateName = userName;
- com.DeleteName = userName;
- com.Validflag = validflag;
- com.SpecialPath = specialPath;
- com.SteelcodeNk = steelcodeNk;
- com.SteelnameNk = steelnameNk;
- com.ModelCodeNk = modelCodeNk;
- com.ModelDescNk = modelDescNk;
- com.ProduccodeNk = produccodeNk;
- com.ProducnameNk = producnameNk;
- return com;
- }
- /// <summary>
- /// 新增或者修改项 从表
- /// </summary>
- /// <param name="i">行</param>
- /// <returns></returns>
- private SpecCObject GetFromData(UltraGridRow rows, DataRow rowSic)
- {
- if (CheckAuthority(rows) == false) return null;
- if (rowSic != null && (rowSic["VALIDFLAG"].ToString() == "2" || rowSic["VALIDFLAG"].ToString() == "3"))
- {
- errMessage = "主记录为提交审核或已审核状态时,无法修改";
- return null;
- }
- SpecCObject com = new SpecCObject();
- com.Sic = rows.Cells["SIC"].Value.ToString().Trim();
- com.IndexSeq = rows.Cells["INDEX_SEQ"].Value.ToString().Trim();
- com.BiasCode = rows.Cells["BIAS_CODE"].Value.ToString().Trim();
- com.BiasName = rows.Cells["BIAS_CODE"].Text.Trim();
- if (com.BiasCode.Equals(""))
- {
- errMessage = "请选择公差项";
- return null;
- }
- com.Lv = rows.Cells["LV"].Value.ToString().Trim();
- com.BiasCodeZ = rows.Cells["BIAS_CODE_Z"].Value.ToString().Trim();
- com.BiasNameZ = rows.Cells["BIAS_CODE_Z"].Text;
- com.ZminSign = rows.Cells["ZMIN_SIGN"].Value.ToString().Trim();
- com.Zmin = rows.Cells["ZMIN"].Value.ToString().Trim();
- com.ZmaxSign = rows.Cells["ZMAX_SIGN"].Value.ToString().Trim();
- com.Zmax = rows.Cells["ZMAX"].Value.ToString().Trim();
- if (!com.BiasCodeZ.Equals(""))
- {
- if (com.ZminSign.Equals("=") && !com.ZmaxSign.Equals(""))
- {
- errMessage = "公差约束项<一>:下限符号为‘=’,不能选择上限符号";
- return null;
- }
- if (com.ZminSign.Equals("") && com.ZmaxSign.Equals(""))
- {
- errMessage = "请选择公差约束项<一>:下限符号或者上限符号";
- return null;
- }
- //上限符号与上限值
- if (!com.Zmax.Equals(""))
- {
- if (com.ZmaxSign.Equals(""))
- {
- errMessage = "请选择公差约束项<一>:上限符号";
- return null;
- }
- if (StringUtil.IsNumber(com.Zmax) && com.Zmax.Length > 10)
- {
- errMessage = "公差约束项<一>:上限值(10位以内数字)";
- return null;
- }
- string zMax = com.Zmax.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
- if (!StringUtil.IsNumber(com.Zmax) && zMax.CompileFormula() == null)
- {
- errMessage = "公差约束项<一>:上限值(请输入合法公式!)";
- return null;
- }
- }
- else
- {
- if (!com.ZmaxSign.Equals(""))
- {
- errMessage = "请输入公差约束项<一>:上限值";
- return null;
- }
- }
- //下限符号与下限值
- if (!com.Zmin.Equals(""))
- {
- if (com.ZminSign.Equals(""))
- {
- errMessage = "请选择公差约束项<一>:下限符号";
- return null;
- }
- if (StringUtil.IsNumber(com.Zmin) && com.Zmin.Length > 10)
- {
- errMessage = "请输入公差约束项<一>:下限值(10位以内数字)";
- return null;
- }
- string zMin = com.Zmin.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
- if (!StringUtil.IsNumber(com.Zmin) && zMin.CompileFormula() == null)
- {
- errMessage = "公差约束项<一>:下限值(请输入合法公式!)";
- return null;
- }
- }
- else
- {
- if (!com.ZminSign.Equals(""))
- {
- errMessage = "请输入公差约束项<一>:下限值";
- return null;
- }
- }
- if (!com.Zmax.Equals("") && !com.Zmin.Equals("")) //&&Convert.ToDouble(com.Zmin)>Convert.ToDouble(com.Zmax)
- {
- int retrunValue = QcmBaseInfo.CheckStdData(com.ZminSign, com.ZmaxSign, com.Zmin, com.Zmax);
- if (retrunValue == 0)
- {
- errMessage = "输入的数据不完整";
- return null;
- }
- if (retrunValue == 1)
- {
- errMessage = "公差约束项<一>下限值与上限值相等,上下限符号请选择<=和>=";
- return null;
- }
- if (retrunValue == 2)
- {
- errMessage = "公差约束项<一>下限值不能大于上限值";
- return null;
- }
- }
- }
- else
- {
- if (!com.ZminSign.Equals("") || !com.Zmin.Equals("") || !com.ZmaxSign.Equals("") || !com.Zmax.Equals(""))
- {
- errMessage = "请选择公差约束项<一>:公差约束项";
- return null;
- }
- }
- //公差约束项二
- com.BiasCodeC = rows.Cells["BIAS_CODE_C"].Value.ToString().Trim();
- com.BiasNameC = rows.Cells["BIAS_CODE_C"].Text;
- com.CminSign = rows.Cells["CMIN_SIGN"].Value.ToString().Trim();
- com.Cmin = rows.Cells["CMIN"].Value.ToString().Trim();
- com.CmaxSign = rows.Cells["CMAX_SIGN"].Value.ToString().Trim();
- com.Cmax = rows.Cells["CMAX"].Value.ToString().Trim();
- if (!com.BiasCodeC.Equals(""))
- {
- if (com.CminSign.Equals("=") && !com.CmaxSign.Equals(""))
- {
- errMessage = "公差约束项<二>:下限符号为‘=’,不能选择上限符号";
- return null;
- }
- if (com.CminSign.Equals("") && com.CmaxSign.Equals(""))
- {
- errMessage = "请选择公差约束项<二>:下限符号或者上限符号";
- return null;
- }
- //上限符号与上限值
- if (!com.Cmax.Equals(""))
- {
- if (com.CmaxSign.Equals(""))
- {
- errMessage = "请选择公差约束项<二>:上限符号";
- return null;
- }
- if (StringUtil.IsNumber(com.Cmax) && com.Cmax.Length > 10)
- {
- errMessage = "请输入公差约束项<二>:上限值(10位以内数字)";
- return null;
- }
- string Cmax = com.Cmax.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
- if (!StringUtil.IsNumber(com.Cmax) && Cmax.CompileFormula() == null)
- {
- errMessage = "公差约束项<二>:上限值(请输入合法公式!)";
- return null;
- }
- }
- else
- {
- if (!com.CmaxSign.Equals(""))
- {
- errMessage = "请输入公差约束项<二>:上限值";
- return null;
- }
- }
- //下限符号与下限值
- if (!com.Cmin.Equals(""))
- {
- if (com.CminSign.Equals(""))
- {
- errMessage = "请选择公差约束项<二>:下限符号";
- return null;
- }
- if (StringUtil.IsNumber(com.Cmin) && com.Cmin.Length > 10)
- {
- errMessage = "请输入公差约束项<二>:下限值(10位以内数字)";
- return null;
- }
- string Cmin = com.Cmin.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
- if (!StringUtil.IsNumber(com.Cmin) && Cmin.CompileFormula() == null)
- {
- errMessage = "公差约束项<二>:下限值(请输入合法公式!)";
- return null;
- }
- }
- else
- {
- if (!com.CminSign.Equals(""))
- {
- errMessage = "请输入公差约束项<二>:下限值";
- return null;
- }
- }
- if (!com.Cmax.Equals("") && !com.Cmin.Equals("")) // && Convert.ToDouble(com.Cmin) > Convert.ToDouble(com.Cmax)
- {
- int retrunValue = QcmBaseInfo.CheckStdData(com.CminSign, com.CmaxSign, com.Cmin, com.Cmax);
- if (retrunValue == 0)
- {
- errMessage = "输入的数据不完整";
- return null;
- }
- if (retrunValue == 1)
- {
- errMessage = "公差约束项<二>下限值与上限值相等,上下限符号请选择<=和>=";
- return null;
- }
- if (retrunValue == 2)
- {
- errMessage = "公差约束项<二>下限值不能大于上限值";
- return null;
- }
- }
- }
- else
- {
- if (!com.CminSign.Equals("") || !com.Cmin.Equals("") || !com.CmaxSign.Equals("") || !com.Cmax.Equals(""))
- {
- errMessage = "请选择公差约束项<二>:公差约束项";
- return null;
- }
- }
- //公差约束项三
- com.BiasCodeS = rows.Cells["BIAS_CODE_S"].Value.ToString().Trim();
- com.BiasNameS = rows.Cells["BIAS_CODE_S"].Text;
- com.SminSign = rows.Cells["SMIN_SIGN"].Value.ToString().Trim();
- com.Smin = rows.Cells["SMIN"].Value.ToString().Trim();
- com.SmaxSign = rows.Cells["SMAX_SIGN"].Value.ToString().Trim();
- com.Smax = rows.Cells["SMAX"].Value.ToString().Trim();
- if (!com.BiasCodeS.Equals(""))
- {
- if (com.SminSign.Equals("=") && !com.SmaxSign.Equals(""))
- {
- errMessage = "公差约束项<三>:下限符号为‘=’,不能选择上限符号";
- return null;
- }
- if (com.SminSign.Equals("") && com.SmaxSign.Equals(""))
- {
- errMessage = "请选择公差约束项<三>:下限符号或者上限符号";
- return null;
- }
- //上限符号与上限值
- if (!com.Smax.Equals(""))
- {
- if (com.SmaxSign.Equals(""))
- {
- errMessage = "请选择公差约束项<三>:上限符号";
- return null;
- }
- if (StringUtil.IsNumber(com.Smax) && com.Smax.Length > 10)
- {
- errMessage = "请输入公差约束项<三>:上限值(10位以内数字)";
- return null;
- }
- string Smax = com.Smax.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
- if (!StringUtil.IsNumber(com.Smax) && Smax.CompileFormula() == null)
- {
- errMessage = "公差约束项<三>:上限值(请输入合法公式!)";
- return null;
- }
- }
- else
- {
- if (!com.SmaxSign.Equals(""))
- {
- errMessage = "请输入公差约束项<三>:上限值";
- return null;
- }
- }
- //下限符号与下限值
- if (!com.Smin.Equals(""))
- {
- if (com.SminSign.Equals(""))
- {
- errMessage = "请选择公差约束项<三>:下限符号";
- return null;
- }
- if (StringUtil.IsNumber(com.Smin) && com.Smin.Length > 10)
- {
- errMessage = "请输入公差约束项<三>:下限值(10位以内数字)";
- return null;
- }
- string Smin = com.Smin.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
- if (!StringUtil.IsNumber(com.Smin) && Smin.CompileFormula() == null)
- {
- errMessage = "公差约束项<三>:下限值(请输入合法公式!)";
- return null;
- }
- }
- else
- {
- if (!com.SminSign.Equals(""))
- {
- errMessage = "请输入公差约束项<三>:下限值";
- return null;
- }
- }
- if (!com.Smax.Equals("") && !com.Smin.Equals("")) //&& Convert.ToDouble(com.Smin) > Convert.ToDouble(com.Smax)
- {
- int retrunValue = QcmBaseInfo.CheckStdData(com.SminSign, com.SmaxSign, com.Smin, com.Smax);
- if (retrunValue == 0)
- {
- errMessage = "输入的数据不完整";
- return null;
- }
- if (retrunValue == 1)
- {
- errMessage = "公差约束项<三>下限值与上限值相等,上下限符号请选择<=和>=";
- return null;
- }
- if (retrunValue == 2)
- {
- errMessage = "公差约束项<三>下限值不能大于上限值";
- return null;
- }
- }
- }
- else
- {
- if (!com.SminSign.Equals("") || !com.Smin.Equals("") || !com.SmaxSign.Equals("") || !com.Smax.Equals(""))
- {
- errMessage = "请选择公差约束项<三>:公差约束项";
- return null;
- }
- }
- if (!com.BiasCodeS.Equals(""))
- {
- if (com.BiasCodeC.Equals(""))
- {
- errMessage = "请依次填写公差约束项";
- return null;
- }
- else
- {
- if (com.BiasCodeZ.Equals(""))
- {
- errMessage = "请依次填写公差约束项";
- return null;
- }
- }
- }
- else
- {
- if (!com.BiasCodeC.Equals(""))
- {
- if (com.BiasCodeZ.Equals(""))
- {
- errMessage = "请依次填写公差约束项";
- return null;
- }
- }
- }
- com.IsCheck = rows.Cells["ISCHECK"].Value.ToString().Trim();
- if (Convert.ToBoolean(com.IsCheck))
- com.IsCheck = "1";
- else
- com.IsCheck = "0";
- com.StdMinVal = rows.Cells["STD_MIN_VAL"].Value.ToString().Trim();
- int i = 0;
- if (!com.StdMinVal.Equals(""))
- {
- i += 1;
- if (!StringUtil.IsNumber(com.StdMinVal) || com.StdMinVal.Length > 10)
- {
- errMessage = "下偏差值(mm)请输入10位以内数字";
- return null;
- }
- if ((com.BiasCode == "404019" || com.BiasCode == "404020") && decimal.Parse(com.StdMinVal) > 0)
- {
- errMessage = "(管体/管端壁厚)下偏差值(mm)不能为正数";
- return null;
- }
- }
- com.StdMaxVal = rows.Cells["STD_MAX_VAL"].Value.ToString().Trim();
- if (!com.StdMaxVal.Equals(""))
- {
- if (!StringUtil.IsNumber(com.StdMaxVal) || com.StdMaxVal.Length > 10)
- {
- errMessage = "上偏差值(mm)请输入10位以内数字";
- return null;
- }
- }
- com.StdMinIn = rows.Cells["STD_MIN_IN"].Value.ToString().Trim();
- if (!com.StdMinIn.Equals(""))
- {
- if (!StringUtil.IsNumber(com.StdMinIn) || com.StdMinIn.Length > 10)
- {
- errMessage = "标准负值(in)请输入10位以内数字";
- return null;
- }
- }
- com.StdMaxIn = rows.Cells["STD_MAX_IN"].Value.ToString().Trim();
- if (!com.StdMaxIn.Equals(""))
- {
- if (!StringUtil.IsNumber(com.StdMaxIn) || com.StdMaxIn.Length > 10)
- {
- errMessage = "标准正值(in)请输入10位以内数字";
- return null;
- }
- }
- com.StdMinPercent = rows.Cells["STD_MIN_PERCENT"].Value.ToString().Trim();
- if (!com.StdMinPercent.Equals(""))
- {
- i += 1;
- if (!StringUtil.IsNumber(com.StdMinPercent) || com.StdMinPercent.Length > 10)
- {
- errMessage = "下偏差值(%)请输入10位以内数字";
- return null;
- }
- if ((com.BiasCode == "404019" || com.BiasCode == "404020") && decimal.Parse(com.StdMinPercent) > 0)
- {
- errMessage = "(管体/管端壁厚)下偏差值(%)不能为正数";
- return null;
- }
- }
- com.StdMaxPercent = rows.Cells["STD_MAX_PERCENT"].Value.ToString().Trim();
- if (!com.StdMaxPercent.Equals(""))
- {
- if (!StringUtil.IsNumber(com.StdMaxPercent) || com.StdMaxPercent.Length > 10)
- {
- errMessage = "上偏差值(%)请输入10位以内数字";
- return null;
- }
- }
- com.StdMinFormula = rows.Cells["STD_MIN_FORMULA"].Value.ToString().Trim();
- if (!com.StdMinFormula.Equals(""))
- {
- i += 1;
- if (com.StdMinFormula.Length > 100)
- {
- errMessage = "请输入标准公式下偏差值(mm)";
- return null;
- }
- if ((com.BiasCode == "404019" || com.BiasCode == "404020") && (!com.StdMinFormula.StartsWith("-") && com.StdMinFormula != "0"))
- {
- errMessage = "(管体/管端壁厚)标准公式下偏差值(mm)不能为正数";
- return null;
- }
- }
- com.StdMaxFormula = rows.Cells["STD_MAX_FORMULA"].Value.ToString().Trim();
- if (!com.StdMaxFormula.Equals(""))
- {
- if (com.StdMaxFormula.Length > 100)
- {
- errMessage = "请输入标准公式上偏差值(mm)";
- return null;
- }
- }
- if (com.StdMinVal.Equals("") && com.StdMinFormula.Equals("") && com.StdMinPercent.Equals(""))
- {
- errMessage = "请输入一组标准值";
- return null;
- }
- if (com.StdMinVal.Equals(""))
- {
- if (!com.StdMaxVal.Equals(""))
- {
- errMessage = "下偏差值(mm)请输入10位以内数字";
- return null;
- }
- }
- else
- {
- if (com.StdMaxVal.Equals(""))
- {
- errMessage = "上偏差值(mm)请输入10位以内数字";
- return null;
- }
- }
- if (com.StdMinPercent.Equals(""))
- {
- if (!com.StdMaxPercent.Equals(""))
- {
- errMessage = "下偏差值(%)请输入10位以内数字";
- return null;
- }
- }
- else
- {
- if (com.StdMaxPercent.Equals(""))
- {
- errMessage = "上偏差值(%)请输入10位以内数字";
- return null;
- }
- }
- if (com.StdMinFormula.Equals(""))
- {
- if (!com.StdMaxFormula.Equals(""))
- {
- errMessage = "请输入标准公式下偏差值(mm)";
- return null;
- }
- }
- else
- {
- if (com.StdMaxFormula.Equals(""))
- {
- errMessage = "请输入标准公式上偏差值(mm)";
- return null;
- }
- }
- if (!com.StdMinFormula.Equals("") && !StringUtil.IsNumber(com.StdMinFormula))
- {
- if (!QcmBaseCommon.CheckToleranceFormula(com.StdMinFormula))
- {
- errMessage = "您输入的标准值-公式下偏差值(mm):[" + com.StdMinFormula + "]不合法,请重新输入!";
- return null;
- }
- }
- if (!com.StdMaxFormula.Equals("") && !StringUtil.IsNumber(com.StdMaxFormula))
- {
- if (!QcmBaseCommon.CheckToleranceFormula(com.StdMaxFormula))
- {
- errMessage = "您输入的标准值-公式上偏差值(mm):[" + com.StdMaxFormula + "]不合法,请重新输入!";
- return null;
- }
- }
- com.StdMinFormulaV = rows.Cells["STD_MIN_FORMULA_V"].Value.ToString().Trim();
- com.StdMaxFormulaV = rows.Cells["STD_MAX_FORMULA_V"].Value.ToString().Trim();
- if (Convert.ToBoolean(com.StdMinFormulaV))
- com.StdMinFormulaV = "1";
- else
- com.StdMinFormulaV = "0";
- if (Convert.ToBoolean(com.StdMaxFormulaV))
- com.StdMaxFormulaV = "1";
- else
- com.StdMaxFormulaV = "0";
- if (com.StdMaxFormulaV.Equals("1") && com.StdMinFormulaV.Equals("1"))
- {
- errMessage = "不能同时选择标准取小值和取大值";
- return null;
- }
- if (i > 1 && com.StdMinFormulaV.Equals("0") && com.StdMaxFormulaV.Equals("0"))
- {
- errMessage = "请选择标准取小值或者取大值";
- return null;
- }
- com.StdMemo = rows.Cells["STDMEMO"].Value.ToString().Trim();
- com.CreateName = UserInfo.GetUserName();
- com.UpdateName = UserInfo.GetUserName();
- com.Validflag = rows.Cells["VALIDFLAG"].Value.ToString();
- com.CreateTime = rows.Cells["CREATE_TIME"].Value.ToString().Trim();
- com.GroupSeq = rows.Cells["GROUP_SEQ"].Value.ToString();
- if (!com.BiasCodeC.Equals(""))
- {
- if (com.BiasCodeC.Equals(com.BiasCodeS) || com.BiasCodeC.Equals(com.BiasCodeZ))
- {
- errMessage = "公差约束项不能相同,请重新选择";
- return null;
- }
- }
- if (!com.BiasCodeS.Equals(""))
- {
- if (com.BiasCodeS.Equals(com.BiasCodeC) || com.BiasCodeS.Equals(com.BiasCodeZ))
- {
- errMessage = "公差约束项不能相同,请重新选择";
- return null;
- }
- }
- if (!com.BiasCodeZ.Equals(""))
- {
- if (com.BiasCodeZ.Equals(com.BiasCodeC) || com.BiasCodeZ.Equals(com.BiasCodeS))
- {
- errMessage = "公差约束项不能相同,请重新选择";
- return null;
- }
- }
- return com;
- }
- FrmTolerancesStandard _frmTolerancesStandard = null;
- /// <summary>
- /// 扣型选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
- {
- if (e.Cell.Column.Key.Equals("MODEL_DESC") && Convert.ToBoolean(ultraGrid1.DisplayLayout.ActiveRow.Cells["CHC"].Value))
- {
- UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow;
- FrmModel frms = new FrmModel();
- frms.Code = row.Cells["MODEL_CODE"].Value.ToString();
- frms.Desc = row.Cells["MODEL_DESC"].Value.ToString();
- frms.FrmOb = this.ob;
- 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;
- _frmTolerancesStandard = new FrmTolerancesStandard();
- _frmTolerancesStandard.PopupLoad("3", ob);
- _frmTolerancesStandard.UltraPanel1.Visible = false;
- _frmTolerancesStandard.ultraToolbarsManager1.Visible = true;
- _frmTolerancesStandard.Msc = msc;
- _frmTolerancesStandard.CodeJg = "";
- _frmTolerancesStandard.DoQuery1();
- if (_frmTolerancesStandard.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- DataRow CurRow, NewRow;
- for (int i = 0; i < _frmTolerancesStandard.dataTable2.Rows.Count; i++)
- {
- CurRow = _frmTolerancesStandard.dataTable2.Rows[i];
- NewRow = dataTable2.NewRow();
- if (!_frmTolerancesStandard.Ids.Contains(CurRow["SIC"].ToString2()))
- {
- continue;
- }
- for (int j = 0; j < _frmTolerancesStandard.dataTable2.Columns.Count; j++)
- {
- try
- {
- if (dataTable2.Columns.Contains(_frmTolerancesStandard.dataTable2.Columns[j].ColumnName))
- {
- if (_frmTolerancesStandard.dataTable2.Columns[j].ColumnName == "SIC")
- {
- NewRow[_frmTolerancesStandard.dataTable2.Columns[j].ColumnName] = ultraGrid1.ActiveRow.GetValue("SIC");
- }
- else
- {
- NewRow[_frmTolerancesStandard.dataTable2.Columns[j].ColumnName] = CurRow[j];
- }
- }
- }
- catch { }
- }
- dataTable2.Rows.Add(NewRow);
- }
- ultraGrid1.UpdateData();
- ultraGrid1.ActiveRow.ExpandAll();
- }
- }
- }
- private void ultraCheckMSC_CheckedChanged(object sender, EventArgs e)
- {
- if (ultraCheckMSC.Checked)
- TextMSC.Enabled = true;
- else
- TextMSC.Enabled = false;
- }
- private void ultraCheckStand_CheckedChanged(object sender, EventArgs e)
- {
- if (ultraCheckStand.Checked)
- TextStd.Enabled = true;
- else
- TextStd.Enabled = false;
- }
- 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_CODE"].CellActivation = Activation.ActivateOnly;
- ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"].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_CODE");
- 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_CODE", 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 frmModel = new FrmModel();
- frmModel.FrmOb = this.ob;
- frmModel.Code = ultraGrid1.ActiveRow.GetValue("MODEL_CODE_NK");
- frmModel.Desc = ultraGrid1.ActiveCell.Value.ToString();
- if (frmModel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- ultraGrid1.ActiveRow.SetValue("MODEL_CODE_NK", frmModel.Code);
- ultraGrid1.ActiveRow.SetValue("MODEL_DESC_NK", frmModel.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 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("SIC")).ToList();
- Rows = dataTable2.Select("SIC IN ('" + string.Join("','", Ids) + "')");
- }
- }
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- }
- }
- }
|