| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;using Pur.Entity;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm.Control;
- using Infragistics.Win.UltraWinTree;
- using Pur.Entity.configureEntity;
- using System.Data.OracleClient;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinScrollBar;
- using com.hnshituo.pur.vo;
- using System.Collections;
- using Core.Mes.Client.Comm.Server;
- using Pur.Pop_upWindow;
- using Pur.Entity.require_planEntiy;
- using System.Reflection;
- using Core.Mes.Client.Comm.Format;
- namespace Pur.configure
- {
- public partial class FrmPurMat : FrmPmsBase
- {
- DataTable dt_Purmatclass = null;
- Boolean QClickCellOrQuery = false;//是否点击查询按钮或grid数据单元格
- UltraTreeNode qUltraNode = null;
- //string strBUYER_DEPT_CODE = "";
- //string strMENT_UNIT_CODE = "";
- string QstrBUYER_ROLE_ID = "";
- string QstrPLANNER_ROLE_ID = "";
- string QstrBUYER_ROLE_ID1 = "";
- string QstrPLANNER_ROLE_ID1 = "";
- string QstrINV_PHYSIC_USERID = "";//库管员
- string planPrice = "";//计划价格
- MatEntity Q_mat = null;
- public FrmPurMat()
- {
- InitializeComponent();
- ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- ultraGrid3.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- ultraGrid4.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- txt_IS_DEFAULT_ATTR.SelectedIndex = 0;
- txt_IsLevel.SelectedIndex = 0;
- txt_IS_DEFAULT_STANDRANDS.SelectedIndex = 0;
- txt_IS_DEFAULT_UOM.SelectedIndex = 0;
- cmbNum.SelectedIndex = 0;//默认显示500条数据
- //给编辑区设置滚动条
- //foreach (Control gbox in ultraGroupBox6.Controls)
- //{
- // if (gbox is UltraScrollBar) continue;
- // gbox.Tag = gbox.Tag = gbox.Location.Y;
- //}
- //panel1.VerticalScroll.Value = panel1.VerticalScroll.Maximum;
- }
- /// <summary>
- /// 界面加载函数
- /// </summary>
- /// <param name="e"></param>
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
- //ultraGrid2.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FrmPurMat_Load(object sender, EventArgs e)
- {
- getUltcmbBindData();
- setUltCmbEdt_sel();
- string basecode = "1234";
- DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { basecode }, this.ob);
- dt = dt.AsEnumerable().Where(p => p["VALIDFLAG"].ToString().Equals("1")).CopyToDataTable();
- Ultcmb_MAT_TYPE.DataSource = dt;
- Ultcmb_MAT_TYPE.DisplayMember = "BASENAME";
- Ultcmb_MAT_TYPE.ValueMember = "BASECODE";
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- }
- //菜单按钮事件
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- QClickCellOrQuery = true;
- GetPUR_MAT_Class();
- if (ultraGrid1.Rows.Count > 0)
- {
- ulTreeMat.CollapseAll();
- UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(ultraGrid1.Rows[0].Cells["ARCCODE"].Value.ToString());
- ulTreeMat.ActiveNode = uttNode;
- if (uttNode == null)
- {
- MessageUtil.ShowTips("物料名称:" + ultraGrid1.Rows[0].Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + ultraGrid1.Rows[0].Cells["ARCCODE"].Value.ToString());
- }
- else
- {
- while (ulTreeMat.ActiveNode != uttNode)
- {
- ulTreeMat.ActiveNode = uttNode;
- }
- uttNode.Expanded = true;
- //展开分类
- while (uttNode.Parent != null)
- {
- uttNode = uttNode.Parent;
- uttNode.Expanded = true;
- }
- }
- QClickCellOrQuery = false;//设置未点击
- }
- break;
- case "Add":
- AddPUR_MAT();
- break;
- case "Update":
- UpdPUR_MAT();
- break;
- case "Delete":
- DelPUR_MAT();
- break;
- case "UsePUR_MAT"://启用物料
- UsePUR_MAT();
- break;
- case "updateSrole_1":
- if (ulTreeMat.ActiveNode != null)
- {
- updateSrole(ulTreeMat.ActiveNode.Key, "1");
- }
- break;
- case "updateSrole_2":
- if (ulTreeMat.ActiveNode != null)
- {
- updateSrole(ulTreeMat.ActiveNode.Key, "2");
- }
- break;
- case "updateSrole_3"://批量修改库管员
- if (ulTreeMat.ActiveNode != null)
- {
- updateSrole(ulTreeMat.ActiveNode.Key, "3");
- }
- break;
- case "setMatClassPross":
- setMatClassPross();
- break;
- case "addSupps":
- addSupps(ulTreeMat.ActiveNode.Key, txt_suppCode.Text);
- break;
- case "updPrice"://维护计划价格
- updPrice();
- break;
- case "doExcel":
- doExcel();
- break;
- }
- }
- private void doExcel()
- {
- try
- {
- this.Cursor = Cursors.Default;
- if (ultraGrid2.Rows.Count <= 0)
- {
- MessageUtil.ShowTips( "无可导出明细!");
- }
- ArrayList alUltraGrid = new ArrayList();
- alUltraGrid.Add(ultraGrid1);
- ArrayList alSheeft = new ArrayList();
- alSheeft.Add("物料明细");
- if (ultraGrid1.Rows.Count > 0)
- {
- GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "物料明细表");//导出excel
- }
- else
- {
- MessageUtil.ShowTips("无可导出明细!");
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("导出失败" + e.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 维护计划价格
- /// </summary>
- private void updPrice()
- {
- if(ultraTabControl2.SelectedTab.Key == "01")
- {
- ultraTabControl1.SelectedTab = ultraTabPageControl2.Tab;
- }
- }
- /// <summary>
- /// 查询物料分类
- /// </summary>
- public void GetPUR_MAT_Class()
- {
- //查询物料分类
- PurmatclassEntity mat = new PurmatclassEntity();
- mat.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "find", new object[] { mat, 0, 0 });
- getultree(dt);//绑定物料分类表
- //查询物料
- getMat(getEnSelContion(null));
- }
- /// <summary>
- /// 查询物料
- /// </summary>
- private void getMat(MatEntity mat)
- {
- if (ulTreeMat.Nodes.Count == 0)
- { return; }
- if(mat==null)
- { mat = new MatEntity(); }
- if(chk_showHasDelete.Checked)
- {
- mat.Validflag=null;
- }
- else
- {
- mat.Validflag="1";
- }
- DataTable dt_mat = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatService", "getMat", new object[] { mat});
- //按创建时间降序
- if (dt_mat.Rows.Count > 1)
- {
- dt_mat.DefaultView.Sort = "CREATETIME DESC";
- dt_mat = dt_mat.DefaultView.ToTable();
- }
- dataTable1.Rows.Clear();
- GridHelper.CopyDataToDatatable(ref dt_mat, ref dataTable1, true);//绑定物料分类表
- Q_mat = mat;
- dt_Purmatclass = dt_mat;
- showHasDelete(chk_showHasDelete.Checked);//隐藏作废的物料
- if (ultraGrid1.Rows.Count == 0)
- {
- dataTable2.Rows.Clear();
- dataTable3.Rows.Clear();
- dataTable4.Rows.Clear();
- dataTable5.Rows.Clear();
- getControlBoxValue(0);//清空控件
- setUltCmbEdt_sel();
- }
- ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- }
- /// <summary>
- /// 查询供应商
- /// </summary>
- /// <param name="Itemcode">物料代码</param>
- private void getSuppGrade(string strItemcode)
- {
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.SuppGradeService", "getMat_Supp", new object[] { strItemcode });
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);//绑定物料分类表
- if (dataTable2.Rows.Count < 1)
- {
- getControlBoxValue(1);//清空控件
- }
- ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- }
- /// <summary>
- /// 获取物料属性
- /// </summary>
- /// <param name="parm"></param>
- private void getItemAttr()
- {
- //查询父表
- //查询属性父表
- PurMatAttrsEntity MatAttrsEntity = new PurMatAttrsEntity();
- MatAttrsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- MatAttrsEntity.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatAttrsService", "getMatAttrClass", new object[] { MatAttrsEntity });
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable7, true);//获取物料属性
- //查询子表
- dataTable3.Rows.Clear();
- Dictionary<string, object> param = new Dictionary<string, object>();
- param.Add("ItemCode", ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());
- param.Add("Validflag", "1");
- DataTable dt_mat = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatAttrsService", "find", new object[] { param, 0, 0 });
- //按是否常用排序
- if (dt_mat.Rows.Count > 1)
- {
- dt_mat.DefaultView.Sort = "ISDEFAULT DESC";
- dt_mat = dt_mat.DefaultView.ToTable();
- }
- for (int i = 0; i < dt_mat.Rows.Count; i++)
- {
- if (dt_mat.Rows[i]["ISDEFAULT"].ToString() == "1")
- {
- dt_mat.Rows[i]["ISDEFAULT"] = "是";
- }
- else if (dt_mat.Rows[i]["ISDEFAULT"].ToString() == "0")
- {
- dt_mat.Rows[i]["ISDEFAULT"] = "否";
- }
- if (dt_mat.Rows[i]["islevel"].ToString() == "1")
- {
- dt_mat.Rows[i]["islevel"] = "是";
- }
- else
- {
- dt_mat.Rows[i]["islevel"] = "否";
- }
- }
-
- GridHelper.CopyDataToDatatable(ref dt_mat, ref dataTable3, true);//绑定物料规格
- if (dataTable3.Rows.Count < 1)
- {
- getControlBoxValue(2);//清空控件
- }
- }
- /// <summary>
- /// 获取物料标准编号
- /// </summary>
- private void getMatStandard()
- {
- dataTable4.Rows.Clear();
- if (ultraGrid1.ActiveRow != null)
- {
- PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
- PurMatStandards_Entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- PurMatStandards_Entity.Validflag = "1";
- DataTable dt_matStandards = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatStandardsService", "find", new object[] { PurMatStandards_Entity, 0, 0 });
- //按是否常用排序
- if (dt_matStandards.Rows.Count > 1)
- {
- dt_matStandards.DefaultView.Sort = "ISDEFAULT DESC";
- dt_matStandards = dt_matStandards.DefaultView.ToTable();
- }
- for (int i = 0; i < dt_matStandards.Rows.Count; i++)
- {
- if (dt_matStandards.Rows[i]["ISDEFAULT"].ToString() == "1")
- {
- dt_matStandards.Rows[i]["ISDEFAULT"] = "是";
- }
- else if (dt_matStandards.Rows[i]["ISDEFAULT"].ToString() == "0")
- {
- dt_matStandards.Rows[i]["ISDEFAULT"] = "否";
- }
- }
- GridHelper.CopyDataToDatatable(ref dt_matStandards, ref dataTable4, true);//绑定物料规格
- if (dataTable4.Rows.Count < 1)
- {
- getControlBoxValue(3);//清空控件
- }
- }
- }
- /// <summary>
- /// 获取单位转换
- /// </summary>
- private void getMatUOM()
- {
- dataTable5.Rows.Clear();
- if (ultraGrid1.ActiveRow != null)
- {
- PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
- MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- //MatUomsEntity.Validflag = "1";
- DataTable dt_matUOM = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatUomsService", "find", new object[] { MatUomsEntity, 0, 0 });
- //按是否常用排序
- if (dt_matUOM.Rows.Count > 1)
- {
- dt_matUOM.DefaultView.Sort = "ISDEFAULT DESC";
- dt_matUOM = dt_matUOM.DefaultView.ToTable();
- }
- for (int i = 0; i < dt_matUOM.Rows.Count; i++)
- {
- if (dt_matUOM.Rows[i]["ISDEFAULT"].ToString() == "1")
- {
- dt_matUOM.Rows[i]["ISDEFAULT"] = "是";
- }
- else if (dt_matUOM.Rows[i]["ISDEFAULT"].ToString() == "0")
- {
- dt_matUOM.Rows[i]["ISDEFAULT"] = "否";
- }
- //是否常用
- if (dt_matUOM.Rows[i]["Validflag"].ToString() == "1")
- {
- dt_matUOM.Rows[i]["Validflag"] = "正常";
- }
- else if (dt_matUOM.Rows[i]["Validflag"].ToString() == "0")
- {
- dt_matUOM.Rows[i]["Validflag"] = "作废";
- }
- }
- GridHelper.CopyDataToDatatable(ref dt_matUOM, ref dataTable5, true);//绑定物料规格
- if (dataTable5.Rows.Count < 1)
- {
- getControlBoxValue(4);//清空控件
- }
- foreach (UltraGridRow ugr in ultraGrid5.Rows)
- {
- if (ugr.Cells["VALIDFLAG"].Value.ToString() == "作废")
- {
- //ugr.Hidden = false;//显示
- ugr.Appearance.ForeColor = Color.Red;
- }
- }
- }
- }
- /// <summary>
- /// 增加物料
- /// </summary>
- public void AddPUR_MAT()
- {
- if (ultraTabControl1.SelectedTab.Key == "01")//添加物料
- {
- if (ulTreeMat.ActiveNode != null)//选中物料分类节点
- {
- MatEntity mat_entity = new MatEntity();
- if (ulTreeMat.ActiveNode.Key.Length < 5)
- {
- MessageUtil.ShowTips("当前节点不是物料小类,不能添加物料");
- return;
- }
- if (txt_ITEM_NAME.Text.Trim() == "")
- {
- MessageUtil.ShowTips("物料名称不能为空");
- return;
- }
- if (txt_ITEM_CODE.Text.Trim().Substring(0, 5) != ulTreeMat.ActiveNode.Key)
- {
- if (MessageUtil.ShowYesNoAndQuestion("填写的物料编码的前5位为【" + txt_ITEM_CODE.Text.Trim().Substring(0, 5) + "】,和当前所选分类编码【" + ulTreeMat.ActiveNode.Key + "】不同,确定是否添加?").Equals(DialogResult.No))
- { return; }
- }
- if (cb_BASE_UNIT_FLAG.Checked)
- {
- if (txt_BASE_UNIT_VALUE.Text == "" || !StringUtil.IsNumber(txt_BASE_UNIT_VALUE.Text))
- {
- MessageUtil.ShowTips("基吨值不能为空,且必须为数字");
- return;
- }
- if (txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') == -1 && txt_BASE_UNIT_VALUE.Text.Trim().Length > 6)
- {
- MessageUtil.ShowTips("基吨值整数长度不超过6位");
- return;
- }
- if (txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') != -1 && txt_BASE_UNIT_VALUE.Text.Trim().Length > 6)
- {
- if (txt_BASE_UNIT_VALUE.Text.Trim().Substring(0, txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.')).Length > 6)
- {
- MessageUtil.ShowTips("基吨值整数长度不超过6位");
- return;
- }
- if (txt_BASE_UNIT_VALUE.Text.Trim().Substring(txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') + 1).Length > 6)
- {
- MessageUtil.ShowTips("基吨值小数长度不超过6位");
- return;
- }
- }
- }
- mat_entity.ItemName = txt_ITEM_NAME.Text.Replace(" ","");
- if (isExsitRow("com.hnshituo.pur.configure.service.MatService","isExsitItemName", mat_entity) > 0)
- {
- MessageUtil.ShowTips("添加失败 " + "数据库中已存在相同的物料名称");
- return;
- }
- mat_entity.ItemName = null;//清空物料名称,方便下一步判断物料编码是否相同
- UltraTreeNode ultNode = ulTreeMat.ActiveNode;
- //判断物料名称是否相同
- if (ultraGrid1.ActiveRow==null || ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() != txt_ITEM_CODE.Text.Trim())//自定义输入物料编码
- {
- if (txt_ITEM_CODE.Text.Trim().Contains("@"))
- {
- MessageUtil.ShowTips("物料编码中不能包含“@”字符");
- return;
- }
- if (txt_ITEM_CODE.Text.Trim().Length != 15)
- {
- MessageUtil.ShowTips("手动输入编码必须为15位");
- return;
- }
- //判断编码是否存在
- mat_entity.ItemCode = txt_ITEM_CODE.Text.Trim();
- if (isExsitRow("com.hnshituo.pur.configure.service.MatService", mat_entity) > 0)
- {
- MessageUtil.ShowTips("添加失败 " + "数据库中已存在相同的物料编码");
- return;
- }
- }
- else
- {
- mat_entity.ItemCode = getItemCodeClass(ulTreeMat.ActiveNode.Key, "");//物料编码
- }
- // 是否使用采购单位
- //if (ultChkSuppUon.Checked)
- //{
- // mat_entity.ItemUseUom = "1";// 是否使用采购单位,0:否,1:是
- // mat_entity.ItemUom = Ultcmb_ITEM_UOM.Text;//采购单位(个、袋、桶)
- // double num = 0;
- // double.TryParse(txt_ITEM_UOM_CONEFFICIENT.Text, out num);
- // mat_entity.ItemUomConefficient = num;//转换系数
- //}
- //else
- //{
- // mat_entity.ItemUseUom = "0";// 是否使用采购单位,0:否,1:是
- // mat_entity.ItemUom = Ultcmb_WEIGHT_UNIT.Text;//库存单位赋给采购单位
- //}
- //mat_entity.ItemUom = Ultcmb_WEIGHT_UNIT.Text;//库存单位赋给采购单位
- //mat_entity.ItemUomConefficient = 1;//转换系数
- if (cb_BASE_UNIT_FLAG.Checked)//基顿标识
- {
- mat_entity.BaseUnitFlag = "1";
- mat_entity.BaseUnitValue = double.Parse(txt_BASE_UNIT_VALUE.Text);
- }
- else
- {
- mat_entity.BaseUnitFlag = "0";
- }
- mat_entity.IsBudgetCtrl = txt_IS_BUDGET_CTRL.Value == null ? null : txt_IS_BUDGET_CTRL.Value.ToString();
- mat_entity.WeightUnit = Ultcmb_WEIGHT_UNIT.Text;//库存单位
- mat_entity.WeightUnitCode = Ultcmb_WEIGHT_UNIT_CODE.Text;//库存单位编码
- mat_entity.ReceiveType = Ultcmb_RECEIVE_TYPE.Value == null ? null : Ultcmb_RECEIVE_TYPE.Value.ToString();//入库类型;1:直接入库2:收货质检入库3:JIT入库4:VMI入库
- if (Ultcmb_BATCH_FLAG.Value == null)
- {
- MessageUtil.ShowTips("添加失败 " + "“是否批次控制”不能为空");
- return;
- }
- if (txt_DELVRY_RANGE_TPE.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择交货量差方式");
- txt_DELVRY_RANGE_TPE.Focus();
- return;
- }
- mat_entity.DelvryRangeTpe =txt_DELVRY_RANGE_TPE.Value.ToString().Trim();//交货量差方式
- if ("1" == txt_DELVRY_RANGE_TPE.Value.ToString().Trim() || "2" == txt_DELVRY_RANGE_TPE.Value.ToString().Trim())
- {
- if (txt_DELVRY_RANGE_MIN.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MIN.Value.ToString().Trim()))
- {
- mat_entity.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN.Value.ToString());//交货量差下限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差下限值");
- txt_DELVRY_RANGE_MIN.Focus();
- return;
- }
- if (txt_DELVRY_RANGE_MAX.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MAX.Value.ToString().Trim()))
- {
- mat_entity.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX.Value.ToString());//交货量差上限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差上限值");
- txt_DELVRY_RANGE_MAX.Focus();
- return;
- }
- }
- else
- {
- mat_entity.DelvryRangeMin = 0;
- mat_entity.DelvryRangeMax = 0;
- }
- mat_entity.PcFlag = txt_PC_FLAG.Value == null ? null : txt_PC_FLAG.Value.ToString();//是检化验
- mat_entity.BatchFlag = Ultcmb_BATCH_FLAG.Value == null ? null : Ultcmb_BATCH_FLAG.Value.ToString();//是否批次控制
- mat_entity.PurStandards = Ultcmb_PUR_STANDARDS.Value == null ? null : Ultcmb_PUR_STANDARDS.Value.ToString();//采购标准
- mat_entity.InvWasteFacUom = Ultcmb_INV_WASTE_FAC_UOM.Value == null ? 0 : double.Parse(Ultcmb_INV_WASTE_FAC_UOM.Value.ToString());//库存损耗率单位
- //mat_entity.ShareCkSpecFlag = Ultcmb_SHARE_CK_SPEC_FLAG.Value == null ? null : Ultcmb_SHARE_CK_SPEC_FLAG.Value.ToString();//是否与子规格共用库存
- mat_entity.MeteringFlag = Ultcmb_METERING_FLAG.Value == null ? null : Ultcmb_METERING_FLAG.Value.ToString();//是否计量
- mat_entity.PriceType = Ultcmb_PRICE_TYPE.Text;//计价类型
- mat_entity.CurrencyCode = Ultcmb_CURRENCY_CODE.Text;//币种代码
- mat_entity.LifeCycleUom = Ultcmb_LIFE_CYCLE_UOM.Text;//有效期单位
- mat_entity.PurStandardsCode = txt_PUR_STANDARDS_CODE.Text;//采购标准编号
- mat_entity.MinStock = txt_MIN_STOCK.Text.Trim() == "" ? 0 : double.Parse(txt_MIN_STOCK.Text);//最小库存(预警)
- mat_entity.MaxStock = txt_MAX_STOCK.Text.Trim() == "" ? 0 : double.Parse(txt_MAX_STOCK.Text);//最大库存(预警)
- mat_entity.LeadTime = txt_LEAD_TIME.Text.Trim() == "" ? 0 : double.Parse(txt_LEAD_TIME.Text);//采购提前时间(天)
- mat_entity.InvWasteFac = txt_INV_WASTE_FAC.Text.Trim() == "" ? 0 : double.Parse(txt_INV_WASTE_FAC.Text);//库存损耗率
- mat_entity.LifeCycle = txt_LIFE_CYCLE.Text.Trim() == "" ? 0 : double.Parse(txt_LIFE_CYCLE.Text);//有效期
- mat_entity.MinQty = txt_MIN_QTY.Text.Trim() == "" ? 0 : double.Parse(txt_MIN_QTY.Text);//最小采购数量
- mat_entity.QtyMultiple = txt_QTY_MULTIPLE.Text.Trim() == "" ? 0 : double.Parse(txt_QTY_MULTIPLE.Text);//批量数
- mat_entity.BugPrice = txt_BUG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_BUG_PRICE.Text);//计划价
- mat_entity.LastPrice = txt_LAST_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_LAST_PRICE.Text);//最近采购价
- mat_entity.MonthEndAvgPrice = txt_MONTH_END_AVG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_MONTH_END_AVG_PRICE.Text);//月末移动平均价
- mat_entity.ItemName = txt_ITEM_NAME.Text.Trim().Replace(" "," ").Replace("(","(").Replace(")",")");//物料名称
- mat_entity.ItemDescE = txt_ITEM_DESC_E.Text;//物料英文名称
- mat_entity.ItemDesc = txt_ITEM_DESC.Text;//物料描述
- mat_entity.ItemModel = txt_ITEM_MODEL.Text;//物料材质
- mat_entity.ItemSpec = txt_ITEM_SPEC.Text;//物料型号规格
- mat_entity.BuyerRoleId = QstrBUYER_ROLE_ID;
- mat_entity.PlannerRoleId = QstrPLANNER_ROLE_ID;
- mat_entity.BuyerRoleName = txt_BUYER_ROLE_NAME.Text;
- mat_entity.PlannerRoleName = txt_PLANNER_ROLE_NAME.Text;
- mat_entity.InvPhysicUserid = QstrINV_PHYSIC_USERID;//库管员
- mat_entity.InvPhysicUsername = txt_INV_PHYSIC_USERID.Text;//库管员名称
- //mat_entity.BuyerUnitCode = strBUYER_DEPT_CODE;//采购科室代码
- //mat_entity.BuyerUnitDesc = txt_BUYER_UNITCODE.Text;//采购科室描述
- //mat_entity.MentUnitCode = strMENT_UNIT_CODE;//采购管理科室代码
- //mat_entity.MentUnitDesc = txt_MENT_UNIT_CODE.Text;//采购管理科室代码
- mat_entity.ArcCode = ulTreeMat.ActiveNode.Key;//物料只保存分类编码,不保存父类编码
- mat_entity.ArcItem = ulTreeMat.ActiveNode.Text;//物料分类编码名称
- mat_entity.CreateName = UserInfo.GetUserName();
- mat_entity.CreateUserid = UserInfo.GetUserID();
- mat_entity.CreateTime = System.DateTime.Now;
- mat_entity.Validflag = "1";
- mat_entity.MatType = Ultcmb_MAT_TYPE.Value.ToString2();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "doInsert", new object[] { mat_entity });//添加操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
- return;
- }
- if (mat_entity.MeteringFlag.Equals("1"))
- {
- // 添加数据到计量系统
- string json = JSONFormat.Format(mat_entity);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.hnshituo.pur.configure.service.impl.MeterBaseMatterInforService";
- ccp.MethodName = "insert";
- ccp.ServerParams = new object[] { json };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- }
- MessageUtil.ShowTips("添加成功!");
- if (ulTreeMat.ActiveNode != null)
- {
- MatEntity mM = new MatEntity();
- mM.ArcCode = ulTreeMat.ActiveNode.Key;
- //mM.Validflag = "1";
- getMat(mM);//刷新物料
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
- }
- }
- else
- {
- MessageUtil.ShowTips("请选择物料分类");
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "0")//增加供应商
- {
- if (ultraGrid1.ActiveRow != null)
- {
- if (txt_suppCode.Text.Trim() == "")
- {
- MessageUtil.ShowTips("请选择供应商");
- return;
- }
- Supp EntitySupp = this.execute<Supp>("com.hnshituo.pur.configure.service.SuppService", "findById", new object[] { txt_suppCode.Text });
- MatEntity mat_entity = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() });
- Entity_SuppGrade EntitySuppGrade = new Entity_SuppGrade();
- EntitySuppGrade.SuppCode = EntitySupp.SuppCode;
- EntitySuppGrade.ItemCode = mat_entity.ItemCode;
- if (isExsitRow("com.hnshituo.pur.configure.service.SuppGradeService", EntitySuppGrade) > 0)//包含相同的文件
- {
- MessageUtil.ShowTips("数据库中存在相同的供应商,请重新选择");
- return;
- }
- EntitySuppGrade.SuppName = EntitySupp.SuppName;
- EntitySuppGrade.SuppShortName = EntitySupp.SuppShortName;
- EntitySuppGrade.SuppPerGrade = EntitySupp.SuppCreditRate;
- EntitySuppGrade.IsDefault = txt_IS_DEFAULT.Value == null ? null : txt_IS_DEFAULT.Value.ToString();
- EntitySuppGrade.ItemCode = mat_entity.ItemCode;
- EntitySuppGrade.ItemDesc = mat_entity.ItemDesc;
- EntitySuppGrade.ItemDescE = mat_entity.ItemDescE;
- EntitySuppGrade.ItemName = mat_entity.ItemName;
- //EntitySuppGrade.BuyerRoleId = QstrBUYER_ROLE_ID1;
- //EntitySuppGrade.PlannerRoleName = QstrPLANNER_ROLE_ID1;
- //EntitySuppGrade.BuyerRoleName = txt_BUYER_ROLE_NAME1.Text;
- //EntitySuppGrade.PlannerRoleName = txt_PLANNER_ROLE_NAME1.Text;
- if (txt_delivery_type_2.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择交货差方式");
- txt_delivery_type_2.Focus();
- return;
- }
- EntitySuppGrade.DelvryRangeTpe = txt_delivery_type_2.Value.ToString().Trim();//交货量差方式
- if ("1" == txt_delivery_type_2.Value.ToString().Trim() || "2" == txt_delivery_type_2.Value.ToString().Trim())
- {
- if (txt_DELVRY_RANGE_MIN2.Value != null)
- {
- EntitySuppGrade.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN2.Value.ToString());//交货量差下限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差下限值");
- txt_DELVRY_RANGE_MIN2.Focus();
- return;
- }
- if (txt_DELVRY_RANGE_MAX2.Value != null)
- {
- EntitySuppGrade.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX2.Value.ToString());//交货量差上限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差上限值");
- txt_DELVRY_RANGE_MAX2.Focus();
- return;
- }
- }
- else
- {
- EntitySuppGrade.DelvryRangeMin = 0;
- EntitySuppGrade.DelvryRangeMax = 0;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SuppGradeService", "insertSuppGrade", new object[] { EntitySuppGrade });//添加操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功!");
- getSuppGrade(ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());//刷新供应商
- ConfigureClassCommon.doActiveSelRow(ultraGrid2, "SUPPCODE", EntitySuppGrade.SuppCode);//激活当前行
- }
- else
- {
- MessageUtil.ShowTips("请选择供应商");
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "1")//增加属性
- {
- if (ultraGrid1.ActiveRow != null)
- {
- if (txt_ITEM_ATTR.Text.Trim() == "")
- {
- MessageUtil.ShowTips("请选择属性");
- return;
- }
- if (txt_IS_DEFAULT_ATTR.Value == null)
- {
- MessageUtil.ShowTips("请选择“是否常用”");
- txt_IS_DEFAULT_ATTR.Focus();
- return;
- }
- if (txt_IsLevel.Value == null)
- {
- MessageUtil.ShowTips("请选择“是否判定等级”");
- txt_IsLevel.Focus();
- return;
- }
-
- if (txt_IS_DEFAULT_ATTR.Text.ToString() == "常用")
- {
- for (int i = 0; i < ultraGrid3.Rows.Count; i++)
- {
- if (ultraGrid3.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid3.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
- {
- MessageUtil.ShowTips("只能有一个属性作为常用,请将此属性选为不常用");
- return;
- }
- }
- }
- PurMatAttrsEntity mat_entity = new PurMatAttrsEntity();
- //判断数据库中已经存在所选物料相同的属性名称
- mat_entity.ItemAttr = txt_ITEM_ATTR.Text.Trim();//属性名称
- mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- mat_entity.Validflag = "1";
- //if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
- //{
- // MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的属性名称");
- // return;
- //}
- mat_entity.ItemAttr = null;
- mat_entity.ItemAttrCode = txt_ITEM_ATTR_CODE.Text;//属性编码
- if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
- {
- MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的属性编码");
- mat_entity.ItemAttr = null;//型号规格
- return;
- }
- mat_entity.ItemAttr = txt_ITEM_ATTR.Text.Trim();//属性名称
- mat_entity.ItemAttrId = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getMaxSeq", new object[] { "PUR_MAT_ATTRS", "ITEM_ATTR_ID" });//属性ID
- //if (ultChkSuppUon.Checked)
- //{
- // 判断数据库中已经存在所选物料相同的采购单位
- // mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- // mat_entity.ItemUom = Ultcmb_ITEM_UOM.Text.Trim();//采购单位(个、袋、桶)
- // if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
- // {
- // MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的单位名称");
- // mat_entity.ItemUom = null;//采购单位(个、袋、桶)
- // return;
- // }
- // mat_entity.ItemUseUom = "1";// 是否使用采购单位,0:否,1:是
- // mat_entity.ItemUom = Ultcmb_ITEM_UOM.Text.Trim();//采购单位(个、袋、桶)
- // double num = 0;
- // double.TryParse(txt_ITEM_UOM_CONEFFICIENT.Text, out num);
- // mat_entity.ItemUomConefficient = num;//转换系数
- //}
- //else
- //{
- // mat_entity.ItemUseUom = "0";// 是否使用采购单位,0:否,1:是
- // mat_entity.ItemUom = ultraGrid1.ActiveRow.Cells["WEIGHTUNIT"].Value.ToString();//库存单位赋给采购单位
- // mat_entity.ItemUomConefficient = 1;
- //}
- //mat_entity.ItemAttrId = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber", new object[] { "PUR_MAT_ATTRS", "ITEM_ATTR_ID", ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString()+"@", "3" });//添加操作
- //mat_entity.ItemAttr = txt_ITEM_ATTR.Text.Trim();//型号规格
- mat_entity.ItemAttr4 = txt_item_Attr4.Text;//物料属性4
- mat_entity.ItemAttr3 = txt_item_Attr3.Text;//物料属性3
- mat_entity.ItemAttr2 = txt_item_Attr2.Text;//物料属性2
- mat_entity.ItemAttr1 = txt_item_Attr1.Text;//物料属性1
- //mat_entity.OrderNum = txt_ORDER_NUM.Value == null ? double.Parse(txt_ORDER_NUM.NullText) : double.Parse(txt_ORDER_NUM.Value.ToString());//排序
- mat_entity.IsDefault = txt_IS_DEFAULT_ATTR.Value.ToString();//是否常用
- mat_entity.IsLevel = txt_IsLevel.Value.ToString();//是否常用
- mat_entity.Remark = txt_REMARK_ATTR.Text;//备注
- mat_entity.ItemAttrClass = txt_MatAttrClass.Text;//属性分类编码
- mat_entity.ItemAttrClassName = txt_MatAttrClassName.Text;//属性分类名称
- mat_entity.CreateTime = System.DateTime.Now;//创建时间
- mat_entity.CreateName = UserInfo.GetUserName();
- mat_entity.CreateUserid = UserInfo.GetUserID();
- mat_entity.UpdateTime = null;
- mat_entity.UpdateName = null;
- mat_entity.UpdateUserid = null;
- mat_entity.Validflag = "1";
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatAttrsService", "doInsert", new object[] { mat_entity });//添加操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功!");
- getItemAttr();//查询规格
- ConfigureClassCommon.doActiveSelRow(ultraGrid3, "ITEMATTRID", mat_entity.ItemAttrId);//激活当前行
- }
- else
- {
- MessageUtil.ShowTips("请选择物料");
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "2")//标准编号
- {
- PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
- if (txt_IS_DEFAULT_STANDRANDS.Text.ToString() == "常用")
- {
- for (int i = 0; i < ultraGrid4.Rows.Count; i++)
- {
- if (ultraGrid4.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid4.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
- {
- MessageUtil.ShowTips("只能有一个标准编号作为常用,请将此标准编号选为不常用");
- return;
- }
- }
- }
- PurMatStandards_Entity.StandardsCode = txt_STANDARDS_CODE.Text;
- PurMatStandards_Entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- PurMatStandards_Entity.Validflag = "1";
- if (isExsitRow("com.hnshituo.pur.configure.service.MatStandardsService", PurMatStandards_Entity) > 0)
- {
- MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的标准编号");
- return;
- }
- PurMatStandards_Entity.ItemStandardsId = Guid.NewGuid().ToString();//this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getMaxSeq", new object[] { "PUR_MAT_STANDARDS", "ITEM_ATTR_ID" });//标准编号ID;
- PurMatStandards_Entity.StandardsId = txt_STANDARDS_ID.Text;//标准编号ID
- PurMatStandards_Entity.IsDefault = txt_IS_DEFAULT_STANDRANDS.Value.ToString();
- PurMatStandards_Entity.Remark = txt_REMARK_STANDARD.Text;//备注
- //PurMatStandards_Entity.OrderNum = txtORDER_NUM.Text.Trim() == "" ? 0 : double.Parse(txtORDER_NUM.Text);//排序
- //PurMatStandards_Entity.PurStandardsCode = txtPUR_STANDARDS_CODE.Text;//采购标准编号
- PurMatStandards_Entity.CreateName = UserInfo.GetUserName();
- PurMatStandards_Entity.CreateUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatStandardsService", "doInsert", new object[] { PurMatStandards_Entity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功!");
- getMatStandard();
- ConfigureClassCommon.doActiveSelRow(ultraGrid4, "StandardsId", PurMatStandards_Entity.StandardsId);//激活当前行
- }
- else if (ultraTabControl1.SelectedTab.Key == "3")//增加单位转换
- {
- if (txt_IS_DEFAULT_UOM.Text.ToString() == "常用")
- {
- for (int i = 0; i < ultraGrid5.Rows.Count; i++)
- {
- if (ultraGrid5.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid5.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
- {
- MessageUtil.ShowTips("只能有一个单位作为常用,请将此单位选为不常用");
- return;
- }
- }
- }
- PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
- MatUomsEntity.Validflag = "1";
- MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- MatUomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
- if (isExsitRow("com.hnshituo.pur.configure.service.MatUomsService", MatUomsEntity) > 0)
- {
- MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的采购单位名称");
- return;
- }
- if (txt_UOM_NAME.Text.Trim()=="")
- {
- MessageUtil.ShowTips("单位编码不能为空,请联系管理员 ");
- return;
- }
- if (txt_WEIGHT_UNIT.Text.Trim() == "")
- {
- MessageUtil.ShowTips("库存单位不能为空 ");
- return;
- }
- MatUomsEntity.ItemUomId = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getMaxSeq", new object[] { "PUR_MAT_UOMS", "ITEM_UOM_ID" });//标准编号ID;
- MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- MatUomsEntity.ItemUomConefficient = txt_ITEM_UOM_CONEFFICIENT.Text.Trim() == "" ? 0 : double.Parse(txt_ITEM_UOM_CONEFFICIENT.Text);//转换系数
- MatUomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE.Text;//库存单位编码
- MatUomsEntity.WeightUnit = txt_WEIGHT_UNIT.Text;//库存单位名称
- MatUomsEntity.UomCode = txt_UOM_CODE.Text;//采购单位名称
- MatUomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
- MatUomsEntity.Remark = txt_REMARK_UOM.Text;//备注
- MatUomsEntity.IsDefault = txt_IS_DEFAULT_UOM.Value.ToString();//是否常用
- MatUomsEntity.Validflag = "1";
- MatUomsEntity.CreateName = UserInfo.GetUserName();
- MatUomsEntity.CreateUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatUomsService", "doInsert", new object[] { MatUomsEntity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功!");
- getMatUOM();
- ConfigureClassCommon.doActiveSelRow(ultraGrid5, "ITEMUOMID", MatUomsEntity.ItemUomId);//激活当前行
- }
- }
- /// <summary>
- /// 判断数据库中是否存在相同的列
- /// </summary>
- /// <param name="strJavaPackName"></param>
- /// <param name="o"></param>
- /// <returns>true存在</returns>
- public int isExsitRow(string strJavaPackName, object o)
- {
- DataTable dt = this.execute<DataTable>(strJavaPackName, "find", new object[] { o, 0, 0 });
- if (dt != null && dt.Rows.Count > 0)//存在相同的行
- {
- return dt.Rows.Count;
- }
- return 0;
- }
- /// <summary>
- /// 判断数据库中是否存在相同的列
- /// </summary>
- /// <param name="strJavaPackName"></param>
- /// <param name="o"></param>
- /// <returns>true存在</returns>
- public int isExsitRow(string strJavaPackName,string methodName, object o)
- {
- DataTable dt = this.execute<DataTable>(strJavaPackName, methodName, new object[] { o });
- if (dt != null && dt.Rows.Count > 0)//存在相同的行
- {
- return dt.Rows.Count;
- }
- return 0;
- }
- /// <summary>
- /// 更新物料
- /// </summary>
- public void UpdPUR_MAT()
- {
-
- if (ultraTabControl1.SelectedTab.Key == "01")
- {
-
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr != null)
- {
- //合法验证
- if (ugr.Cells["VALIDFLAG"].Value.ToString() == "作废")
- {
- MessageUtil.ShowTips("此物料已作废,不能修改");
- return;
- }
- if (txt_ITEM_CODE.Text.Trim() != ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString().Trim())//修改了物料编码
- {
- MessageUtil.ShowTips("物料编码不能修改");
- return;
- }
- if (Ultcmb_BATCH_FLAG.Text != "")
- {
- if (Ultcmb_BATCH_FLAG.Value.ToString() != ultraGrid1.ActiveRow.Cells["BATCHFLAG"].Value.ToString().Trim())//修改了是否批次控制
- {
- MessageUtil.ShowTips("“是否控制批次”不能修改");
- return;
- }
- }
- //修改库存单位
- if (Ultcmb_WEIGHT_UNIT.Text.ToString() != ultraGrid1.ActiveRow.Cells["WEIGHTUNIT"].Value.ToString().Trim())
- {
- RequirePlanD rq=new RequirePlanD();
- rq.ItemCode = ultraGrid1.ActiveRow.Cells["ItemCode"].Value.ToString();
- rq.Validflag = "1";
- int num= this.GetJsonService().execute<int>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "count", new object[] { rq, 0, 0 });
- if (num > 0)
- {
- MessageUtil.ShowTips("此物料已有需求,不能更改库存单位");
- return;
- }
- PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
- MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ItemCode"].Value.ToString();
- int num1 = this.execute<int>("com.hnshituo.pur.configure.service.MatUomsService", "count", new object[] { MatUomsEntity });
- if (num1 > 0)
- {
- MessageUtil.ShowTips("如要修改库存单位,请先删除此物料的采购单位");
- return;
- }
- }
-
-
- UltraTreeNode ultNode = ulTreeMat.ActiveNode;
- MatEntity mat_entity = new MatEntity();
- if (txt_ITEM_NAME.Text.Trim() == "")
- {
- MessageUtil.ShowTips("请输入物料名称");
- return;
- }
- if (cb_BASE_UNIT_FLAG.Checked)
- {
- if (txt_BASE_UNIT_VALUE.Text == "" || !StringUtil.IsNumber(txt_BASE_UNIT_VALUE.Text))
- {
- MessageUtil.ShowTips("基吨值不能为空,且必须为数字");
- return;
- }
- if (txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') == -1 && txt_BASE_UNIT_VALUE.Text.Trim().Length > 6)
- {
- MessageUtil.ShowTips("基吨值整数长度不超过6位");
- return;
- }
- if (txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') != -1 && txt_BASE_UNIT_VALUE.Text.Trim().Length > 6)
- {
- if (txt_BASE_UNIT_VALUE.Text.Trim().Substring(0, txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.')).Length > 6)
- {
- MessageUtil.ShowTips("基吨值整数长度不超过6位");
- return;
- }
- if (txt_BASE_UNIT_VALUE.Text.Trim().Substring(txt_BASE_UNIT_VALUE.Text.Trim().IndexOf('.') + 1).Length > 6)
- {
- MessageUtil.ShowTips("基吨值小数长度不超过6位");
- return;
- }
- }
- }
- mat_entity.ItemName = txt_ITEM_NAME.Text.Replace(" ", "");
- if (txt_ITEM_NAME.Text != ultraGrid1.ActiveRow.Cells["ITEMNAME"].Value.ToString())//修改了物料名称
- {
- if (isExsitRow("com.hnshituo.pur.configure.service.MatService", "isExsitItemName", mat_entity) > 0)
- {
- MessageUtil.ShowTips("修改失败 " + "数据库中已存在相同的物料名称");
- return;
- }
- }
- //修改分类
- mat_entity.ArcCode = txt_ItemArcCode.Text;
- mat_entity.ArcItem=txt_ItemArcCodeName.Text;
- if (cb_BASE_UNIT_FLAG.Checked)//基顿标识
- {
- mat_entity.BaseUnitFlag = "1";
- mat_entity.BaseUnitValue = double.Parse(txt_BASE_UNIT_VALUE.Text);
- }
- else
- {
- mat_entity.BaseUnitFlag = "0";
- }
- mat_entity.IsBudgetCtrl = txt_IS_BUDGET_CTRL.Value == null ? null : txt_IS_BUDGET_CTRL.Value.ToString();//是否定额控制
- mat_entity.PcFlag = txt_PC_FLAG.Value == null ? null : txt_PC_FLAG.Value.ToString();//是检化验
- if (txt_DELVRY_RANGE_TPE.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择交货量差方式");
- txt_DELVRY_RANGE_TPE.Focus();
- return;
- }
- mat_entity.DelvryRangeTpe = txt_DELVRY_RANGE_TPE.Value.ToString().Trim();//交货量差方式
- if ("1" == txt_DELVRY_RANGE_TPE.Value.ToString().Trim() || "2" == txt_DELVRY_RANGE_TPE.Value.ToString().Trim())
- {
- if (txt_DELVRY_RANGE_MIN.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MIN.Value.ToString().Trim()))
- {
- mat_entity.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN.Value.ToString());//交货量差下限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差下限值");
- txt_DELVRY_RANGE_MIN.Focus();
- return;
- }
- if (txt_DELVRY_RANGE_MAX.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MAX.Value.ToString().Trim()))
- {
- mat_entity.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX.Value.ToString());//交货量差上限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差上限值");
- txt_DELVRY_RANGE_MAX.Focus();
- return;
- }
- }
- else
- {
- mat_entity.DelvryRangeMin = 0;
- mat_entity.DelvryRangeMax = 0;
- }
- mat_entity.WeightUnit = Ultcmb_WEIGHT_UNIT.Text;//库存单位
- mat_entity.WeightUnitCode = Ultcmb_WEIGHT_UNIT_CODE.Text;//库存单位编码
- mat_entity.ReceiveType = Ultcmb_RECEIVE_TYPE.Value == null ? null : Ultcmb_RECEIVE_TYPE.Value.ToString();//入库类型;1:直接入库2:收货质检入库3:JIT入库4:VMI入库
- mat_entity.BatchFlag = Ultcmb_BATCH_FLAG.Value == null ? null : Ultcmb_BATCH_FLAG.Value.ToString();//是否批次控制
- mat_entity.PurStandards = Ultcmb_PUR_STANDARDS.Value == null ? null : Ultcmb_PUR_STANDARDS.Value.ToString();//采购标准
- mat_entity.InvWasteFacUom = Ultcmb_INV_WASTE_FAC_UOM.Value == null ? 0 : double.Parse(Ultcmb_INV_WASTE_FAC_UOM.Value.ToString());//库存损耗率单位
- //mat_entity.ShareCkSpecFlag = Ultcmb_SHARE_CK_SPEC_FLAG.Value == null ? null : Ultcmb_SHARE_CK_SPEC_FLAG.Value.ToString();//是否与子规格共用库存
- mat_entity.MeteringFlag = Ultcmb_METERING_FLAG.Value == null ? null : Ultcmb_METERING_FLAG.Value.ToString();//是否计量
- mat_entity.PriceType = Ultcmb_PRICE_TYPE.Text;//计价类型
- mat_entity.CurrencyCode = Ultcmb_CURRENCY_CODE.Text;//币种代码
- mat_entity.LifeCycleUom = Ultcmb_LIFE_CYCLE_UOM.Text;//有效期单位
- mat_entity.PurStandardsCode = txt_PUR_STANDARDS_CODE.Text;//采购标准编号
- mat_entity.MinStock = txt_MIN_STOCK.Text.Trim() == "" ? 0 : double.Parse(txt_MIN_STOCK.Text);//最小库存(预警)
- mat_entity.MaxStock = txt_MAX_STOCK.Text.Trim() == "" ? 0 : double.Parse(txt_MAX_STOCK.Text);//最大库存(预警)
- mat_entity.LeadTime = txt_LEAD_TIME.Text.Trim() == "" ? 0 : double.Parse(txt_LEAD_TIME.Text);//采购提前时间(天)
- mat_entity.InvWasteFac = txt_INV_WASTE_FAC.Text.Trim() == "" ? 0 : double.Parse(txt_INV_WASTE_FAC.Text);//库存损耗率
- mat_entity.LifeCycle = txt_LIFE_CYCLE.Text.Trim() == "" ? 0 : double.Parse(txt_LIFE_CYCLE.Text);//有效期
- mat_entity.MinQty = txt_MIN_QTY.Text.Trim() == "" ? 0 : double.Parse(txt_MIN_QTY.Text);//最小采购数量
- mat_entity.QtyMultiple = txt_QTY_MULTIPLE.Text.Trim() == "" ? 0 : double.Parse(txt_QTY_MULTIPLE.Text);//批量数
- if (planPrice != txt_BUG_PRICE.Text)
- {
- if (UserInfo.GetDepartment() != "综合管理科" && UserInfo.GetUserName() != "admin")
- {
- MessageUtil.ShowTips("不是综合管理科人员,不允许修改计划价!");
- //txt_BUG_PRICE.Enabled = false;
- return;
- }
- else
- {
- mat_entity.BugPrice = txt_BUG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_BUG_PRICE.Text);//计划价
- }
- }
- else
- {
- mat_entity.BugPrice = txt_BUG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_BUG_PRICE.Text);//计划价
- }
- mat_entity.LastPrice = txt_LAST_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_LAST_PRICE.Text);//最近采购价
- mat_entity.MonthEndAvgPrice = txt_MONTH_END_AVG_PRICE.Text.Trim() == "" ? 0 : double.Parse(txt_MONTH_END_AVG_PRICE.Text);//月末移动平均价
- mat_entity.ItemName = txt_ITEM_NAME.Text.Trim().Replace(" ", " ").Replace("(", "(").Replace(")", ")");//物料名称
- mat_entity.ItemDescE = txt_ITEM_DESC_E.Text;//物料英文名称
- mat_entity.ItemDesc = txt_ITEM_DESC.Text;//物料描述
- mat_entity.ItemModel = txt_ITEM_MODEL.Text;//物料材质
- mat_entity.ItemSpec = txt_ITEM_SPEC.Text;//物料型号规格
- mat_entity.BuyerRoleId = QstrBUYER_ROLE_ID;
- mat_entity.PlannerRoleId = QstrPLANNER_ROLE_ID;
- mat_entity.BuyerRoleName = txt_BUYER_ROLE_NAME.Text;
- mat_entity.PlannerRoleName = txt_PLANNER_ROLE_NAME.Text;
- mat_entity.InvPhysicUserid = QstrINV_PHYSIC_USERID;//库管员
- mat_entity.InvPhysicUsername = txt_INV_PHYSIC_USERID.Text;//库管员名称
- //mat_entity.BuyerUnitCode = strBUYER_DEPT_CODE;//采购科室代码
- //mat_entity.BuyerUnitDesc = txt_BUYER_UNITCODE.Text;//采购科室描述
- //mat_entity.MentUnitCode = strMENT_UNIT_CODE;//采购管理科室代码
- ///mat_entity.MentUnitDesc = txt_MENT_UNIT_CODE.Text;//采购管理科室代码
- // 是否使用采购单位
- //if (ultChkSuppUon.Checked)
- //{
- // mat_entity.ItemUseUom = "1";// 是否使用采购单位,0:否,1:是
- // mat_entity.ItemUom = Ultcmb_ITEM_UOM.Text;//采购单位(个、袋、桶)
- // double num = 0;
- // double.TryParse(txt_ITEM_UOM_CONEFFICIENT.Text, out num);
- // mat_entity.ItemUomConefficient = num;//转换系数
- //}
- //else
- //{
- // mat_entity.ItemUseUom = "0";// 是否使用采购单位,0:否,1:是
- // mat_entity.ItemUom = Ultcmb_WEIGHT_UNIT.Text;//库存单位赋给采购单位
- //}
- mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- mat_entity.UpdateTime = System.DateTime.Now;
- mat_entity.UpdateName = UserInfo.GetUserName();
- mat_entity.UpdateUserid = UserInfo.GetUserID();
- mat_entity.MatType = Ultcmb_MAT_TYPE.Value.ToString2();
-
- if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料【" + ultraGrid1.ActiveRow.Cells["ITEMNAME"].Value.ToString().Trim() + "】?") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "doUpdate", new object[] { mat_entity });//更新操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("更新失败 " + crt.Resultmsg);
- return;
- }
- if (mat_entity.MeteringFlag.Equals("1"))
- {
- // 更新数据到计量系统
- string json = JSONFormat.Format(mat_entity);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.hnshituo.pur.configure.service.impl.MeterBaseMatterInforService";
- ccp.MethodName = "update";
- ccp.ServerParams = new object[] { json };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- }
- MessageUtil.ShowTips("更新成功");
- if (ulTreeMat.ActiveNode != null)
- {
- //MatEntity mM = new MatEntity();
- //mM.ArcCode = ulTreeMat.ActiveNode.Key;
- getMat(Q_mat);//刷新物料
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
- }
- }
- else
- {
- MessageUtil.ShowTips("请选择物料");
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "0")
- {
- if (ultraGrid2.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择供应商");
- return;
- }
- if (ultraGrid2.ActiveRow.Cells["SUPPCODE"].Value.ToString() != txt_suppCode.Text)
- {
- MessageUtil.ShowTips("修改失败 供应商代码和名称不修改");
- return;
- }
- Entity_SuppGrade EntitySuppGrade = new Entity_SuppGrade();
- EntitySuppGrade.Id = ultraGrid2.ActiveRow.Cells["id"].Value.ToString();
- //EntitySuppGrade.SuppCode = txt_suppCode.Text;
- if (txt_IS_DEFAULT.Value != null)
- {
- EntitySuppGrade.IsDefault = txt_IS_DEFAULT.Value.ToString();
- }
- if (txt_delivery_type_2.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择交货差方式");
- txt_delivery_type_2.Focus();
- return;
- }
- EntitySuppGrade.DelvryRangeTpe = txt_delivery_type_2.Value.ToString().Trim();//交货量差方式
- if ("1" == txt_delivery_type_2.Value.ToString().Trim() || "2" == txt_delivery_type_2.Value.ToString().Trim())
- {
- if (txt_DELVRY_RANGE_MIN2.Value != null &&! String.IsNullOrEmpty(txt_DELVRY_RANGE_MIN2.Value.ToString().Trim()))
- {
- EntitySuppGrade.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN2.Value.ToString());//交货量差下限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差下限值");
- txt_DELVRY_RANGE_MIN2.Focus();
- return;
- }
- if (txt_DELVRY_RANGE_MAX2.Value != null && !String.IsNullOrEmpty(txt_DELVRY_RANGE_MAX2.Value.ToString().Trim()))
- {
- EntitySuppGrade.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX2.Value.ToString());//交货量差上限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差上限值");
- txt_DELVRY_RANGE_MAX2.Focus();
- return;
- }
- }
- else
- {
- EntitySuppGrade.DelvryRangeMin = 0;
- EntitySuppGrade.DelvryRangeMax = 0;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确定修改供应商【" + ultraGrid2.ActiveRow.Cells["suppName"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SuppGradeService", "doUpdate", new object[] { EntitySuppGrade });//更新操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("更新失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("修改成功!");
- getSuppGrade(ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());//刷新供应商
- ConfigureClassCommon.doActiveSelRow(ultraGrid2, "Id", EntitySuppGrade.Id);//激活当前行
- }
- else if (ultraTabControl1.SelectedTab.Key == "1")//修改属性
- {
- if (ultraGrid3.ActiveRow != null)
- {
- if (txt_ITEM_ATTR.Text.Trim() == "")
- {
- MessageUtil.ShowTips("请输入属性");
- return;
- }
- if (txt_IS_DEFAULT_ATTR.Text.ToString() == "常用")
- {
- for (int i = 0; i < ultraGrid3.Rows.Count; i++)
- {
- if (ultraGrid3.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid3.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
- {
- if (!ultraGrid3.Rows[i].IsActiveRow)
- {
- MessageUtil.ShowTips("只能有一个属性作为常用,请将此属性选为不常用");
- return;
- }
- }
- }
- }
- PurMatAttrsEntity mat_entity = new PurMatAttrsEntity();
- //判断数据库中已经存在所选物料相同的属性名称
- mat_entity.ItemAttr = txt_ITEM_ATTR.Text.Trim();//属性名称
- mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- mat_entity.Validflag = "1";
- if (txt_ITEM_ATTR.Text.Trim() != ultraGrid3.ActiveRow.Cells["ItemAttr"].Value.ToString())
- {
- if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
- {
- MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的属性名称");
- return;
- }
- }
- mat_entity.ItemAttrId = ultraGrid3.ActiveRow.Cells["ITEMATTRID"].Value.ToString();//属性Id
- mat_entity.ItemAttrCode = txt_ITEM_ATTR_CODE.Text;//属性编码
- mat_entity.ItemAttr4 = txt_item_Attr4.Text;//物料属性4
- mat_entity.ItemAttr3 = txt_item_Attr3.Text;//物料属性3
- mat_entity.ItemAttr2 = txt_item_Attr2.Text;//物料属性2
- mat_entity.ItemAttr1 = txt_item_Attr1.Text;//物料属性1
- mat_entity.IsDefault = txt_IS_DEFAULT_ATTR.Value.ToString();//是否常用
- mat_entity.IsLevel = txt_IsLevel.Value.ToString();//是否常用
- mat_entity.Remark = txt_REMARK_ATTR.Text;//备注
- mat_entity.UpdateTime = System.DateTime.Now;//更新时间
- mat_entity.UpdateName = UserInfo.GetUserName();
- mat_entity.UpdateUserid = UserInfo.GetUserID();
- if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料属性【" + ultraGrid3.ActiveRow.Cells["ItemAttr"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatAttrsService", "doUpdate", new object[] { mat_entity });//添加操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("更新失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("更新成功!");
- getItemAttr();//查询属性
- ConfigureClassCommon.doActiveSelRow(ultraGrid3, "ITEMATTRID", mat_entity.ItemAttrId);//激活当前行
- }
- else
- {
- MessageUtil.ShowTips("请选择物料");
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "2")//修改标准编号
- {
- if (ultraGrid4.ActiveRow != null)
- {
- if (txt_IS_DEFAULT_STANDRANDS.Text.ToString() == "常用")
- {
- for (int i = 0; i < ultraGrid4.Rows.Count; i++)
- {
- if (ultraGrid4.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid4.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
- {
- if (!ultraGrid4.Rows[i].IsActiveRow)
- {
- MessageUtil.ShowTips("只能有一个标准编号作为常用,请将此标准编号选为不常用");
- return;
- }
- }
- }
- }
- PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
- if (ultraGrid4.ActiveRow.Cells["StandardsCode"].Value.ToString() != txt_STANDARDS_CODE.Text)
- {
- PurMatStandards_Entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- PurMatStandards_Entity.StandardsCode = txt_STANDARDS_CODE.Text;//采购标准编号
- PurMatStandards_Entity.Validflag = "1";
- if (isExsitRow("com.hnshituo.pur.configure.service.MatStandardsService", PurMatStandards_Entity) > 0)
- {
- MessageUtil.ShowTips("更新失败 数据库中已经存在所选物料相同的标准编号");
- return;
- }
- }
- //PurMatStandards_Entity.Id = ultraGrid4.ActiveRow.Cells["ID"].Value.ToString();
- //PurMatStandards_Entity.StandardsId = txt_STANDARDS_ID.Text;
- PurMatStandards_Entity.Validflag = "1";
- PurMatStandards_Entity.IsDefault = txt_IS_DEFAULT_STANDRANDS.Value.ToString();//是否为常用
- PurMatStandards_Entity.Remark = txt_REMARK_STANDARD.Text;//备注
- //PurMatStandards_Entity.OrderNum = txtORDER_NUM.Text.Trim() == "" ? 0 : double.Parse(txtORDER_NUM.Text);//排序
- PurMatStandards_Entity.ItemStandardsId = ultraGrid4.ActiveRow.Cells["ITEMSTANDARDSID"].Value.ToString();//采购标准编号
- PurMatStandards_Entity.UpdateName = UserInfo.GetUserName();
- PurMatStandards_Entity.UpdateUserid = UserInfo.GetUserID();
- if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料标准编号【" + ultraGrid4.ActiveRow.Cells["StandardsCode"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatStandardsService", "doUpdate", new object[] { PurMatStandards_Entity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("更新失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("更新成功!");
- getMatStandard();
- ConfigureClassCommon.doActiveSelRow(ultraGrid4, "ITEMSTANDARDSID", PurMatStandards_Entity.ItemStandardsId);//激活当前行
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "3")//修改单位转换
- {
- //MessageUtil.ShowTips("物料单位不能修改,请添加或作废");
- //return;
- if (ultraGrid5.ActiveRow != null)
- {
- PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
- if (txt_IS_DEFAULT_UOM.Text.ToString() == "常用")
- {
- for (int i = 0; i < ultraGrid5.Rows.Count; i++)
- {
- if (ultraGrid5.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "常用" || ultraGrid5.Rows[i].Cells["ISDEFAULT"].Value.ToString() == "是")
- {
- if (!ultraGrid5.Rows[i].IsActiveRow)
- {
- MessageUtil.ShowTips("只能有一个单位作为常用,请将此单位选为不常用");
- return;
- }
- }
- }
- }
- MatUomsEntity.ItemUomId = ultraGrid5.ActiveRow.Cells["ITEMUOMID"].Value.ToString();
- //MatUomsEntity.ItemUomConefficient = txt_ITEM_UOM_CONEFFICIENT.Text.Trim() == "" ? 0 : double.Parse(txt_ITEM_UOM_CONEFFICIENT.Text);//转换系数
- MatUomsEntity.IsDefault = txt_IS_DEFAULT_UOM.Value == null ? null : txt_IS_DEFAULT_UOM.Value.ToString();//是否常用
- //MatUomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE.Text;//库存单位编码
- //MatUomsEntity.WeightUnit = txt_WEIGHT_UNIT.Text;//库存单位名称
- //MatUomsEntity.UomCode = txt_UOM_CODE.Text;//采购单位名称
- //MatUomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
- MatUomsEntity.Remark = txt_REMARK_UOM.Text;//备注
- MatUomsEntity.UpdateName = UserInfo.GetUserName();
- MatUomsEntity.UpdateUserid = UserInfo.GetUserID();
- if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料采购单位【" + ultraGrid5.ActiveRow.Cells["UomName"].Value.ToString() + "】? 注:物料单位只能修改是否常用和备注") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatUomsService", "doUpdate", new object[] { MatUomsEntity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("修改成功!");
- getMatUOM();
- ConfigureClassCommon.doActiveSelRow(ultraGrid5, "ITEMUOMID", MatUomsEntity.ItemUomId);//激活当前行
- }
- }
- }
- /// <summary>
- /// 删除物料
- /// </summary>
- public void DelPUR_MAT()
- {
- if (ultraTabControl1.SelectedTab.Key == "01")
- {
- if (ultraGrid1.ActiveRow != null)
- {
- if (MessageUtil.ShowYesNoAndQuestion("确定作废物料【" + ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- //string resStr = "";
- //resStr = this.execute<string>("com.hnshituo.pur.configure.service.MatService", "MatIsUsing", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString(), null });//删除操作
- //if (resStr != "")
- //{
- // MessageUtil.ShowTips("物料在" + resStr + "中使用,不能作废");
- // return;
- //}
- MatEntity mat_entity = new MatEntity();
- mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- mat_entity.Validflag = "0";
- mat_entity.DeleteName = UserInfo.GetUserName();
- mat_entity.DeleteTime = System.DateTime.Now;
- mat_entity.DeleteUserid = UserInfo.GetUserID();
- mat_entity.ArcCode = ulTreeMat.ActiveNode.Key;//物料只保存分类编码,不保存父类编码
- mat_entity.ArcItem = ulTreeMat.ActiveNode.Text;//物料分类编码名称
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "doUpdate", new object[] { mat_entity });//删除操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("作废失败 " + crt.Resultmsg);
- return;
- }
- string meteringFlag = Ultcmb_METERING_FLAG.Value == null ? null : Ultcmb_METERING_FLAG.Value.ToString();//是否计量
- if (meteringFlag.Equals("1"))
- {
- // 作废 数据到计量系统
- string json = JSONFormat.Format(mat_entity);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.hnshituo.pur.configure.service.impl.MeterBaseMatterInforService";
- ccp.MethodName = "logicDelete";
- ccp.ServerParams = new object[] { json };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- }
- MessageUtil.ShowTips("作废成功!");
- if (ulTreeMat.ActiveNode != null)
- {
- //MatEntity mM = new MatEntity();
- //mM.ArcCode = ulTreeMat.ActiveNode.Key;
- getMat(Q_mat);//刷新物料
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
- }
- }
- else
- {
- MessageUtil.ShowTips("请选择物料");
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "0")
- {
- if (ultraGrid2.ActiveRow != null)
- {
- string id_SuppGrade = ultraGrid2.ActiveRow.Cells["ID"].Value.ToString().Trim();
- string id_SuppGradename = ultraGrid2.ActiveRow.Cells["SUPPNAME"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(id_SuppGrade))
- {
- MessageUtil.ShowTips("未获取该供应商关联标识,无法删除");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定要删除该物料与供应商【" + ultraGrid2.ActiveRow.Cells["SUPPNAME"].Value.ToString() + "】的挂接关系?") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SuppGradeService", "doDelete", new object[] { id_SuppGrade });//删除操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- getSuppGrade(ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());//刷新供应商
- }
- else
- {
- MessageUtil.ShowTips("请选择供应商");
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "1")
- {
- if (ultraGrid3.ActiveRow != null)
- {
- if (MessageUtil.ShowYesNoAndQuestion("确定要删除物料属性【" + ultraGrid3.ActiveRow.Cells["ItemAttr"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- //string resStr = "";
- //resStr = this.execute<string>("com.hnshituo.pur.configure.service.MatService", "MatIsUsing", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString(), ultraGrid3.ActiveRow.Cells["ITEMATTRID"].Value.ToString() });//删除操作
- //if (resStr != "")
- //{
- // MessageUtil.ShowTips("此物料的属性在" + resStr + "中使用,不能删除");
- // return;
- //}
- PurMatAttrsEntity mat_entity = new PurMatAttrsEntity();
- mat_entity.ItemAttrId = ultraGrid3.ActiveRow.Cells["ITEMATTRID"].Value.ToString();
- mat_entity.Validflag = "0";
- mat_entity.DeleteName = UserInfo.GetUserName();
- mat_entity.DeleteTime = System.DateTime.Now;
- mat_entity.DeleteUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatAttrsService", "doUpdate", new object[] { mat_entity });//删除操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- getItemAttr();//刷新物料规格
- }
- else
- {
- MessageUtil.ShowTips("请选择物料属性");
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "2")//删除标准编号
- {
- if (ultraGrid4.ActiveRow != null)
- {
- if (MessageUtil.ShowYesNoAndQuestion("确定要删除物料标准编号【" + ultraGrid4.ActiveRow.Cells["STANDARDSCODE"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
- PurMatStandards_Entity.ItemStandardsId = ultraGrid4.ActiveRow.Cells["ItemStandardsId"].Value.ToString();
- PurMatStandards_Entity.Validflag = "0";
- PurMatStandards_Entity.DeleteName = UserInfo.GetUserName();
- PurMatStandards_Entity.DeleteUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatStandardsService", "doUpdate", new object[] { PurMatStandards_Entity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- getMatStandard();
- }
- }
- else if (ultraTabControl1.SelectedTab.Key == "3")//删除单位
- {
- if (ultraGrid5.ActiveRow != null)
- {
- if (MessageUtil.ShowYesNoAndQuestion("确定要删除物料采购单位【" + ultraGrid5.ActiveRow.Cells["UOMNAME"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
- MatUomsEntity.ItemUomId = ultraGrid5.ActiveRow.Cells["ITEMUOMID"].Value.ToString();
- MatUomsEntity.Validflag = "0";
- MatUomsEntity.DeleteName = UserInfo.GetUserName();
- MatUomsEntity.DeleteUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatUomsService", "doUpdate", new object[] { MatUomsEntity});
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- getMatUOM();
- }
- }
- }
- /// <summary>
- /// 启用物料
- /// </summary>
- public void UsePUR_MAT()
- {
- if (ultraTabControl1.SelectedTab.Key == "01")
- {
- if (ultraGrid1.ActiveRow != null)
- {
- if (ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString() != "作废")
- {
- MessageUtil.ShowTips("此物料正常使用,无须再做启用操作!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定要启用物料编码【" + ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- //string resStr = "";
- //resStr = this.execute<string>("com.hnshituo.pur.configure.service.MatService", "MatIsUsing", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString(), null });//删除操作
- //if (resStr != "")
- //{
- // MessageUtil.ShowTips("物料在" + resStr + "中使用,不能删除");
- // return;
- //}
- MatEntity mat_entity = new MatEntity();
- mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- mat_entity.Validflag = "1";
- mat_entity.UpdateName = UserInfo.GetUserName();
- mat_entity.UpdateTime = System.DateTime.Now;
- mat_entity.UpdateUserid = UserInfo.GetUserID();
- mat_entity.ArcCode = ulTreeMat.ActiveNode.Key;//物料只保存分类编码,不保存父类编码
- mat_entity.ArcItem = ulTreeMat.ActiveNode.Text;//物料分类编码名称
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "doUpdate", new object[] { mat_entity });//删除操作
-
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("启用失败 " + crt.Resultmsg);
- return;
- }
- string meteringFlag = Ultcmb_METERING_FLAG.Value == null ? null : Ultcmb_METERING_FLAG.Value.ToString();//是否计量
- if (meteringFlag.Equals("1"))
- {
- // 启用 数据到计量系统
- string json = JSONFormat.Format(mat_entity);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.hnshituo.pur.configure.service.impl.MeterBaseMatterInforService";
- ccp.MethodName = "logicDelete";
- ccp.ServerParams = new object[] { json };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- }
- MessageUtil.ShowTips("启用成功!");
- if (ulTreeMat.ActiveNode != null)
- {
- //MatEntity mM = new MatEntity();
- //mM.ArcCode = ulTreeMat.ActiveNode.Key;
- getMat(Q_mat);//刷新物料
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
- }
- }
- else
- {
- MessageUtil.ShowTips("请选择物料");
- }
- }
- else//单位
- {
- if (ultraGrid5.ActiveRow==null)
- {
- MessageUtil.ShowYesNoAndQuestion("请选择要启用的单位");
- return;
- }
- MatEntity mat = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { ultraGrid1.ActiveRow.Cells["itemcode"].Value.ToString() });
- PurMatUomsEntity matUoms = this.execute<PurMatUomsEntity>("com.hnshituo.pur.configure.service.MatUomsService", "findById", new object[] { ultraGrid5.ActiveRow.Cells["itemuomid"].Value.ToString() });
- if (matUoms.WeightUnit != mat.WeightUnit)
- {
- MessageUtil.ShowTips("启用失败:因为启用的单位和物料的库存单位不一致");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定要启用单位【" + ultraGrid5.ActiveRow.Cells["UOMNAME"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
- MatUomsEntity.ItemUomId = ultraGrid5.ActiveRow.Cells["ITEMUOMID"].Value.ToString();
- MatUomsEntity.Validflag = "1";//备注
- MatUomsEntity.DeleteName = UserInfo.GetUserName();
- MatUomsEntity.DeleteUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatUomsService", "doUpdate", new object[] { MatUomsEntity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("启用失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("启用成功!");
- getMatUOM();
- ConfigureClassCommon.doActiveSelRow(ultraGrid5, "ITEMUOMID", MatUomsEntity.ItemUomId);//激活当前行
- }
-
- }
- /// <summary>
- /// 获取物料分类树形结构
- /// </summary>
- public void getultree(DataTable dt)
- {
- ulTreeMat.Nodes.Clear();
- if (dt == null || dt.Rows.Count < 1)
- {
- return;
- }
- dt_Purmatclass = dt;//保存物料分类全局变量
- DataTable dt_A = new DataTable();//物料分类
- //筛选出根节点
- DataRow[] rows = dt.Select("PARENTCODE='' or PARENTCODE is null");
- dt_A = dt.Clone(); //克隆A的结构
- foreach (DataRow row in rows)
- {
- dt_A.ImportRow(row);//复制行数据
- }
- //排序
- dt_A.DefaultView.Sort = "basename";
- dt_A = dt_A.DefaultView.ToTable();
- //添加物料大类
- for (int j = 0; j < dt_A.Rows.Count; j++)
- {
- UltraTreeNode Ultnode = ulTreeMat.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
- Ultnode.LeftImages.Add(imageList1.Images[Ultnode.Level]);
- getChildNodes(Ultnode);
- }
- }
- /// <summary>
- /// 递归查询父节点下的所有子节点
- /// </summary>
- /// <param name="Tnode"></param>
- public void getChildNodes(UltraTreeNode Tnode)
- {
- DataTable dt_A = dt_Purmatclass.Clone();//物料分类
- DataRow[] rows = dt_Purmatclass.Select("PARENTCODE='" + Tnode.Key + "'");
- foreach (DataRow row in rows)
- {
- dt_A.ImportRow(row);//复制行数据
- }
- //排序
- dt_A.DefaultView.Sort = "basename";
- dt_A = dt_A.DefaultView.ToTable();
- //添加物料分类
- for (int j = 0; j < dt_A.Rows.Count; j++)
- {
- UltraTreeNode Ultnode = Tnode.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
- try
- {
- Ultnode.LeftImages.Add(imageList1.Images[Ultnode.Level]);
- //System.Drawing.Image image = System.Drawing.Image.FromFile(Environment.CurrentDirectory+"\\images\\IL_MAINMENU_IMAGE_LARGE\\01.png");
- //Ultnode.LeftImages.Add(Environment.CurrentDirectory + "\\images\\IL_MAINMENU_IMAGE_LARGE\\01.png");
- }
- catch (Exception)
- {
-
- }
- getChildNodes(Ultnode);//利用递归将当前节点的子节点添加进去
- }
- }
- /// <summary>
- /// 选中树形结构后自动展开,并且查询出相印的物料
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ulTreeMat_AfterActivate(object sender, NodeEventArgs e)
- {
- if (!QClickCellOrQuery)//如果不是点击查询按钮或单击grig行数据,刷新右侧数据
- {
- ulTreeMat.ActiveNode.Expanded = true;
- qUltraNode = ulTreeMat.ActiveNode;
- getMat(getEnSelContion(qUltraNode.Key));
- }
- txt_ARC_CODE.Text = ulTreeMat.ActiveNode.Key;
- txt_ARC_ITEM.Text = ulTreeMat.ActiveNode.Text;
- }
- /// <summary>
- /// 查询物料规格
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow urg = ultraGrid1.ActiveRow;
- if(urg!=null)
- {
- planPrice = urg.Cells["BUGPRICE"].Text.ToString();
- }
- if (ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString() == "作废")
- {
- dataTable2.Rows.Clear();
- dataTable3.Rows.Clear();
- dataTable4.Rows.Clear();
- dataTable5.Rows.Clear();
- getControlBoxValue(0);//清空控件
- setUltCmbEdt_sel();
- }
- else
- {
- //查询物料属性
- getItemAttr();
- //查询供应商
- getSuppGrade(ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString().Trim());
- //查询物料标准编码
- getMatStandard();
- //单位
- getMatUOM();
- //给控件赋值
- getControlBoxValue(sender);
- }
- this.ultraTabControl1.SelectedTab = ultraTabPageControl1.Tab;
- UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(ultraGrid1.ActiveRow.Cells["ARCCODE"].Value.ToString());
- if (ulTreeMat.ActiveNode == uttNode)
- {
- return;
- }
- ulTreeMat.CollapseAll();
- QClickCellOrQuery = true;
- ulTreeMat.ActiveNode = uttNode;
- if (uttNode == null)
- {
- MessageUtil.ShowTips("物料名称:" + ultraGrid1.ActiveRow.Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + ultraGrid1.ActiveRow.Cells["ARCCODE"].Value.ToString());
- }
- else
- {
- while (ulTreeMat.ActiveNode != uttNode)
- {
- ulTreeMat.ActiveNode = uttNode;
- }
- uttNode.Expanded = true;
- //展开分类
- while (uttNode.Parent != null)
- {
- uttNode = uttNode.Parent;
- uttNode.Expanded = true;
- }
- }
- QClickCellOrQuery = false;//设置未点击
-
- }
- //供应商单击事件
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- getControlBoxValue(sender);
- }
- //物料规格单击事件
- private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
- {
- getControlBoxValue(sender);
- }
- private void ultraGrid5_AfterRowActivate(object sender, EventArgs e)
- {
- getControlBoxValue(sender);
- }
- /// <summary>
- /// 单击数据列表赋值数据给控件
- /// </summary>
- private void getControlBoxValue(object sender)
- {
- if (sender.Equals(ultraGrid1) || sender.Equals(0))//清空文本框
- {
- foreach (Control ctr in ultraGroupBox6.Controls)
- {
- if (ctr is Label)
- { continue; }
- if (ctr is UltraCheckEditor)
- {
- UltraCheckEditor ultcmb = (UltraCheckEditor)ctr;
- //ultChkSuppUon.Checked = false;
- }
- ctr.Text = null;
- }
- if (ultraGrid1.ActiveRow != null && !sender.Equals(0))//物料信息
- {
- MatEntity mat_entity = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() });
- MatEntity mat_entity1 = CopyEntity<MatEntity>(mat_entity);
- if (mat_entity.BaseUnitFlag == "1")//基顿标识
- {
- cb_BASE_UNIT_FLAG.Checked = true;
- txt_BASE_UNIT_VALUE.Text = mat_entity.BaseUnitValue == null ? "" : mat_entity.BaseUnitValue.ToString();
- }
- else
- {
- cb_BASE_UNIT_FLAG.Checked = false;
- }
- txt_ItemArcCode.Text = mat_entity.ArcCode;
- txt_ItemArcCodeName.Text = mat_entity.ArcItem;
- txt_IS_BUDGET_CTRL.Value = mat_entity.IsBudgetCtrl == null ? null : mat_entity.IsBudgetCtrl;//是否定额控制
- txt_DELVRY_RANGE_MIN.Value = mat_entity.DelvryRangeMin;//交货量差下限
- txt_DELVRY_RANGE_MAX.Value = mat_entity.DelvryRangeMax;//交货量差上限
- txt_DELVRY_RANGE_TPE.Value = mat_entity.DelvryRangeTpe;//交货量差方式
- txt_DELVRY_RANGE_MIN2.Value = mat_entity.DelvryRangeMin;//交货量差下限
- txt_DELVRY_RANGE_MAX2.Value = mat_entity.DelvryRangeMax;//交货量差上限
- txt_delivery_type_2.Value = mat_entity.DelvryRangeTpe;//交货量差方式
- //txt_MENT_UNIT_CODE.Text = mat_entity.MentUnitDesc == null ? null : mat_entity.MentUnitDesc.ToString();//采购管理科室代码
- //txt_BUYER_UNITCODE.Text = mat_entity.BuyerUnitDesc == null ? null : mat_entity.BuyerUnitDesc.ToString();//采购管理部门代码
- txt_BUYER_ROLE_NAME.Text = mat_entity.BuyerRoleName == null ? null : mat_entity.BuyerRoleName;
- txt_PLANNER_ROLE_NAME.Text = mat_entity.PlannerRoleName == null ? null : mat_entity.PlannerRoleName;
- QstrBUYER_ROLE_ID = ultraGrid1.ActiveRow.Cells["BUYERROLEID"].Value.ToString();
- QstrPLANNER_ROLE_ID = ultraGrid1.ActiveRow.Cells["PLANNERROLEID"].Value.ToString();
- txt_INV_PHYSIC_USERID.Text = mat_entity.InvPhysicUsername == null ? null : mat_entity.InvPhysicUsername;//库管员名称
- QstrINV_PHYSIC_USERID = mat_entity.InvPhysicUserid;
- Ultcmb_WEIGHT_UNIT.Text = mat_entity.WeightUnit == null ? null : mat_entity.WeightUnit.ToString();//库存单位
- Ultcmb_WEIGHT_UNIT_CODE.Text = mat_entity.WeightUnitCode == null ? null : mat_entity.WeightUnitCode.ToString();//库存单位编码
- txt_WEIGHT_UNIT.Text = mat_entity.WeightUnit == null ? null : mat_entity.WeightUnit.ToString();//库存单位
- txt_WEIGHT_UNIT_CODE.Text = mat_entity.WeightUnitCode == null ? null : mat_entity.WeightUnitCode.ToString();//库存单位编码
- Ultcmb_RECEIVE_TYPE.Value = mat_entity.ReceiveType;//入库类型;1:直接入库2:收货质检入库3:JIT入库4:VMI入库
- Ultcmb_BATCH_FLAG.Value = mat_entity.BatchFlag;//是否批次控制
- Ultcmb_PUR_STANDARDS.Value = mat_entity.PurStandards;//采购标准
- Ultcmb_INV_WASTE_FAC_UOM.Value = mat_entity.InvWasteFacUom == null ? null : mat_entity.InvWasteFacUom.ToString();//库存损耗率单位
- //Ultcmb_SHARE_CK_SPEC_FLAG.Value = mat_entity.ShareCkSpecFlag;//是否与子规格共用库存
- Ultcmb_METERING_FLAG.Value = mat_entity.MeteringFlag;//是否计量
- txt_PC_FLAG.Value = mat_entity.PcFlag;
- Ultcmb_PRICE_TYPE.Text = mat_entity.PriceType == null ? null : mat_entity.PriceType.ToString();//计价类型
- Ultcmb_CURRENCY_CODE.Text = mat_entity.CurrencyCode == null ? null : mat_entity.CurrencyCode.ToString();//币种代码
- Ultcmb_LIFE_CYCLE_UOM.Text = mat_entity.LifeCycleUom == null ? null : mat_entity.LifeCycleUom.ToString();//有效期单位
- //txt_UOM_NAME.Text = mat_entity.ItemUom == null ? null : mat_entity.ItemUom.ToString();//采购单位(个、袋、桶)
- //txt_PUR_STANDARDS_CODE.Text = mat_entity.PurStandardsCode == null ? null : mat_entity.PurStandardsCode.ToString();//采购标准编号
- txt_MIN_STOCK.Text = mat_entity.MinStock == null ? null : mat_entity.MinStock.ToString();//最小库存(预警)
- txt_MAX_STOCK.Text = mat_entity.MaxStock == null ? null : mat_entity.MaxStock.ToString();//最大库存(预警)
- txt_LEAD_TIME.Text = mat_entity.LeadTime == null ? null : mat_entity.LeadTime.ToString();//采购提前时间(天)
- txt_INV_WASTE_FAC.Text = mat_entity.InvWasteFac == null ? null : mat_entity.InvWasteFac.ToString();//库存损耗率
- txt_LIFE_CYCLE.Text = mat_entity.LifeCycle == null ? null : mat_entity.LifeCycle.ToString();//有效期
- txt_MIN_QTY.Text = mat_entity.MinQty == null ? null : mat_entity.MinQty.ToString();//最小采购数量
- txt_QTY_MULTIPLE.Text = mat_entity.QtyMultiple == null ? null : mat_entity.QtyMultiple.ToString();//批量数
- txt_BUG_PRICE.Text = mat_entity.BugPrice == null ? null : mat_entity.BugPrice.ToString();//计划价
- txt_LAST_PRICE.Text = mat_entity.LastPrice == null ? null : mat_entity.LastPrice.ToString();//最近采购价
- //txt_ITEM_UOM_CONEFFICIENT.Text = mat_entity.ItemUomConefficient == null ? null : mat_entity.ItemUomConefficient.ToString();//转换系数
- txt_MONTH_END_AVG_PRICE.Text = mat_entity.MonthEndAvgPrice == null ? null : mat_entity.MonthEndAvgPrice.ToString();//月末移动平均价
- txt_ITEM_NAME.Text = mat_entity.ItemName == null ? null : mat_entity.ItemName.ToString();//物料名称
- txt_ITEM_DESC_E.Text = mat_entity.ItemDescE == null ? null : mat_entity.ItemDescE.ToString();//物料英文名称
- txt_ITEM_DESC.Text = mat_entity.ItemDesc == null ? null : mat_entity.ItemDesc.ToString();//物料描述
- txt_ITEM_MODEL.Text = mat_entity.ItemModel == null ? null : mat_entity.ItemModel.ToString();//物料材质
- txt_ITEM_SPEC.Text = mat_entity.ItemSpec == null ? null : mat_entity.ItemSpec.ToString();//物料型号规格
- txt_ITEM_CODE.Text = mat_entity.ItemCode == null ? null : mat_entity.ItemCode.ToString();//物料编码
- Ultcmb_MAT_TYPE.Text = mat_entity.MatType == null ? null : mat_entity.MatType.ToString();//物料大类
- }
- }
- else if (sender.Equals(ultraGrid2) || sender.Equals(1))
- {
- if (ultraGrid2.ActiveRow == null)
- {
- foreach (Control ctr in ultraTabPageControl2.Controls)
- {
- if (ctr.Name.Contains("label"))
- { continue; }
- ctr.Text = null;
- }
- return;
- }
- if (ultraGrid2.ActiveRow != null && !sender.Equals(1))//物料供应商供应商信息
- {
- String strid = ultraGrid2.ActiveRow.GetCellValue("id").ToString().Trim();
- if (String.IsNullOrEmpty(strid))
- { return; }
- Entity_SuppGrade mat_entity = this.execute<Entity_SuppGrade>("com.hnshituo.pur.configure.service.SuppGradeService", "findById", new object[] { strid });
- txt_suppCode.Text = ultraGrid2.ActiveRow.Cells["SUPPCODE"].Value.ToString();
- txt_SUPP_NAME.Text = ultraGrid2.ActiveRow.Cells["SUPPNAME"].Value.ToString();
- txt_IS_DEFAULT.Value = mat_entity.IsDefault;
- txt_DELVRY_RANGE_MIN2.Value = mat_entity.DelvryRangeMin;//交货量差下限
- txt_DELVRY_RANGE_MAX2.Value = mat_entity.DelvryRangeMax;//交货量差上限
- txt_delivery_type_2.Value = mat_entity.DelvryRangeTpe;//交货量差方式
- }
- }
- else if (sender.Equals(ultraGrid3) || sender.Equals(2))
- {
- if (ultraGrid3.ActiveRow == null)
- {
- foreach (Control ctr in ultraTabPageControl3.Controls)
- {
- //if (ctr.Name.Contains("label") || ctr.GetType().FullName == "txt_IS_DEFAULT_ATTR")
- //{ continue; }
- //ctr.Text = null;
- ConfigureClassCommon.clearOldData(ultraTabPageControl3);
- }
- return;
- }
- if (ultraGrid3.ActiveRow != null && !sender.Equals(2))//编辑属性
- {
- txt_item_Attr4.Text = ultraGrid3.ActiveRow.Cells["itemAttr4"].Value.ToString();
- txt_item_Attr3.Text = ultraGrid3.ActiveRow.Cells["itemAttr3"].Value.ToString();
- txt_item_Attr2.Text = ultraGrid3.ActiveRow.Cells["itemAttr2"].Value.ToString();
- txt_item_Attr1.Text = ultraGrid3.ActiveRow.Cells["itemAttr1"].Value.ToString();
- txt_ITEM_ATTR.Text = ultraGrid3.ActiveRow.Cells["ITEMATTR"].Value.ToString();//属性名称
- txt_ITEM_ATTR_CODE.Text = ultraGrid3.ActiveRow.Cells["ITEMATTRCODE"].Value.ToString();//属性编码
- if (ultraGrid3.ActiveRow.Cells["ISDEFAULT"].Value.ToString() == "是")//是否常用
- {
- txt_IS_DEFAULT_ATTR.Value = "1";//是
- }
- else
- {
- txt_IS_DEFAULT_ATTR.Value = "0";//否
- }
- if (ultraGrid3.ActiveRow.Cells["txtIsLevel"].Value.ToString() == "是") //IsLevel
- {
- txt_IsLevel.Value = "1";//是
- }
- else
- {
- txt_IsLevel.Value = "0";//否
- }
- txt_REMARK_ATTR.Text = ultraGrid3.ActiveRow.Cells["REMARK"].Value.ToString();//备注
- //txt_ORDER_NUM.Value = ultraGrid3.ActiveRow.Cells["ORDERNUM"].Value.ToString();//排序
- //txt_UOM_NAME.Text = ultraGrid3.ActiveRow.Cells["ITEMUOM"].Value.ToString();//采购单位
- //txt_ITEM_UOM_CONEFFICIENT.Text = ultraGrid3.ActiveRow.Cells["ITEMUOMCONEFFICIENT"].Value.ToString();//转换系数
- //if (ultraGrid3.ActiveRow.Cells["ITEMUSEUOM"].Value.ToString() == "1")//是否使用采购单位
- //{
- //ultChkSuppUon.Checked = true;
- // }
- //else
- //{
- // ultChkSuppUon.Checked = false;
- //}
- }
- }
- else if (sender.Equals(ultraGrid4) || sender.Equals(3))
- {
- if (ultraGrid4.ActiveRow == null)
- {
- foreach (Control ctr in ultraTabPageControl7.Controls)
- {
- if (ctr.Name.Contains("label") || ctr.Name == "txt_IS_DEFAULT_STANDRANDS")
- { continue; }
- ctr.Text = null;
- }
- return;
- }
- if (ultraGrid4.ActiveRow != null && !sender.Equals(3))
- {
- txt_STANDARDS_ID.Text = ultraGrid4.ActiveRow.Cells["STANDARDSID"].Value.ToString();//标准编号ID
- txt_STANDARDS_CODE.Text = ultraGrid4.ActiveRow.Cells["STANDARDSCODE"].Value.ToString();//标准编号
- txt_REMARK_STANDARD.Text = ultraGrid4.ActiveRow.Cells["REMARK"].Value.ToString();//备注
- if (ultraGrid4.ActiveRow.Cells["ISDEFAULT"].Value.ToString() == "是")//是否常用
- {
- txt_IS_DEFAULT_STANDRANDS.Value = "1";//是
- }
- else
- {
- txt_IS_DEFAULT_STANDRANDS.Value = "0";//否
- }
- }
- }
- else if (sender.Equals(ultraGrid5) || sender.Equals(4))
- {
- if (ultraGrid5.ActiveRow == null)
- {
- foreach (Control ctr in ultraTabPageControl9.Controls)
- {
- if (ctr.Name.Contains("label") || ctr.Name == "txt_IS_DEFAULT_UOM")
- { continue; }
- ctr.Text = null;
- }
- return;
- }
- if (ultraGrid5.ActiveRow != null && !sender.Equals(4))
- {
- txt_UOM_NAME.Text = ultraGrid5.ActiveRow.Cells["UOMNAME"].Value.ToString();//采购单位名称
- txt_UOM_CODE.Text = ultraGrid5.ActiveRow.Cells["UOMCODE"].Value.ToString();//采购单位编码
- txt_WEIGHT_UNIT_CODE.Text = ultraGrid1.ActiveRow.Cells["WEIGHTUNITCODE"].Value.ToString();//库存单位编码
- txt_WEIGHT_UNIT.Text = ultraGrid1.ActiveRow.Cells["WEIGHTUNIT"].Value.ToString();//库存单位名称
- txt_ITEM_UOM_CONEFFICIENT.Text = ultraGrid5.ActiveRow.Cells["ITEMUOMCONEFFICIENT"].Value.ToString();//转换系数
- txt_REMARK_UOM.Text = ultraGrid5.ActiveRow.Cells["REMARK"].Value.ToString();//备注
- if (ultraGrid5.ActiveRow.Cells["ISDEFAULT"].Value.ToString() == "是")//是否常用
- {
- txt_IS_DEFAULT_UOM.Value = "1";//是
- }
- else
- {
- txt_IS_DEFAULT_UOM.Value = "0";//否
- }
- }
- }
- }
- /// <summary>
- /// 设置下拉列表默认选中事件
- /// </summary>
- public void setUltCmbEdt_sel()
- {
- if (Ultcmb_RECEIVE_TYPE.Items.Count > 0)
- Ultcmb_RECEIVE_TYPE.SelectedIndex = 0;
- if (Ultcmb_BATCH_FLAG.Items.Count > 0)
- Ultcmb_BATCH_FLAG.SelectedIndex = 0;
- if (Ultcmb_PUR_STANDARDS.Items.Count > 0)
- Ultcmb_PUR_STANDARDS.SelectedIndex = 0;
- if (Ultcmb_INV_WASTE_FAC_UOM.Items.Count > 0)
- Ultcmb_INV_WASTE_FAC_UOM.SelectedIndex = 0;
- if (Ultcmb_METERING_FLAG.Items.Count > 0)
- Ultcmb_METERING_FLAG.SelectedIndex = 0;
- if (Ultcmb_PRICE_TYPE.Items.Count > 0)
- Ultcmb_PRICE_TYPE.SelectedIndex = 0;
- if (Ultcmb_CURRENCY_CODE.Items.Count > 0)
- Ultcmb_CURRENCY_CODE.SelectedIndex = 0;
- if (Ultcmb_LIFE_CYCLE_UOM.Items.Count > 0)
- Ultcmb_LIFE_CYCLE_UOM.SelectedIndex = 0;
- if (txt_DELVRY_RANGE_TPE.Items.Count > 0)
- txt_DELVRY_RANGE_TPE.SelectedIndex = 0;
- }
- /// ultraGrid1行单击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl1.Tab;
- UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(e.Cell.Row.Cells["ARCCODE"].Value.ToString());
- if (ulTreeMat.ActiveNode == uttNode)
- {
- return;
- }
- ulTreeMat.CollapseAll();
- QClickCellOrQuery = true;
- ulTreeMat.ActiveNode = uttNode;
- if (uttNode == null)
- {
- MessageUtil.ShowTips("物料名称:" + e.Cell.Row.Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + e.Cell.Row.Cells["ARCCODE"].Value.ToString());
- }
- else
- {
- while (ulTreeMat.ActiveNode != uttNode)
- {
- ulTreeMat.ActiveNode = uttNode;
- }
- uttNode.Expanded = true;
- //展开分类
- while (uttNode.Parent != null)
- {
- uttNode = uttNode.Parent;
- uttNode.Expanded = true;
- }
- }
- QClickCellOrQuery = false;//设置未点击
- }
- /// <summary>
- /// ultraGrid2行单击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
- {
- }
- /// <summary>
- /// ultraGrid3行单击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid3_ClickCell(object sender, ClickCellEventArgs e)
- {
- }
- /// <summary>
- /// ultraGrid5行单击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid5_ClickCell(object sender, ClickCellEventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl9.Tab;
- }
- private void ultraGrid2_Click(object sender, EventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl2.Tab;
- }
- private void ultraGrid3_Click(object sender, EventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl3.Tab;
- }
- private void ultraGrid4_Click(object sender, EventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl7.Tab;
- }
- /// <summary>
- /// 单击选择编辑区tab页
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid5_Click(object sender, EventArgs e)
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl9.Tab;
- }
- /// <summary>
- /// 是否使用采购单位
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultChkSuppUon_CheckedChanged(object sender, EventArgs e)
- {
- ////if (ultChkSuppUon.Checked)
- //{
- // Ultcmb_ITEM_UOM.Enabled = true;
- // txt_ITEM_UOM_CONEFFICIENT.Enabled = true;
- //}
- //else
- //{
- // Ultcmb_ITEM_UOM.Enabled = false;
- // txt_ITEM_UOM_CONEFFICIENT.Enabled = false;
- //}
- }
- /// <summary>
- /// 单机选择采购部门
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- //private void txt_BUYER_DEPT_CODE_MouseClick(object sender, MouseEventArgs e)
- //{
- // //查询采购科室
- // frmdepartment frm = new frmdepartment(ob);
- // frm.StartPosition = FormStartPosition.Manual;
- // frm.Location = new Point(Cursor.Position.X, Cursor.Position.Y - frm.Height);//还需设置frm.StartPosition属性
- // frm.ShowDialog();
- // if (frm.BuyerUnitCode == null)
- // return;
- // if (sender.Equals(txt_BUYER_UNITCODE))
- // {
- // txt_BUYER_UNITCODE.Text = frm.BuyerUnitDesc;
- // strBUYER_DEPT_CODE = frm.BuyerUnitCode;
- // }
- // else if (sender.Equals(txt_MENT_UNIT_CODE))
- // {
- // txt_MENT_UNIT_CODE.Text = frm.BuyerUnitDesc;
- // strMENT_UNIT_CODE = frm.BuyerUnitCode;
- // }
- //}
- private void ultraScrollBar1_Scroll(object sender, ScrollEventArgs e)
- {
- foreach (Control gbox in ultraGroupBox6.Controls)
- {
- if (gbox is UltraScrollBar) continue;
- gbox.Location = new Point(gbox.Location.X, (int)gbox.Tag - e.NewValue);
- }
- }
- /// <summary>
- /// 获取查询条件
- /// </summary>
- /// <returns></returns>
- private MatEntity getEnSelContion(string str)
- {
- MatEntity eMat = new MatEntity();
- if (str == null)
- {
- if (ultraTextEditor1.Text.Trim() != "")
- {
- eMat.ItemCode = ultraTextEditor1.Text;
- }
- if (ultraTextEditor2.Text.Trim() != "")
- {
- string strItemName = ultraTextEditor2.Text.Trim();
- while (strItemName.Contains(" "))
- {
- strItemName=strItemName.Replace(" ", " ");
- }
- eMat.MatItems = strItemName.Split(' ');
- }
-
- //物料分类
- if (checkBox1.Checked)
- {
- eMat.UpdateName = txt_ARC_CODE.Text;
- }
- }
- else
- {
- eMat.ArcCode = str;
- }
- if (cmbNum.Value != null && cmbNum.Value.ToString() != "")
- {
- eMat.ItemUomConefficient = double.Parse(cmbNum.Value.ToString());
- }
- return eMat;
- }
- /// <summary>
- /// 获取物料编码
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- public string getItemCodeClass(string str, string strParentCode)
- {
- //在后台获取编码
- string strCode = this.execute<string>("com.hnshituo.pur.configure.service.MatService", "getItemCode", new object[] { str });
- return strCode;
- //在前台获取编码
- //string strChild = "";
- //string strJion = "";
- //int num = 0;
- //MatEntity mat = new MatEntity();
- //if (strParentCode == "")//获取物料编码
- //{
- // num = 7;
- // mat.ArcCode = str;
- //}
- //else//获取属性物料编码
- //{
- // strJion = "@";
- // num = 3;
- // mat.ParentItemCode = str;
- //}
- //int intChild = this.execute<int>("com.hnshituo.pur.configure.service.MatService", "count", new object[] { mat, 0, 0 });
- //intChild++;
- //strChild = intChild.ToString();
- //while (strChild.Length < num)
- //{
- // strChild = "0" + strChild;
- //}
- ////判断编码是否存在
- //MatEntity matIsExsitRow = new MatEntity();
- //matIsExsitRow.ItemCode = str + strJion + strChild;
- //while (isExsitRow("com.hnshituo.pur.configure.service.MatService", matIsExsitRow) > 0)
- //{
- // intChild++;
- // strChild = intChild.ToString();
- // while (strChild.Length < num)
- // {
- // strChild = "0" + strChild;
- // }
- // matIsExsitRow.ItemCode = str + strJion + strChild;
- //}
- //return str + strJion + strChild;
- }
- /// <summary>
- /// 选择供应商
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- /// <summary>
- private void txt_SUPP_NAME_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.SuppService", "findAll", new object[] { });
- if (dt == null || dt.Rows.Count < 1)
- {
- MessageUtil.ShowTips("暂无供应商可选");
- return;
- }
- frmSuppSel frm = new frmSuppSel(this.ob);
- frm.ShowDialog();
- if (!string.IsNullOrEmpty(frm.strSUPP_NAME))
- {
- txt_SUPP_NAME.Text = frm.strSUPP_NAME;
- txt_suppCode.Text = frm.strSUPP_CODE;
- }
- }
- /// <summary>
- /// 选择采购员角色ID
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_BUYER_ROLE_ID_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- FrmPop_core_app_srole frm = new FrmPop_core_app_srole(this.ob);
- frm.ShowDialog();
- if (frm.StrDeptid != "")
- {
- if (sender.Equals(txt_BUYER_ROLE_NAME))//物料
- {
- QstrBUYER_ROLE_ID = frm.StrDeptid;
- txt_BUYER_ROLE_NAME.Text = frm.StrName;
- }
-
- else//供应商
- {
- QstrBUYER_ROLE_ID1 = frm.StrDeptid;
- txt_BUYER_ROLE_NAME1.Text = frm.StrName;
- }
- }
- }
- /// <summary>
- /// 选择库管员
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_INV_PHYSIC_USERID_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- SetectManByDept frm = new SetectManByDept(this.ob, "002001029006");
- frm.ShowDialog();
- if (!string.IsNullOrEmpty(frm.StrUserID))
- {
- QstrINV_PHYSIC_USERID = frm.StrUserID;
- txt_INV_PHYSIC_USERID.Text = frm.StrUserName;
- }
- }
- /// <summary>
- /// 选择计划员角色ID
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_PLANNER_ROLE_ID_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- FrmPop_core_app_srole frm = new FrmPop_core_app_srole(this.ob);
- frm.ShowDialog();
- if (sender.Equals(txt_PLANNER_ROLE_NAME))//物料
- {
- if (frm.StrDeptid != "")
- {
- QstrPLANNER_ROLE_ID = frm.StrDeptid;
- txt_PLANNER_ROLE_NAME.Text = frm.StrName;
- }
- }
- else//供应商
- {
- if (frm.StrDeptid != "")
- {
- QstrPLANNER_ROLE_ID1 = frm.StrDeptid;
- txt_PLANNER_ROLE_NAME1.Text = frm.StrName;
- }
- }
- }
- /// <summary>
- /// 批量修改物料采购员或计划员角色
- /// </summary>
- /// <param name="strParentMatCode"></param>
- /// <param name="PeopleType">1为采购员,2为计划员</param>
- private void updateSrole(string strParentMatCode, string PeopleType)
- {
-
- if (PeopleType == "2")
- { //修改采购员角色
- FrmPop_core_app_srole frm = new FrmPop_core_app_srole(this.ob);
- frm.ShowDialog();
- if (frm.StrDeptid != "")
- {
- if (MessageUtil.ShowYesNoAndTips("是否确定批量修改物料分类【" + ulTreeMat.ActiveNode.Text + "】所有物料的采购员角色为【" + frm.StrName + "】?").Equals(DialogResult.No))
- { return; }
- MatEntity mat_entity = new MatEntity();
- mat_entity.ArcCode = strParentMatCode;
- mat_entity.BuyerRoleId = frm.StrDeptid;
- mat_entity.BuyerRoleName = frm.StrName;
- mat_entity.UpdateName = UserInfo.GetUserName();
- mat_entity.UpdateUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "updateSrole", new object[] { mat_entity });//更新操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("批量更新失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("批量更新成功");
- if (Q_mat != null)
- getMat(Q_mat);//刷新物料
- }
- }
- //修改
- else if (PeopleType == "3")
- {
- SetectManByDept frm = new SetectManByDept(this.ob, "002001029006");
- frm.ShowDialog();
- if (!string.IsNullOrEmpty(frm.StrUserID))
- {
- if (MessageUtil.ShowYesNoAndTips("是否确定批量修改物料分类【" + ulTreeMat.ActiveNode.Text + "】所有物料的库管员为【" + frm.StrUserName + "】?").Equals(DialogResult.No))
- { return; }
- QstrINV_PHYSIC_USERID = frm.StrUserID;
- txt_INV_PHYSIC_USERID.Text = frm.StrUserName;
- MatEntity mat_entity = new MatEntity();
- mat_entity.ArcCode = strParentMatCode;
- mat_entity.InvPhysicUserid = frm.StrUserID;
- mat_entity.InvPhysicUsername = frm.StrUserName;
- mat_entity.UpdateName = UserInfo.GetUserName();
- mat_entity.UpdateUserid = UserInfo.GetUserID();
-
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "updateSrole", new object[] { mat_entity });//更新操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("批量更新库管员失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("批量更新库管员成功");
- if (Q_mat != null)
- getMat(Q_mat);//刷新物料
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "ITEMCODE", mat_entity.ItemCode);//激活当前行
- }
- }
- else if (PeopleType == "1")//修改计划员角色
- {
- FrmPop_core_app_srole frm = new FrmPop_core_app_srole(this.ob);
- frm.ShowDialog();
- if (frm.StrDeptid != "")
- {
- if (MessageUtil.ShowYesNoAndTips("是否确定批量修改物料分类【" + ulTreeMat.ActiveNode.Text + "】所有物料的计划员角色为【" + frm.StrName + "】?").Equals(DialogResult.No))
- { return; }
- MatEntity mat_entity = new MatEntity();
- mat_entity.ArcCode = strParentMatCode;
- mat_entity.Validflag = "1";
- mat_entity.PlannerRoleId = frm.StrDeptid;
- mat_entity.PlannerRoleName = frm.StrName;
- mat_entity.UpdateName = UserInfo.GetUserName();
- mat_entity.UpdateUserid = UserInfo.GetUserID();
- // if (MessageUtil.ShowYesNoAndQuestion("是否确定修改物料分类【" + ulTreeMat.ActiveNode.Text + "】的计划员角色为【" + frm.StrName + "】?") == DialogResult.No)
- //{
- // return;
- // }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "updateSrole", new object[] { mat_entity });//更新操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("批量更新失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("批量更新成功");
- if (Q_mat != null)
- getMat(Q_mat);//刷新物料
- }
- }
- }
- /// <summary>
- /// 批量新增供应商
- /// </summary>
- /// <param name="strParentMatCode"></param>
- /// <param name="PeopleType">1为采购员,2为计划员</param>
- private void addSupps(string strParentMatCode, string strSuppCode)
- {
- if (txt_suppCode.Text.Trim() == "")
- {
- MessageUtil.ShowTips("请选择供应商");
- return;
- }
- if (strParentMatCode == "")
- {
- MessageUtil.ShowTips("请选择分类");
- return;
- }
- Supp EntitySupp = this.execute<Supp>("com.hnshituo.pur.configure.service.SuppService", "findById", new object[] { strSuppCode });
- MatEntity mat_entity = this.execute<MatEntity>("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString() });
- Entity_SuppGrade EntitySuppGrade = new Entity_SuppGrade();
- EntitySuppGrade.SuppCode = EntitySupp.SuppCode;
- EntitySuppGrade.ItemCode = mat_entity.ItemCode;
- if (isExsitRow("com.hnshituo.pur.configure.service.SuppGradeService", EntitySuppGrade) > 0)//包含相同的文件
- {
- MessageUtil.ShowTips("数据库中存在相同的供应商,请重新选择");
- return;
- }
- EntitySuppGrade.SuppName = EntitySupp.SuppName;
- EntitySuppGrade.SuppShortName = EntitySupp.SuppShortName;
- EntitySuppGrade.SuppPerGrade = EntitySupp.SuppCreditRate;
- EntitySuppGrade.IsDefault = txt_IS_DEFAULT.Value == null ? null : txt_IS_DEFAULT.Value.ToString();
- EntitySuppGrade.ItemCode = mat_entity.ItemCode;
- EntitySuppGrade.ItemDesc = mat_entity.ItemDesc;
- EntitySuppGrade.ItemDescE = mat_entity.ItemDescE;
- EntitySuppGrade.ItemName = mat_entity.ItemName;
- //EntitySuppGrade.BuyerRoleId = QstrBUYER_ROLE_ID1;
- //EntitySuppGrade.PlannerRoleName = QstrPLANNER_ROLE_ID1;
- //EntitySuppGrade.BuyerRoleName = txt_BUYER_ROLE_NAME1.Text;
- //EntitySuppGrade.PlannerRoleName = txt_PLANNER_ROLE_NAME1.Text;
- if (txt_delivery_type_2.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择交货差方式");
- txt_delivery_type_2.Focus();
- return;
- }
- EntitySuppGrade.DelvryRangeTpe = txt_delivery_type_2.Value.ToString().Trim();//交货量差方式
- if ("1" == txt_delivery_type_2.Value.ToString().Trim() || "2" == txt_delivery_type_2.Value.ToString().Trim())
- {
- if (txt_DELVRY_RANGE_MIN2.Value != null)
- {
- EntitySuppGrade.DelvryRangeMin = double.Parse(txt_DELVRY_RANGE_MIN2.Value.ToString());//交货量差下限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差下限值");
- txt_DELVRY_RANGE_MIN2.Focus();
- return;
- }
- if (txt_DELVRY_RANGE_MAX2.Value != null)
- {
- EntitySuppGrade.DelvryRangeMax = double.Parse(txt_DELVRY_RANGE_MAX2.Value.ToString());//交货量差上限
- }
- else
- {
- MessageUtil.ShowTips("请填写交货量差上限值");
- txt_DELVRY_RANGE_MAX2.Focus();
- return;
- }
- }
- else
- {
- EntitySuppGrade.DelvryRangeMin = 0;
- EntitySuppGrade.DelvryRangeMax = 0;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确定添加供应商【" + txt_SUPP_NAME.Text.Trim() + "】到物料分类【" + ulTreeMat.ActiveNode.Text.ToString().Trim() + "】下的所有物料中?") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatService", "AddSupps", new object[] { mat_entity,EntitySuppGrade });//更新操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("批量新增失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("批量新增成功");
- if (Q_mat != null)
- getMat(Q_mat);//刷新物料
- }
- /// <summary>
- /// 采购单位单击按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Ultcmb_ITEM_UOM_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- //frmPopItemUon frm = new frmPopItemUon(this.ob);
- //frm.ShowDialog();
- //txt_UOM_NAME.Text = frm.QstrWeightName;
- //txt_UOM_NAME.Text = frm.QstrWeightName;
- }
- private void Ultcmb_WEIGHT_UNIT_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- FrmPopItemWeight frm = new FrmPopItemWeight(this.ob);
- frm.ShowDialog();
- if (!string.IsNullOrEmpty(frm.QstrWeightName))
- {
- Ultcmb_WEIGHT_UNIT.Text = frm.QstrWeightName;
- Ultcmb_WEIGHT_UNIT_CODE.Text = frm.QstrWeightCode;
- }
- }
- /// <summary>
- /// 绑定所有的下拉列表的数据
- /// </summary>
- private void getUltcmbBindValueList(DataTable dt, UltraComboEditor ultcmb)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- ValueListItem vlItem = new ValueListItem(dt.Rows[i]["BASECODE"].ToString().Trim(), dt.Rows[i]["BASENAME"].ToString().Trim());
- ultcmb.Items.Add(vlItem);
- }
- }
- /// <summary>
- /// 切换tab功能界面同时切换相应的编辑区界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTabControl2_Click(object sender, EventArgs e)
- {
- if (this.ultraTabControl2.SelectedTab.Key == "0")
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl2.Tab;
- }
- else if (this.ultraTabControl2.SelectedTab.Key == "1")
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl3.Tab;
- }
- else if (this.ultraTabControl2.SelectedTab.Key == "2")
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl7.Tab;
- }
- else if (this.ultraTabControl2.SelectedTab.Key == "3")
- {
- this.ultraTabControl1.SelectedTab = ultraTabPageControl9.Tab;
- }
- }
- /// <summary>
- /// 移除无效数据
- /// </summary>
- /// <param name="dt"></param>
- private void removeNotValiflagData(DataTable dt)
- {
- for (int i = 0; i < dt.Rows.Count; )
- {
- if (dt.Rows[i]["VALIDFLAG"].ToString() == "0")
- {
- dt.Rows.RemoveAt(i);
- }
- else
- {
- i++;
- }
- }
- }
- /// 单击选择列表区tab页
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- if (this.ultraTabControl1.SelectedTab.Key == "0")
- {
- this.ultraTabControl2.SelectedTab = ultraTabPageControl4.Tab;
- }
- else if (this.ultraTabControl1.SelectedTab.Key == "1")
- {
- this.ultraTabControl2.SelectedTab = ultraTabPageControl5.Tab;
- }
- else if (this.ultraTabControl1.SelectedTab.Key == "2")
- {
- this.ultraTabControl2.SelectedTab = ultraTabPageControl6.Tab;
- }
- else if (this.ultraTabControl1.SelectedTab.Key == "3")
- {
- this.ultraTabControl2.SelectedTab = ultraTabPageControl8.Tab;
- }
- }
- /// <summary>
- /// 绑定下拉列表的数据
- /// </summary>
- /// <param name="dt"></param>
- /// <summary>
- private void getUltcmbBindData()
- {
- DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1101" }, this.ob);
- removeNotValiflagData(dt);
- getUltcmbBindValueList(dt, Ultcmb_RECEIVE_TYPE);
- //Ultcmb_RECEIVE_TYPE.DataSource = dt;
- //Ultcmb_RECEIVE_TYPE.DisplayMember = "BASENAME";
- //Ultcmb_RECEIVE_TYPE.ValueMember = "BASECODE";
- //ComboBoxHelper.FillUltraComboItems(Ultcmb_RECEIVE_TYPE, dt, "VALIDFLAG='1'");//接收方式
- }
- /// <summary>
- /// 点击弹出属性选择窗口
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_ITEM_ATTR_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- FrmPopAttrs frm = new FrmPopAttrs(this.ob);
- frm.ShowDialog();
- if (frm.QstrItemAttrCode != "")
- {
- txt_ITEM_ATTR.Text = frm.QstrItemAttr;
- txt_ITEM_ATTR_CODE.Text = frm.QstrItemAttrCode;
- txt_MatAttrClass.Text = frm.QstrItemAttrClass;
- txt_MatAttrClassName.Text = frm.QstrItemAttrClassName;
- }
- }
- /// <summary>
- /// 点击弹出标准编号选择窗口
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_STANDARDS_CODE_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- FrmPopStandards frm = new FrmPopStandards(this.ob);
- frm.ShowDialog();
- if (frm.QstrStandardsCode != "")
- {
- txt_STANDARDS_CODE.Text = frm.QstrStandardsCode;
- txt_STANDARDS_ID.Text = frm.QstrStandardsId;
- }
- }
- /// <summary>
- /// 点击弹出单位选择窗口
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_UOM_NAME_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- string strWeight = "";
- if (ultraGrid1.ActiveRow != null)
- {
- strWeight = ultraGrid1.ActiveRow.Cells["WEIGHTUNITCODE"].Value.ToString();
- }
- frmPopItemUon frm = new frmPopItemUon(this.ob, strWeight);
- frm.ShowDialog();
- if (frm.QstrUOMCode != "")
- {
- txt_ITEM_UOM_CONEFFICIENT.Text = frm.QstrItemUomConefficient;//转换系数
- txt_WEIGHT_UNIT_CODE.Text = frm.QstrWeightCode;//库存单位编码
- txt_WEIGHT_UNIT.Text = frm.QstrWeightName;//库存单位名称
- txt_UOM_CODE.Text = frm.QstrUOMCode;//采购单位名称
- txt_UOM_NAME.Text = frm.QstrUOMName;//采购单位名称
- }
- }
- /// <summary>
- /// 基顿标识
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cb_BASE_UNIT_FLAG_CheckedChanged(object sender, EventArgs e)
- {
- txt_BASE_UNIT_VALUE.ReadOnly = !cb_BASE_UNIT_FLAG.Checked;
- }
- /// <summary>
- /// 是否显示已作废的物料
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void chk_showHasDelete_CheckedChanged(object sender, EventArgs e)
- {
- getMat(Q_mat);
- }
- /// <summary>
- /// 是否显示已作废的物料
- /// </summary>
- /// <param name="bl"></param>
- private void showHasDelete(bool bl)
- {
- if (bl)//true 显示作废物料
- {
- foreach (UltraGridRow ugr in ultraGrid1.Rows)
- {
- if (ugr.Cells["VALIDFLAG"].Value.ToString() == "作废")
- {
- //ugr.Hidden = false;//显示
- ugr.Appearance.ForeColor = Color.Red;
- }
- }
- }
- //else
- //{
- // foreach (UltraGridRow ugr in ultraGrid1.Rows)
- // {
- // if (ugr.Cells["VALIDFLAG"].Value.ToString() == "作废")
- // {
- // //ugr.Hidden = true;//隐藏
- // }
- // }
- //}
- }
- /// <summary>
- /// 物料分类维护审批流程
- /// </summary>
- private void setMatClassPross()
- {
- if (ulTreeMat.ActiveNode != null && ulTreeMat.ActiveNode.Key.Length==5)
- {
- frmPopMatClassPross frm = new frmPopMatClassPross(this.ob, ulTreeMat.ActiveNode.Key);
- frm.StartPosition = FormStartPosition.Manual;//设置窗体初始位置由Location决定
- frm.StartPosition = FormStartPosition.CenterParent;//设置窗体初始位置
- frm.ShowDialog();
- }
- else
- {
- MessageUtil.ShowTips("请选择物料小类");
- return;
- }
- }
- private void txt_DELVRY_RANGE_TPE_ValueChanged(object sender, EventArgs e)
- {
- if (txt_DELVRY_RANGE_TPE.Value != null)
- {
- if (txt_DELVRY_RANGE_TPE.Value.ToString() == "1")//绝对值
- {
- label73.Visible = false;
- label74.Visible = false;
- }
- else//百分比
- {
- label73.Visible = true;
- label74.Visible = true;
- }
- }
- }
- private void txt_delivery_type_2_ValueChanged(object sender, EventArgs e)
- {
- if (txt_DELVRY_RANGE_TPE.Value != null)
- {
- if (txt_DELVRY_RANGE_TPE.Value.ToString() == "1")//绝对值
- {
- label81.Visible = false;
- label82.Visible = false;
- }
- else//百分比
- {
- label81.Visible = true;
- label82.Visible = true;
- }
- }
- }
- /// <summary>
- /// 选择物料分类
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_ItemArcCode_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
-
- }
- private void txt_ItemArcCodeName_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- frmPopMatClass frm = new frmPopMatClass(this.ob,"1");
- frm.ShowDialog();
- if (frm.Q_Ultnode != null)
- {
- txt_ItemArcCodeName.Text = frm.Q_Ultnode.Text;
- txt_ItemArcCode.Text = frm.Q_Ultnode.Key;
- }
- }
- /// <summary>
- /// 复制实体类数据(源数据可以为任何类型,该方法只赋值属性名称相同的属性。)
- /// </summary>
- /// <typeparam name="T">实体类</typeparam>
- /// <param name="srcObj">源对象</param>
- public T CopyEntity<T>(object srcObj)
- {
- Type type1 = typeof(T);
- T t = (T)type1.Assembly.CreateInstance(type1.FullName);
- PropertyInfo[] props = srcObj.GetType().GetProperties();
- foreach (PropertyInfo prop in props)
- {
- PropertyInfo pobj = type1.GetProperty(prop.Name);
- if (pobj != null)
- {
- pobj.SetValue(t, prop.GetValue(srcObj, null), null);
- }
- }
- T t1 = (T)typeof(T).Assembly.CreateInstance(typeof(T).FullName);
- Type tp = t1.GetType();
- PropertyInfo[] proInfo = srcObj.GetType().GetProperties();
- foreach (PropertyInfo prop in proInfo)
- {
- PropertyInfo propObj = tp.GetProperty(prop.Name);
- if (propObj != null)
- {
- propObj.SetValue(t1, prop.GetValue(srcObj, null), null);
- }
- }
- try
- {
- T Desobj = (T)typeof(T).Assembly.CreateInstance(typeof(T).FullName);
- PropertyInfo[] srcPropertyInfos = srcObj.GetType().GetProperties();
- foreach (PropertyInfo srcPropertyInfo in srcPropertyInfos)
- {
- PropertyInfo DespropertyInfo = Desobj.GetType().GetProperty(srcPropertyInfo.Name);
- if (DespropertyInfo == null) continue;
- DespropertyInfo.SetValue(Desobj, srcPropertyInfo.GetValue(srcObj, null), null);
- }
- return Desobj;
- }
- catch (Exception ex)
- {
- throw;
- }
- }
- }
- }
|