frmLocalTruckScaleNew.cs 132 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Timers;
  10. using System.Windows.Forms;
  11. using System.Xml.Linq;
  12. using Core.Mes.Client.Comm.Control;
  13. using Core.Mes.Client.Comm.Server;
  14. using Core.Mes.Client.Comm.Tool;
  15. using Core.StlMes.Client.LgResMgt.Mcms.entity;
  16. using CoreFS.CA06;
  17. using Infragistics.Win;
  18. using Infragistics.Win.Misc;
  19. using Infragistics.Win.UltraWinEditors;
  20. using Infragistics.Win.UltraWinGrid;
  21. using Infragistics.Win.UltraWinListView;
  22. using Infragistics.Win.UltraWinTabControl;
  23. using Newtonsoft.Json;
  24. using Newtonsoft.Json.Serialization;
  25. using NPOI.HSSF.UserModel;
  26. using NPOI.SS.UserModel;
  27. using NPOI.SS.Util;
  28. using BorderStyle = NPOI.SS.UserModel.BorderStyle;
  29. using HorizontalAlignment = NPOI.SS.UserModel.HorizontalAlignment;
  30. using Timer = System.Timers.Timer;
  31. using System.Net.Sockets;
  32. using System.Threading;
  33. using System.Text;
  34. using System.Collections;
  35. using Core.Mes.Client.Comm.Format;
  36. namespace Core.StlMes.Client.LgResMgt.Mcms
  37. {
  38. public partial class frmLocalTruckScaleNew : FrmBase
  39. {
  40. private static readonly string _path = Environment.CurrentDirectory + "\\data\\SerialPort.xml";
  41. private readonly Timer timer = new Timer();
  42. private List<CmmInputRecordEntity> _cmmInputRecordEntities;
  43. private frmMessage _frmMessage;
  44. private List<CmmRecordTemplateEntity> _templateList;
  45. private bool canUpdateWt;
  46. private CmmPoundBaseEntity cmmPoundBase;
  47. private CommunicationEntity communicationnow;
  48. private List<CommunicationEntity> CommunicationEntitys = new List<CommunicationEntity>();
  49. // private SerialPortEntity defultPortEntity;
  50. private bool isLoading = true;
  51. private List<CmmPoundBaseEntity> poundInfos;
  52. //TODO:等陆硬盘录像机
  53. private Log l = Log.GetInstance();
  54. private DataCollectionControl collection = new DataCollectionControl();
  55. //private SocketClient defultClenttEntity;
  56. private List<CmmBaseSpotInfoEntity> CmmBaseSpotInfo;
  57. //private CmmBaseSpotInfoEntity CmmBase = new CmmBaseSpotInfoEntity();
  58. //private TcpListener tcpListener;
  59. //图片控制器含图片压缩及上传sftp
  60. private ImageControl imageControl;
  61. List<CmmLoadinfoCEntity> loadinfo;
  62. string strip;
  63. // private CmmWorkImageEntity CmmImage=new CmmWorkImageEntity();
  64. public frmLocalTruckScaleNew()
  65. {
  66. InitializeComponent();
  67. IsLoadUserView = true;
  68. // timer.Elapsed += timer_Elapsed;
  69. // timer.Interval = 1 * 60 * 1000;
  70. // timer.Start();
  71. }
  72. private void timer_Elapsed(object sender, ElapsedEventArgs e)
  73. {
  74. try
  75. {
  76. CurrentGrid.SafeRefreshControl(() =>
  77. {
  78. var dic = new Dictionary<string, object>();
  79. if (!string.IsNullOrWhiteSpace(cboPoundList.Text))
  80. dic.Add("poundNo", cboPoundList.Text);
  81. dic.Add("validflag", new List<string> { "1" });
  82. dic.Add("effRemaind", "1");
  83. List<CmmWeightRecordEntity> list = EntityHelper.GetData<CmmWeightRecordEntity>(
  84. "com.steering.Mcms.RecordServer.doQueryRecord",
  85. new object[] { dic },
  86. ob);
  87. if ((list != null) && list.Any())
  88. foreach (
  89. var ultraGridRow in
  90. CurrentGrid.Rows.Where(
  91. p => list.Any(q => q.RecordNo == p.Cells["RecordNo"].Value.ToString2())))
  92. ultraGridRow.Cells["RecordDate"].Appearance.BackColor = Color.Red;
  93. });
  94. GC.Collect();
  95. }
  96. catch (Exception)
  97. {
  98. }
  99. }
  100. protected override void OnLoad(EventArgs e)
  101. {
  102. //try
  103. //{
  104. System.Net.IPHostEntry hostIP = System.Net.Dns.GetHostEntry(Environment.MachineName);
  105. strip = hostIP.AddressList[0].ToString();
  106. // strip = UserInfo.GetMachineIP();
  107. base.OnLoad(e);
  108. tbFirstWt.Controls.OfType<UltraTabPageControl>()
  109. .SelectMany(p => p.Controls.OfType<MatInfo>())
  110. .ToList()
  111. .ForEach(p => p.ini(ob));
  112. tbOther.Controls.OfType<UltraTabPageControl>()
  113. .SelectMany(p => p.Controls.OfType<MatInfo>())
  114. .ToList()
  115. .ForEach(p => p.ini(ob));
  116. matInfo15.ini(ob);
  117. matInfo16.ini(ob);
  118. tbWt.Appearance.ForeColor = SystemColors.ControlText;
  119. ;
  120. tbFirstWt.Appearance.ForeColor = SystemColors.ControlText;
  121. ;
  122. tbScondWt.Appearance.ForeColor = SystemColors.ControlText;
  123. ;
  124. tbOther.Appearance.ForeColor = SystemColors.ControlText;
  125. ;
  126. //TUDO
  127. poundInfos = EntityHelper.GetData<CmmPoundBaseEntity>(
  128. "com.steering.Mcms.PoundBaseServer.getPoudInfo",
  129. new object[] { ValidDataPurviewIds },
  130. ob);
  131. CmmBaseSpotInfo = EntityHelper.GetData<CmmBaseSpotInfoEntity>(
  132. "com.steering.Mcms.CmmBaseSpotInfoServer.doQuery",
  133. new object[] { },
  134. ob);
  135. List<CmmPoundBaseEntity> list = EntityHelper.GetData<CmmPoundBaseEntity>(
  136. "com.steering.Mcms.PoundBaseServer.getPoudInfo",
  137. new object[] { new string[] { } },
  138. ob);
  139. RegStartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 07:00:00"));
  140. RegEndTime.Value = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 07:00:00"));
  141. LoadRecord();
  142. LoadTempate();
  143. //加载配置
  144. imageControl = new ImageControl(CmmBaseSpotInfo[0].FtpIp, CmmBaseSpotInfo[0].FtpPort, CmmBaseSpotInfo[0].FtpUserName, CmmBaseSpotInfo[0].FtpPassword, CmmBaseSpotInfo[0].Ftptype, CmmBaseSpotInfo[0].Ftppath, ob);
  145. imageControl.Start();
  146. // }
  147. // catch
  148. //{ }
  149. comboCount.Text = "1";
  150. }
  151. private void defultClenttEntity_ReceiveData(object sender, object data, string message, DataType datatype,
  152. byte[] bdata)
  153. {
  154. SocketClient client = sender as SocketClient;
  155. if (client.Show == true)
  156. {
  157. ShowMessage(data, message, datatype, sender);
  158. }
  159. }
  160. private void LoadRecord()
  161. {
  162. var dic = new Dictionary<string, object>();
  163. dic.Add("recordType", new List<string> { "1" });
  164. List<CmmInputRecordEntity> datas = EntityHelper.GetData<CmmInputRecordEntity>(
  165. "com.steering.Mcms.InputRecordServer.doQuery",
  166. new object[] { dic },
  167. ob);
  168. txtCar2.DataSource = datas.Where(p => p.RecordType == "1")
  169. .Select(p => p.RecordValue).Distinct().ToList();
  170. txtCar2.Text = "";
  171. dic = new Dictionary<string, object>();
  172. dic.Add("recordType", new List<string> { "2", "7", "8", "9" });
  173. _cmmInputRecordEntities = EntityHelper.GetData<CmmInputRecordEntity>(
  174. "com.steering.Mcms.InputRecordServer.doQuery",
  175. new object[] { dic },
  176. ob);
  177. }
  178. private void utbConnect_Click(object sender, EventArgs e)
  179. {
  180. if (communicationnow.Communication == null) return;
  181. if ((communicationnow.Communication != null) && communicationnow.Communication.Status)
  182. {
  183. communicationnow.Communication.Stop();
  184. }
  185. else
  186. {
  187. communicationnow.Communication.Start();
  188. }
  189. }
  190. private void utbMessage_Click(object sender, EventArgs e)
  191. {
  192. _frmMessage = new frmMessage();
  193. _frmMessage.Show();
  194. }
  195. //TUDO
  196. private void ShowMessage(object data, string message, DataType dataType, object sender)
  197. {
  198. SocketClient client = sender as SocketClient;
  199. if (dataType == DataType.ReceiveData)
  200. {
  201. double wt;
  202. if (double.TryParse(data.ToString2(), out wt))
  203. lblWtNow.SafeRefreshControl(() => { lblWtNow.Text = (wt / 100d).ToString("0.00") + "t"; });
  204. }
  205. else if (dataType == DataType.Open)
  206. {
  207. utbConnect.SafeRefreshControl(() => utbConnect.Appearance.ForeColor = Color.Red);
  208. lblMsg.SafeRefreshControl(
  209. () =>
  210. lblMsg.Text =
  211. client.Status
  212. ? "已打开"
  213. : "已关闭");
  214. // cboNo.SafeRefreshControl(() => cboNo.Enabled = false);
  215. }
  216. else if (dataType == DataType.Close)
  217. {
  218. utbConnect.SafeRefreshControl(() => utbConnect.Appearance.ForeColor = Color.Lime);
  219. lblMsg.SafeRefreshControl(
  220. () =>
  221. lblMsg.Text =
  222. client.Status
  223. ? "已打开"
  224. : "已关闭");
  225. }
  226. else if (dataType == DataType.Error)
  227. {
  228. MessageBox.Show(message);
  229. }
  230. else if (dataType == DataType.ClientReconnect)
  231. {
  232. lblMsg.SafeRefreshControl(() => lblMsg.Text = "网络异常,正在重连服务!");
  233. }
  234. lblStatus.SafeRefreshControl(() => lblStatus.Text = client.ToString());
  235. if ((_frmMessage != null) && !_frmMessage.IsDisposed)
  236. _frmMessage.SafeShowMsg(message, dataType);
  237. else
  238. _frmMessage = null;
  239. }
  240. private void utbShowWt_Click(object sender, EventArgs e)
  241. {
  242. string.Format("当前重量{0}", lblWt.Text.Replace("t", "吨")).Speak();
  243. }
  244. private void lblWtNow_Click(object sender, EventArgs e)
  245. {
  246. lblWt.Text = lblWtNow.Text;
  247. if (CurrentGrid.ActiveRow != null)
  248. {
  249. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  250. if ((current == null) || ("" == current.CarNo)) return;
  251. if ((tbWt.ActiveTab != null) && (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null))
  252. if (tbScondWt.ActiveTab.Key == "3")
  253. {
  254. }
  255. else if (tbScondWt.ActiveTab.Key == "0")
  256. {
  257. }
  258. else if ((tbScondWt.ActiveTab.Key == "1") && (tbOther.ActiveTab != null) &&
  259. (tbOther.ActiveTab.Key == "205"))
  260. {
  261. decimal wt, fwt;
  262. decimal.TryParse(lblWt.Text.Replace("t", ""), out wt);
  263. decimal.TryParse(current.RecordWeight.ToString3(), out fwt);
  264. ShowOutInfo(current.CarNo, wt - fwt);
  265. }
  266. else if ((tbScondWt.ActiveTab.Key == "1") && (tbOther.ActiveTab != null) &&
  267. (tbOther.ActiveTab.Key == "206"))
  268. {
  269. decimal wt, fwt;
  270. decimal.TryParse(lblWt.Text.Replace("t", ""), out wt);
  271. decimal.TryParse(current.RecordWeight.ToString3(), out fwt);
  272. if (wt - fwt > 0)
  273. matInfo13.SetWt(wt - fwt);
  274. // ShowOutInfoGp(current.CarNo, wt - fwt);
  275. }
  276. else if ((tbScondWt.ActiveTab.Key == "1") && (tbOther.ActiveTab != null) &&
  277. (tbOther.ActiveTab.Key == "109"))
  278. {
  279. var matInfo = GetMatInfo();
  280. if (matInfo != null)
  281. {
  282. decimal wt, fwt;
  283. if (decimal.TryParse(lblWt.Text.Replace("t", ""), out wt) &&
  284. decimal.TryParse(current.RecordWeight.ToString3(), out fwt))
  285. if (wt - fwt > 0)
  286. matInfo.SetWt(wt - fwt);
  287. }
  288. }
  289. }
  290. }
  291. private void utbShowCarNo_Click(object sender, EventArgs e)
  292. {
  293. if ((cbxCar1.SelectedIndex < 0) || string.IsNullOrWhiteSpace(txtCar2.Text)) return;
  294. string.Format(" {0}", cbxCar1.Text + txtCar2.Text).Speak();
  295. }
  296. private void chkGross_CheckedChanged(object sender, EventArgs e)
  297. {
  298. tbFirstWt.Visible = chkGross.Checked;
  299. utbSaveAsT.Visible = chkGross.Checked;
  300. if (chkGross.Checked)
  301. {
  302. checkBox1.Visible = false;
  303. recordType.Visible = false;
  304. }
  305. else
  306. {
  307. checkBox1.Visible = true;
  308. recordType.Visible = true;
  309. }
  310. }
  311. Thread thsave;
  312. Point screenPoint;
  313. void Savepicture(object str)
  314. {
  315. //*
  316. //截取屏幕信息
  317. // PbCache.actualFirstNo = CmmImage.ActualFirstNo;
  318. Rectangle rect = new Rectangle(screenPoint, this.Size);
  319. Image img = new Bitmap(rect.Width, rect.Height);
  320. Graphics g = Graphics.FromImage(img);
  321. g.CopyFromScreen(rect.X - 1, rect.Y - 1, 0, 0, rect.Size);//"D://file/1.jpg"
  322. img.Save(string.Format("{0}\\imgShort\\formalImg\\{1}_{2}_{3}.jpg",
  323. AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
  324. PbCache.sportInfo.BaseSpotNo,
  325. PbCache.actualFirstNo,
  326. (5)), System.Drawing.Imaging.ImageFormat.Jpeg);// 最后一张图片名称写死了
  327. //*
  328. //最后进行截图操作
  329. CameraShotCls cameraShot = new CameraShotCls();
  330. cameraShot.CapMethod(PbCache.actualFirstNo, communicationnow.PoundNo);
  331. }
  332. /// <summary>
  333. /// 一次称重保存
  334. /// </summary>
  335. /// <param name="sender"></param>
  336. /// <param name="e"></param>
  337. private void utbSave1_Click(object sender, EventArgs e)
  338. {
  339. if (lblWt.Text != lblWtNow.Text)
  340. {
  341. if ( MessageUtil.ShowYesNoAndQuestion("吨位不一致!请确认是否继续保存 ?") == DialogResult.No)
  342. return;
  343. }
  344. if (cmmPoundBase == null)
  345. {
  346. MessageBox.Show(@"无磅房权限");
  347. return;
  348. }
  349. if (string.IsNullOrWhiteSpace(txtCar2.Text) || string.IsNullOrWhiteSpace(cbxCar1.Text))
  350. {
  351. MessageBox.Show(@"未录入车牌号!");
  352. return;
  353. }
  354. decimal wt = 0;
  355. //测试注释 TZH
  356. //if (!decimal.TryParse(lblWt.Text.Replace("t", ""), out wt) || (wt <= 0))
  357. //{
  358. // MessageBox.Show(@"重量异常!");
  359. // return;
  360. //}
  361. var cmmWeightRecord = new CmmWeightRecordEntityFull();
  362. if (chkGross.Checked)
  363. {
  364. var matInfo = tbFirstWt.ActiveTab.TabPage.Controls.OfType<MatInfo>().FirstOrDefault();
  365. if (matInfo != null) cmmWeightRecord = matInfo.GetData();
  366. }
  367. if ((cmmWeightRecord.RecordNumber == null) && (cmmWeightRecord.MatInfos != null) &&
  368. cmmWeightRecord.MatInfos.Any())
  369. {
  370. MessageBox.Show("支数不能为空!");
  371. return;
  372. }
  373. cmmWeightRecord.CarNo = cbxCar1.Text + txtCar2.Text.ToUpper().Trim();
  374. cmmWeightRecord.Recoder = UserInfo.GetUserName();
  375. cmmWeightRecord.RecordType = !chkGross.Checked ? "101" : tbFirstWt.ActiveTab.Key;
  376. cmmWeightRecord.WtType = chkGross.Checked ? "1" : "0";
  377. cmmWeightRecord.Validflag = "1";
  378. cmmWeightRecord.RecordWeight = wt;
  379. cmmWeightRecord.RecoderLocation = cmmPoundBase.PoundNo;
  380. cmmWeightRecord.MatType = chkGross.Checked ? tbFirstWt.ActiveTab.Text
  381. : checkBox1.Checked ? recordType.Text : "";
  382. cmmWeightRecord.Memo = chkSteelCar.Checked ? "钢管" : "";
  383. if ("102" == cmmWeightRecord.RecordType)
  384. if ((cmmWeightRecord.RecordNumber == null) || (cmmWeightRecord.RecordNumber <= 0) ||
  385. (cmmWeightRecord.MatInfos == null) || !cmmWeightRecord.MatInfos.Any()
  386. || cmmWeightRecord.MatInfos.Any(p => (p.ActCount == null) || (p.ActCount <= 0)))
  387. {
  388. MessageBox.Show("支数不能为空!");
  389. return;
  390. }
  391. // 先毛后皮
  392. if (checkBox1.Checked)
  393. {
  394. var key = "";
  395. key = recordType.Value.ToString2();
  396. if (key == "" || key == null)
  397. {
  398. MessageBox.Show("请选择过磅类型!");
  399. return;
  400. }
  401. cmmWeightRecord.WtType = "1";
  402. cmmWeightRecord.RecordType = key;
  403. }
  404. var list =
  405. cmmWeightRecordEntityBindingSource.DataSource as List<CmmWeightRecordEntity>;
  406. if ((list != null) && list.Any(p => p.CarNo == cmmWeightRecord.CarNo))
  407. if (MessageUtil.ShowYesNoAndQuestion("车牌已经存在皮重,是否继续保存皮重?") == DialogResult.No)
  408. return;
  409. var json = JsonConvert.SerializeObject(cmmWeightRecord, Formatting.None, new JsonSerializerSettings
  410. { ContractResolver = new CamelCasePropertyNamesContractResolver() });
  411. var ccp = new CoreClientParam
  412. {
  413. ServerName = "com.steering.Mcms.LocalTruckScale",
  414. MethodName = "DoAdd",
  415. ServerParams = new object[]
  416. {
  417. "",
  418. json
  419. }
  420. };
  421. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  422. if (true)//(ccp.ReturnCode != -1)
  423. if (ccp.ReturnInfo.ToString2().Contains("称重完成"))
  424. {
  425. ccp.ReturnInfo.ToString2().Speak();
  426. lblWt.Text = "0.000t";
  427. LoadRecord();
  428. Query();
  429. var matInfo = GetMatInfo();
  430. if (matInfo != null) matInfo.SetDefault(null);
  431. }
  432. else
  433. {
  434. MessageUtil.ShowTips(ccp.ReturnInfo);
  435. }
  436. PbCache.actualFirstNo = ccp.ReturnObject.ToString();//tudo
  437. addActual(communicationnow.PoundNo, PbCache.actualFirstNo);
  438. checkBox1.Checked = false;
  439. chkSteelCar.Checked = false;
  440. chkGross.Checked = false;
  441. tbFirstWt.Visible = chkGross.Checked;
  442. utbSaveAsT.Visible = chkGross.Checked;
  443. #region 截取图片信息
  444. try
  445. {
  446. screenPoint = this.PointToScreen(new Point());
  447. thsave = new Thread(new ParameterizedThreadStart(Savepicture));
  448. thsave.Start("");
  449. playVioce("称重完成");
  450. }
  451. catch (Exception ex)
  452. {
  453. l.WriteLog(5, PbCache.lockCarNo + "截图失败");
  454. }
  455. #endregion
  456. //TUDO//
  457. }
  458. /// <summary>
  459. /// 二次称重
  460. /// </summary>
  461. /// <param name="sender"></param>
  462. /// <param name="e"></param>
  463. private void btnSave2_Click(object sender, EventArgs e)
  464. {
  465. string CX = "";
  466. if ( CX_HT.Value != null)
  467. {
  468. CX = CX_HT.Value.ToString();
  469. }
  470. if (cmmPoundBase == null)
  471. {
  472. MessageBox.Show(@"无磅房权限");
  473. return;
  474. }
  475. if (lblWt.Text != lblWtNow.Text)
  476. {
  477. if (MessageUtil.ShowYesNoAndQuestion("吨位不一致!请确认是否继续保存 ?") == DialogResult.No)
  478. return;
  479. }
  480. if (tbScondWt.ActiveTab == null) return;
  481. if (CurrentGrid.ActiveRow == null)
  482. {
  483. MessageBox.Show(@"请选择第一次称重记录");
  484. return;
  485. }
  486. decimal wt = 0;
  487. //测试注释 TZH
  488. //if (!decimal.TryParse(lblWt.Text.Replace("t", ""), out wt) || (wt <= 0))
  489. //{
  490. // MessageBox.Show(@"重量异常!");
  491. // return;
  492. //}
  493. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  494. if (current == null) return;
  495. if (current.CarNo != (cbxCar1.Text + txtCar2.Text))
  496. {
  497. MessageBox.Show("选中的车号与显示的车号不一致");
  498. return;
  499. }
  500. var key = GetKey();
  501. CmmWeightRecordEntityFull cmmWeightRecord;
  502. if ("207" == key)
  503. {
  504. cmmWeightRecord = new CmmWeightRecordEntityFull();
  505. if (checkBox3.Checked)
  506. {
  507. var matInfo = GetMatInfo();
  508. cmmWeightRecord = matInfo.GetData();
  509. cmmWeightRecord.WtType = "0";
  510. }
  511. }
  512. else
  513. {
  514. var matInfo = GetMatInfo();
  515. if (matInfo == null) return;
  516. cmmWeightRecord = matInfo.GetData();
  517. cmmWeightRecord.WtType = "1";
  518. if ((cmmWeightRecord.RecordNumber == null) && (cmmWeightRecord.MatInfos != null) &&
  519. cmmWeightRecord.MatInfos.Any())
  520. {
  521. MessageBox.Show("数量不能为空!");
  522. return;
  523. }
  524. }
  525. var hookWtStr = "";
  526. if (key == "201")
  527. {
  528. if ((cmmWeightRecord.MatInfos == null) || !cmmWeightRecord.MatInfos.Any())
  529. {
  530. MessageBox.Show("无配送单信息!");
  531. return;
  532. }
  533. if (cmmWeightRecord.MatInfos.Any(p => p.ActWeight == null))
  534. {
  535. MessageBox.Show("有炉号没有钩子称重量!");
  536. return;
  537. }
  538. var hookWt = cmmWeightRecord.MatInfos.Select(p => (decimal)p.ActWeight).Sum();
  539. hookWtStr = hookWt.ToString();
  540. decimal NetWt;
  541. decimal wt2, wt1;
  542. if (decimal.TryParse(lblWt.Text.Replace("t", ""), out wt2) &&
  543. decimal.TryParse(current.RecordWeight.ToString3(), out wt1))
  544. {
  545. NetWt = wt2 - wt1;
  546. }
  547. else
  548. {
  549. MessageBox.Show("数据异常!");
  550. return;
  551. }
  552. if (NetWt <= 0)
  553. {
  554. MessageBox.Show("净重小于0!");
  555. return;
  556. }
  557. cmmWeightRecord.RealWt = NetWt;
  558. if (Math.Abs(NetWt - hookWt) * 1000 / NetWt >= 5)
  559. {
  560. var msg = " 净重与钩子称 误差超过千分之5";
  561. msg.Speak();
  562. if (
  563. MessageUtil.ShowYesNoAndQuestion(" 净重: " + NetWt + "t 钩子称重量: " + hookWt + "t 磅差 " +
  564. (NetWt - hookWt) + "t 误差超过千分之5, 请确认是否继续保存 ?") ==
  565. DialogResult.No)
  566. return;
  567. }
  568. }
  569. cmmWeightRecord.RecordType = GetKey();
  570. cmmWeightRecord.Recoder = UserInfo.GetUserName();
  571. cmmWeightRecord.Validflag = "2";
  572. cmmWeightRecord.RecordWeight = wt;
  573. cmmWeightRecord.RecoderLocation = cmmPoundBase.PoundNo;
  574. cmmWeightRecord.CarNo = current.CarNo;
  575. cmmWeightRecord.MatType = GetMatType();
  576. if (("208" == cmmWeightRecord.RecordType) &&
  577. ((cmmWeightRecord.MatInfos == null) || !cmmWeightRecord.MatInfos.Any()))
  578. {
  579. MessageBox.Show(@"无废品出库信息,无法保存!");
  580. return;
  581. }
  582. if (("201" == cmmWeightRecord.RecordType) &&
  583. ((cmmWeightRecord.MatInfos == null) || !cmmWeightRecord.MatInfos.Any()))
  584. {
  585. MessageBox.Show(@"无装车单信息,无法保存!");
  586. return;
  587. }
  588. //钢坯采购空车回皮直接做法,下次判断
  589. var newKey = "";
  590. if (checkBox3.Checked && cmmWeightRecord.RecordType == "207")
  591. {
  592. newKey = qitahuipi.ActiveTab.Key;
  593. cmmWeightRecord.MatType = qitahuipi.ActiveTab.Text;
  594. }
  595. var json = JsonConvert.SerializeObject(cmmWeightRecord, Formatting.None,
  596. new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
  597. object[] o = null;
  598. if (cmmWeightRecord.RecordType == "207" && checkBox3.Checked)
  599. {
  600. if ("102" == newKey)
  601. {
  602. cmmWeightRecord.WtType = "0";
  603. decimal NetWt;
  604. decimal wt2, wt1;
  605. if (decimal.TryParse(lblWt.Text.Replace("t", ""), out wt2) &&
  606. decimal.TryParse(current.RecordWeight.ToString3(), out wt1))
  607. {
  608. NetWt = wt1 - wt2;
  609. }
  610. else
  611. {
  612. MessageBox.Show("数据异常!");
  613. return;
  614. }
  615. if (NetWt <= 0)
  616. {
  617. MessageBox.Show("净重小于0!");
  618. return;
  619. }
  620. cmmWeightRecord.RealWt = NetWt;
  621. }
  622. if ("102" == newKey)
  623. if ((cmmWeightRecord.RecordNumber == null) || (cmmWeightRecord.RecordNumber <= 0) ||
  624. (cmmWeightRecord.MatInfos == null) || !cmmWeightRecord.MatInfos.Any()
  625. || cmmWeightRecord.MatInfos.Any(p => (p.ActCount == null) || (p.ActCount <= 0)))
  626. {
  627. MessageBox.Show("支数不能为空!");
  628. return;
  629. }
  630. o = new object[]
  631. {
  632. current.RecordNo,
  633. hookWtStr,
  634. json,
  635. newKey,
  636. CX
  637. };
  638. }
  639. else
  640. {
  641. o = new object[]
  642. {
  643. current.RecordNo,
  644. hookWtStr,
  645. json,
  646. CX
  647. };
  648. }
  649. var ccp = new CoreClientParam
  650. {
  651. ServerName = "com.steering.Mcms.LocalTruckScale",
  652. MethodName = "DoAdd",
  653. ServerParams = o
  654. };
  655. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  656. if (ccp.ReturnCode != -1)
  657. {
  658. PbCache.actualFirstNo = ccp.ReturnObject.ToString();
  659. addActual(communicationnow.PoundNo, PbCache.actualFirstNo);
  660. checkBox3.Checked = false;
  661. checkBox3.Visible = false;
  662. qitahuipi.Visible = checkBox3.Checked;
  663. #region 截取图片信息
  664. try
  665. {
  666. screenPoint = this.PointToScreen(new Point());
  667. thsave = new Thread(new ParameterizedThreadStart(Savepicture));
  668. thsave.Start("");
  669. playVioce("称重完成");
  670. }
  671. catch (Exception ex)
  672. {
  673. l.WriteLog(5, PbCache.lockCarNo + "截图失败");
  674. }
  675. #endregion
  676. if (ccp.ReturnInfo.ToString2().Contains("称重完成"))
  677. {
  678. decimal wt2;
  679. decimal.TryParse(lblWt.Text.Replace("t", ""), out wt2);
  680. lblWt.Text = "0.000t";
  681. var result = ccp.ReturnInfo.ToString2().Split('|');
  682. result[0].Speak();
  683. if (result.Length > 1)
  684. if ((key == "201") && (wt2 > 50) && (MessageUtil.ShowYesNoAndQuestion("称重完成! 毛重超过50吨, 是否继续打印磅单?") ==
  685. DialogResult.No))
  686. {
  687. }
  688. else
  689. {
  690. Print(result[1]);
  691. }
  692. LoadRecord();
  693. Query();
  694. Query2();
  695. //TODO 打印
  696. var matInfo = GetMatInfo();
  697. if (matInfo != null) matInfo.SetDefault(null);
  698. }
  699. else
  700. {
  701. MessageUtil.ShowTips(ccp.ReturnInfo);
  702. }
  703. }
  704. }
  705. private void Print(string resultNo, bool spilt = false)
  706. {
  707. var strurl =
  708. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=" +
  709. (spilt ? "RepThCattyListCut" : "RepThCattyList") +
  710. ".cpt&RESULT_NO=" +
  711. resultNo;
  712. var fre = new FrmRepBrower(ob, strurl)
  713. {
  714. Size = new Size(900,
  715. 500)
  716. };
  717. fre.Show();
  718. }
  719. private void Print2(string resultNo, bool spilt = false)
  720. {
  721. var strurl =
  722. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=" +
  723. (spilt ? "RepThCattyListCut" : "RepThCattyList") +
  724. ".cpt&RESULT_NO=" +
  725. resultNo;
  726. var fre = new FrmRepBrower(ob, strurl)
  727. {
  728. Size = new Size(900,
  729. 500)
  730. };
  731. fre.Show();
  732. }
  733. //TUDO
  734. private void frmLocalTruckScale_FormClosed(object sender, FormClosedEventArgs e)
  735. {
  736. //if ((communication != null) && communication.Status)
  737. // communication.Stop();
  738. timer.Stop();
  739. }
  740. private void Query()
  741. {
  742. var dic = new Dictionary<string, object>();
  743. if (!string.IsNullOrWhiteSpace(cboPoundList.Text))
  744. dic.Add("poundNo", cboPoundList.Text);
  745. dic.Add("validflag", new List<string> { "1" });
  746. cmmWeightRecordEntityBindingSource.DataSource = EntityHelper.GetData<CmmWeightRecordEntity>(
  747. "com.steering.Mcms.RecordServer.doQueryRecord",
  748. new object[] { dic },
  749. ob);
  750. Comm.RefreshAndAutoSize(CurrentGrid);
  751. }
  752. private void LoadTempate()
  753. {
  754. /* if (cmmPoundBase == null)
  755. return;
  756. */
  757. _templateList = EntityHelper.GetData<CmmRecordTemplateEntity>(
  758. "com.steering.Mcms.TemplateServer.doQueryTempate",
  759. new object[] { "" },
  760. ob);
  761. tbFirstWt_SelectedTabChanged(null, null);
  762. }
  763. private void utbSaveAsT_Click(object sender, EventArgs e)
  764. {
  765. if (cmmPoundBase == null)
  766. {
  767. MessageBox.Show(@"无磅房权限");
  768. return;
  769. }
  770. if (tbWt.ActiveTab == null) return;
  771. var matInfo = GetMatInfo();
  772. if (matInfo != null)
  773. {
  774. var cmmWeightRecord = matInfo.GetData();
  775. string projectName;
  776. using (var fractureInfo = new ProjectName("模板名"))
  777. {
  778. fractureInfo.ShowDialog();
  779. if (fractureInfo.DialogResult != DialogResult.OK) return;
  780. projectName = fractureInfo.ProjectNameStr;
  781. }
  782. var template = new CmmRecordTemplateEntity
  783. {
  784. CreateUser = UserInfo.GetUserName(),
  785. TemplateKey = GetKey(),
  786. TemplateLocation = cmmPoundBase.PoundNo,
  787. TemplateXml = cmmWeightRecord.ToString(),
  788. TemplateName = projectName
  789. };
  790. var ccp = new CoreClientParam
  791. {
  792. ServerName = "com.steering.Mcms.TemplateServer",
  793. MethodName = "DoSaveTemplateNo",
  794. ServerParams = new object[]
  795. {
  796. JsonConvert.SerializeObject(template, Formatting.None, new JsonSerializerSettings
  797. {ContractResolver = new CamelCasePropertyNamesContractResolver()})
  798. }
  799. };
  800. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  801. if (ccp.ReturnCode != -1)
  802. {
  803. MessageUtil.ShowTips(ccp.ReturnInfo);
  804. if (ccp.ReturnInfo.Equals("保存成功!"))
  805. LoadTempate();
  806. }
  807. }
  808. }
  809. private MatInfo GetMatInfo()
  810. {
  811. MatInfo matInfo = null;
  812. if (tbWt.ActiveTab == null) return null;
  813. if ((tbWt.ActiveTab.Key == "1") && (tbFirstWt.ActiveTab != null))
  814. matInfo = tbFirstWt.ActiveTab.TabPage.Controls.OfType<MatInfo>().FirstOrDefault();
  815. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "1") &&
  816. (tbOther.ActiveTab != null))
  817. matInfo = tbOther.ActiveTab.TabPage.Controls.OfType<MatInfo>().FirstOrDefault();
  818. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "3"))
  819. matInfo = matInfo15;
  820. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "0"))
  821. matInfo = matInfo16;
  822. // ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  823. // (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null)
  824. // matInfo = qitahuipi.ActiveTab.TabPage.Controls.OfType<MatInfo>().FirstOrDefault();这个以后试试可以用不--byzc
  825. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  826. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "102")
  827. matInfo = matInfo20;
  828. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  829. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "110")
  830. matInfo = matInfo28;
  831. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  832. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "103")
  833. matInfo = matInfo21;
  834. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  835. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "104")
  836. matInfo = matInfo22;
  837. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  838. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "105")
  839. matInfo = matInfo23;
  840. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  841. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "106")
  842. matInfo = matInfo24;
  843. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  844. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "107")
  845. matInfo = matInfo25;
  846. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  847. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "108")
  848. matInfo = matInfo26;
  849. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  850. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "109")
  851. matInfo = matInfo27;
  852. else if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  853. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "301")
  854. matInfo = matInfo19;
  855. return matInfo;
  856. }
  857. private MatInfo GetMatInfoByKey(string key)
  858. {
  859. MatInfo matInfo = null;
  860. foreach (var ultraTab in tbFirstWt.Tabs)
  861. {
  862. var matinfo = ultraTab.TabPage.Controls.OfType<MatInfo>().Where(p => p.Key == key).ToList();
  863. if (matinfo.Any()) return matinfo[0];
  864. }
  865. foreach (var ultraTab in tbOther.Tabs)
  866. {
  867. var matinfo = ultraTab.TabPage.Controls.OfType<MatInfo>().Where(p => p.Key == key).ToList();
  868. if (matinfo.Any()) return matinfo[0];
  869. }
  870. if (key == "201") return matInfo16;
  871. if (key == "301") return matInfo19;
  872. return matInfo;
  873. }
  874. private void utbDelete_Click(object sender, EventArgs e)
  875. {
  876. var matInfo = GetMatInfo();
  877. if (matInfo != null) matInfo.DeleteRow();
  878. }
  879. private void utbClear_Click(object sender, EventArgs e)
  880. {
  881. var matInfo = GetMatInfo();
  882. if (matInfo != null) matInfo.Clear();
  883. }
  884. private void tbFirstWt_SelectedTabChanged(object sender, SelectedTabChangedEventArgs e)
  885. {
  886. LoadTem();
  887. var matInfo = GetMatInfo();
  888. if (matInfo != null) matInfo.Clear();
  889. //TZH 24.11.7 加入取产销的废品合同号
  890. if (tbOther.ActiveTab.Key == "202")
  891. {
  892. CX_HTH.Visible = true;
  893. CX_HT.Visible = true;
  894. DataTable dt = ServerHelper.GetData("com.steering.Mcms.TemplateServer.SelectCX", new object[] { }, ob);
  895. if (dt != null && dt.Rows.Count > 0)
  896. {
  897. CX_HT.DataSource = dt;
  898. CX_HT.ValueMember = "BILL_NO";
  899. CX_HT.DisplayMember = "BILL_NO";
  900. }
  901. }
  902. else
  903. {
  904. CX_HTH.Visible = false;
  905. CX_HT.Visible = false;
  906. }
  907. if (CurrentGrid.ActiveRow != null)
  908. {
  909. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  910. if ((current == null) || ("" == current.CarNo)) return;
  911. if ((tbWt.ActiveTab != null) && (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null))
  912. if (tbScondWt.ActiveTab.Key == "3")
  913. {
  914. }
  915. else if (tbScondWt.ActiveTab.Key == "0")
  916. {
  917. }
  918. else if ((tbScondWt.ActiveTab.Key == "1") && (tbOther.ActiveTab != null) &&
  919. (tbOther.ActiveTab.Key == "205"))
  920. {
  921. decimal wt, fwt;
  922. decimal.TryParse(lblWt.Text.Replace("t", ""), out wt);
  923. decimal.TryParse(current.RecordWeight.ToString3(), out fwt);
  924. ShowOutInfo(current.CarNo, wt - fwt);
  925. }
  926. else if ((tbScondWt.ActiveTab.Key == "1") && (tbOther.ActiveTab != null) &&
  927. (tbOther.ActiveTab.Key == "206"))
  928. {
  929. decimal wt, fwt;
  930. decimal.TryParse(lblWt.Text.Replace("t", ""), out wt);
  931. decimal.TryParse(current.RecordWeight.ToString3(), out fwt);
  932. if (wt - fwt > 0)
  933. matInfo13.SetWt(wt - fwt);
  934. //ShowOutInfoGp(current.CarNo, wt - fwt);
  935. }
  936. else
  937. {
  938. if (matInfo != null)
  939. {
  940. decimal wt, fwt;
  941. if (decimal.TryParse(lblWt.Text.Replace("t", ""), out wt) &&
  942. decimal.TryParse(current.RecordWeight.ToString3(), out fwt))
  943. if (wt - fwt > 0)
  944. matInfo.SetWt(wt - fwt);
  945. }
  946. }
  947. }
  948. utbSelect.Visible = (tbWt.ActiveTab != null) && (tbWt.ActiveTab.Key == "1") && (tbFirstWt.ActiveTab != null) &&
  949. (tbFirstWt.ActiveTab.Key == "102");
  950. utbSelect2.Visible = utbSelect.Visible;
  951. }
  952. private void LoadTem()
  953. {
  954. if (_templateList == null) return;
  955. var key = GetKey();
  956. if (string.IsNullOrWhiteSpace(key)) return;
  957. if ((_cmmInputRecordEntities != null) && _cmmInputRecordEntities.Any())
  958. {
  959. var matInfo = GetMatInfo();
  960. if (matInfo != null)
  961. matInfo.iniMatName(
  962. _cmmInputRecordEntities.Where(
  963. p => (p.RecordKey == key) || string.IsNullOrWhiteSpace(p.RecordKey)).ToList());
  964. }
  965. lvTemplate.Items.Clear();
  966. lvTemplate.Items.AddRange(_templateList.Where(p => CheckShowKey(p.TemplateKey, key))
  967. .Select(p =>
  968. {
  969. var
  970. temp =
  971. new UltraListViewItem(p.TemplateName, null, null) { Key = p.TemplateNo };
  972. try
  973. {
  974. temp.Tag =
  975. XmlHelper.FromXElement<CmmWeightRecordEntityFull>(XElement.Parse(p.TemplateXml));
  976. }
  977. catch (Exception)
  978. {
  979. // ignored
  980. }
  981. return temp;
  982. }
  983. ).
  984. ToArray()
  985. );
  986. }
  987. private string GetKey()
  988. {
  989. return tbWt.ActiveTab.Key == "1"
  990. ? (tbFirstWt.ActiveTab == null ? "" : tbFirstWt.ActiveTab.Key)
  991. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "1") &&
  992. (tbOther.ActiveTab != null)
  993. ? tbOther.ActiveTab.Key
  994. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "0")
  995. ? "201"
  996. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  997. (tbScondWt.ActiveTab.Key == "2")
  998. ? "207"
  999. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  1000. (tbScondWt.ActiveTab.Key == "3")
  1001. ? "208"
  1002. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  1003. (tbScondWt.ActiveTab.Key == "4")
  1004. ? "102"
  1005. : "";
  1006. }
  1007. private string GetMatType()
  1008. {
  1009. return tbWt.ActiveTab.Key == "1"
  1010. ? ""
  1011. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "1") &&
  1012. (tbOther.ActiveTab != null)
  1013. ? tbOther.ActiveTab.Text
  1014. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "0")
  1015. ? "钢管发运"
  1016. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  1017. (tbScondWt.ActiveTab.Key == "2")
  1018. ? ""
  1019. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  1020. (tbScondWt.ActiveTab.Key == "3")
  1021. ? "其它内转"
  1022. : ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  1023. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "102")
  1024. ? "钢坯采购"
  1025. : "";
  1026. }
  1027. private void lvTemplate_MouseClick(object sender, MouseEventArgs e)
  1028. {
  1029. var listView = sender as UltraListView;
  1030. if (e.Button == MouseButtons.Right)
  1031. {
  1032. var itemAtPoint = lvTemplate.ItemFromPoint(e.Location);
  1033. if (itemAtPoint != null)
  1034. {
  1035. lvTemplate.ContextMenuStrip = listViewMenuStrip;
  1036. ISelectionManager selectionManager = listView;
  1037. if (selectionManager != null) selectionManager.SelectItem(itemAtPoint, true);
  1038. itemAtPoint.Activate();
  1039. }
  1040. }
  1041. }
  1042. private void deleteTemplate_Click(object sender, EventArgs e)
  1043. {
  1044. if (lvTemplate.ActiveItem == null) return;
  1045. var ccp = new CoreClientParam
  1046. {
  1047. ServerName = "com.steering.Mcms.TemplateServer",
  1048. MethodName = "DoDeleteTemplate",
  1049. ServerParams = new object[]
  1050. {
  1051. lvTemplate.ActiveItem.Key,
  1052. UserInfo.GetUserName()
  1053. }
  1054. };
  1055. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1056. if (ccp.ReturnCode != -1)
  1057. {
  1058. MessageUtil.ShowTips(ccp.ReturnInfo);
  1059. if (ccp.ReturnInfo.Equals("删除成功!"))
  1060. LoadTempate();
  1061. }
  1062. }
  1063. private void CurrentGrid_AfterRowActivate(object sender, EventArgs e)
  1064. {
  1065. CurrentGrid.ActiveRow.RowSelectorAppearance.BackColor = Color.LightGreen;
  1066. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  1067. if ((current == null) || ("" == current.CarNo)) return;
  1068. if (current.firstGross == "是")
  1069. {
  1070. checkBox3.Visible = true;
  1071. ultraButton2.Visible = true;
  1072. }
  1073. else
  1074. {
  1075. checkBox3.Visible = false;
  1076. ultraButton2.Visible = false;
  1077. }
  1078. if ((tbWt.ActiveTab != null) && (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null))
  1079. if (tbScondWt.ActiveTab.Key == "3")
  1080. ShowWasteInfo(current.CarNo);
  1081. else if (tbScondWt.ActiveTab.Key == "0")
  1082. ShowLoadvehicleInfo(current.CarNo);
  1083. else if ((tbScondWt.ActiveTab.Key == "1") && (tbOther.ActiveTab != null) && (tbOther.ActiveTab.Key == "205"))
  1084. {
  1085. decimal wt, fwt;
  1086. decimal.TryParse(lblWt.Text.Replace("t", ""), out wt);
  1087. decimal.TryParse(current.RecordWeight.ToString3(), out fwt);
  1088. ShowOutInfo(current.CarNo, wt - fwt);
  1089. }
  1090. else if ((tbScondWt.ActiveTab.Key == "1") && (tbOther.ActiveTab != null) && (tbOther.ActiveTab.Key == "206"))
  1091. {
  1092. decimal wt, fwt;
  1093. decimal.TryParse(lblWt.Text.Replace("t", ""), out wt);
  1094. decimal.TryParse(current.RecordWeight.ToString3(), out fwt);
  1095. if (wt - fwt > 0)
  1096. matInfo13.SetWt(wt - fwt);
  1097. //ShowOutInfoGp(current.CarNo, wt - fwt);
  1098. }
  1099. else
  1100. {
  1101. var matInfo = GetMatInfo();
  1102. if (matInfo != null)
  1103. {
  1104. decimal wt, fwt;
  1105. if (decimal.TryParse(lblWt.Text.Replace("t", ""), out wt) &&
  1106. decimal.TryParse(current.RecordWeight.ToString3(), out fwt))
  1107. if (wt - fwt > 0)
  1108. matInfo.SetWt(wt - fwt);
  1109. }
  1110. }
  1111. }
  1112. // 显示废品信息
  1113. public void ShowWasteInfo(string carNo)
  1114. {
  1115. var cmmWeightRecordEntityFull = new CmmWeightRecordEntityFull();
  1116. var dt = ServerHelper.GetData("com.steering.Mcms.MatOutServer.doQueryWasteInfo", new object[] { carNo }, ob);
  1117. if ((dt != null) && (dt.Rows.Count > 0))
  1118. {
  1119. cmmWeightRecordEntityFull.ShippersName = dt.Rows[0]["STORAGE_NAME_FROM"].ToString2();
  1120. cmmWeightRecordEntityFull.LoadvehicleNo = dt.Rows[0]["OUTSTOCK_DOC"].ToString2();
  1121. cmmWeightRecordEntityFull.ReceiveName = dt.Rows[0]["STORAGE_NAME_TO"].ToString2();
  1122. cmmWeightRecordEntityFull.RecordNumber = decimal.Parse(dt.Rows[0]["ACT_COUNT"].ToString3());
  1123. cmmWeightRecordEntityFull.MatName = "废品管";
  1124. foreach (DataRow dtcRow in dt.Rows)
  1125. {
  1126. var cmmWeightMatEntity = new CmmWeightMatEntity
  1127. {
  1128. Produccode = dtcRow["PRODUCCODE"].ToString2(),
  1129. Producname = dtcRow["PRODUCNAME"].ToString2(),
  1130. Gradecode = dtcRow["GRADECODE"].ToString2(),
  1131. Gradename = dtcRow["GRADENAME"].ToString2(),
  1132. Steelcode = dtcRow["STEELCODE"].ToString2(),
  1133. Steelname = dtcRow["STEELNAME"].ToString2(),
  1134. ActLenTemp = dtcRow["ACT_LEN_MIN"].ToString3() + "-" +
  1135. dtcRow["ACT_LEN_MAX"].ToString3(),
  1136. ActWeight = decimal.Parse(dtcRow["ACT_WEIGHT"].ToString3()),
  1137. ActCount = decimal.Parse(dtcRow["ACT_COUNT"].ToString3()),
  1138. JudgeStoveNo = dtcRow["JUDGE_STOVE_NO"].ToString2(),
  1139. ActDimater = decimal.Parse(dtcRow["ACT_DIMATER"].ToString3()),
  1140. ActHeight = decimal.Parse(dtcRow["ACT_HEIGHT"].ToString3())
  1141. };
  1142. cmmWeightRecordEntityFull.MatInfos.Add(cmmWeightMatEntity);
  1143. }
  1144. }
  1145. matInfo15.SetDefault(cmmWeightRecordEntityFull);
  1146. }
  1147. //显示装车单信息
  1148. public void ShowLoadvehicleInfo(string carNo)
  1149. {
  1150. var cmmWeightRecordEntityFull = new CmmWeightRecordEntityFull();
  1151. var dt = ServerHelper.GetData("com.steering.Mcms.LoadVehicleServer.doQueryLoadvehicleInfo",
  1152. new object[] { carNo }, ob);
  1153. if ((dt != null) && (dt.Rows.Count > 0))
  1154. {
  1155. cmmWeightRecordEntityFull.ShippersName = dt.Rows[0]["BASENAME"].ToString2();
  1156. cmmWeightRecordEntityFull.LoadvehicleNo = dt.Rows[0]["LOADVEHICLE_NO"].ToString2();
  1157. cmmWeightRecordEntityFull.ReceiveName = dt.Rows[0]["RECEIV_NM"].ToString2();
  1158. cmmWeightRecordEntityFull.RecordNumber = decimal.Parse(dt.Rows[0]["STACKING_PIECE"].ToString3());
  1159. cmmWeightRecordEntityFull.ShippersName = dt.Rows[0]["BASENAME"].ToString2();
  1160. cmmWeightRecordEntityFull.OrderName = dt.Rows[0]["CUSTOMER_NM"].ToString2();
  1161. cmmWeightRecordEntityFull.MatName = "钢管";
  1162. cmmWeightRecordEntityFull.MatInfos = new List<CmmWeightMatEntity>();
  1163. var dtc = ServerHelper.GetData("com.steering.Mcms.LoadVehicleServer.doQueryLoadvehicleMatInfo",
  1164. new object[] { cmmWeightRecordEntityFull.LoadvehicleNo }, ob);
  1165. if ((dtc != null) && (dtc.Rows.Count > 0))
  1166. foreach (DataRow dtcRow in dtc.Rows)
  1167. {
  1168. var cmmWeightMatEntity = new CmmWeightMatEntity
  1169. {
  1170. StorageNo = dtcRow["STORAGE_NO"].ToString2(),
  1171. StorageName = dtcRow["STORAGE_NAME"].ToString2(),
  1172. StoveNo = dtcRow["STOVE_NO"].ToString2(),
  1173. OrderNo = dtcRow["ORDER_NO"].ToString2(),
  1174. OrderSeq = dtcRow["ORDER_SEQ"].ToString2(),
  1175. OrderSeqNo = dtcRow["ORDER_SEQ_NO"].ToString2(),
  1176. ProOrderNo = dtcRow["ORDER_NO"].ToString2() + "/" +
  1177. dtcRow["ORDER_SEQ"].ToString2(),
  1178. Produccode = dtcRow["PRODUCCODE"].ToString2(),
  1179. Producname = dtcRow["PRODUCNAME"].ToString2(),
  1180. StdCode = dtcRow["STD_CODE"].ToString2(),
  1181. StdName = dtcRow["STD_NAME"].ToString2(),
  1182. Gradecode = dtcRow["GRADECODE"].ToString2(),
  1183. Gradename = dtcRow["GRADENAME"].ToString2(),
  1184. Steelcode = dtcRow["STEELCODE"].ToString2(),
  1185. Steelname = dtcRow["STEELNAME"].ToString2(),
  1186. SpecCode = dtcRow["SPEC_CODE"].ToString2(),
  1187. SpecName = dtcRow["SPEC_NAME"].ToString2(),
  1188. ModelCode = dtcRow["MODEL_CODE"].ToString2(),
  1189. ModelDesc = dtcRow["MODEL_DESC"].ToString2(),
  1190. ActLenMin = decimal.Parse(dtcRow["ACT_LEN_MIN"].ToString3()),
  1191. ActLenMax = decimal.Parse(dtcRow["ACT_LEN_MAX"].ToString3()),
  1192. ActLenTemp = dtcRow["ACT_LEN_MIN"].ToString3() + "-" +
  1193. dtcRow["ACT_LEN_MAX"].ToString3(),
  1194. ActCount = decimal.Parse(dtcRow["ACT_COUNT"].ToString3()),
  1195. JudgeStoveNo = dtcRow["JUDGE_STOVE_NO"].ToString2(),
  1196. ActDimater = decimal.Parse(dtcRow["ACT_DIMATER"].ToString3()),
  1197. ActHeight = decimal.Parse(dtcRow["ACT_HEIGHT"].ToString3())
  1198. };
  1199. cmmWeightRecordEntityFull.MatInfos.Add(cmmWeightMatEntity);
  1200. }
  1201. try
  1202. {
  1203. var dth = ServerHelper.GetData("com.steering.Mcms.LoadVehicleServer.doQueryHook",
  1204. new object[] { cmmWeightRecordEntityFull.LoadvehicleNo }, ob);
  1205. if ((dth != null) && (dth.Rows.Count > 0))
  1206. foreach (DataRow dthRow in dth.Rows)
  1207. {
  1208. var total = double.Parse(dthRow["HOOK_WEIGHT"].ToString3());
  1209. double num = int.Parse(cmmWeightRecordEntityFull.MatInfos.Where(
  1210. p => p.JudgeStoveNo == dthRow["JUDGE_STOVE_NO"].ToString2())
  1211. .Select(p => p.ActCount)
  1212. .Sum()
  1213. .ToString3());
  1214. var perWt = Math.Round(total / num, 3);
  1215. var list = cmmWeightRecordEntityFull.MatInfos.Where(
  1216. p => p.JudgeStoveNo == dthRow["JUDGE_STOVE_NO"].ToString2()).ToList();
  1217. for (var i = 0; i < list.Count; i++)
  1218. if (i == 0)
  1219. list[i].ActWeight =
  1220. decimal.Parse(
  1221. (total - perWt * (num - double.Parse(list[i].ActCount.ToString3()))).ToString3
  1222. ());
  1223. else
  1224. list[i].ActWeight =
  1225. decimal.Parse(
  1226. (perWt * double.Parse(list[i].ActCount.ToString3())).ToString3());
  1227. }
  1228. }
  1229. catch (Exception)
  1230. {
  1231. }
  1232. }
  1233. else
  1234. {
  1235. cmmWeightRecordEntityFull = null;
  1236. }
  1237. matInfo16.SetDefault(cmmWeightRecordEntityFull);
  1238. }
  1239. public void ShowOutInfo(string carNo, decimal nutWt)
  1240. {
  1241. var cmmWeightRecordEntityFull = new CmmWeightRecordEntityFull();
  1242. var dt = ServerHelper.GetData("com.steering.Mcms.MatOutServer.doQueryOutInfo", new object[] { carNo, comboCount.Text }, ob);
  1243. //if ((dt != null) && (dt.Rows.Count > 0) && ((dt.Rows[0]["STORAGE_NAME_D"].ToString2() == "天津钢管制造有限公司") || ((dt.Rows[0]["STORAGE_NAME_TO"].ToString2() == "天淮室外成品库" || dt.Rows[0]["STORAGE_NAME_TO"].ToString2() == "天淮室内成品库") && dt.Rows[0]["OUTSTOCK_PLAN_NO"].ToString2() == "1"))) // 调整 只有去天津 才带出出库记录 2021.3.15
  1244. if ((dt != null) && (dt.Rows.Count > 0))//天淮全部倒运都可显示
  1245. {
  1246. cmmWeightRecordEntityFull.ShippersName = dt.Rows[0]["STORAGE_NAME_D"].ToString2() == "天津钢管制造有限公司" ? "江苏天淮钢管有限公司" : dt.Rows[0]["STORAGE_NAME_FROM"].ToString2();
  1247. cmmWeightRecordEntityFull.LoadvehicleNo = dt.Rows[0]["OUTSTOCK_DOC"].ToString2();
  1248. cmmWeightRecordEntityFull.ReceiveName = dt.Rows[0]["STORAGE_NAME_TO"].ToString2();
  1249. cmmWeightRecordEntityFull.OrderName = dt.Rows[0]["STORAGE_NAME_D"].ToString2();
  1250. cmmWeightRecordEntityFull.RecordNumber =
  1251. dt.AsEnumerable().Select(p => decimal.Parse(p["ACT_COUNT"].ToString3())).Sum();
  1252. decimal.Parse(dt.Rows[0]["ACT_COUNT"].ToString3());
  1253. cmmWeightRecordEntityFull.MatName = dt.Rows[0]["STORAGE_NAME_D"].ToString2() == "天津钢管制造有限公司"
  1254. ? "调拨钢管"
  1255. : "内转钢管";
  1256. cmmWeightRecordEntityFull.MatInfos = new List<CmmWeightMatEntity>();
  1257. var totalWt = dt.AsEnumerable().Select(p => decimal.Parse(p["ACT_WEIGHT"].ToString3())).Sum();
  1258. var perWt = nutWt / totalWt;
  1259. var remainWt = nutWt;
  1260. for (var i = 0; i < dt.Rows.Count; i++)
  1261. {
  1262. var dtcRow = dt.Rows[i];
  1263. var cmmWeightMatEntity = new CmmWeightMatEntity
  1264. {
  1265. Produccode = dtcRow["PRODUCCODE"].ToString2(),
  1266. Producname = dtcRow["PRODUCNAME"].ToString2(),
  1267. Gradecode = dtcRow["GRADECODE"].ToString2(),
  1268. Gradename = dtcRow["GRADENAME"].ToString2(),
  1269. Steelcode = dtcRow["STEELCODE"].ToString2(),
  1270. Steelname = dtcRow["STEELNAME"].ToString2(),
  1271. ActLenTemp = dtcRow["ACT_LEN_MIN"].ToString3() + "-" +
  1272. dtcRow["ACT_LEN_MAX"].ToString3(),
  1273. ActWeight = i == dt.Rows.Count - 1 ? remainWt : Math.Round(decimal.Parse(dtcRow["ACT_WEIGHT"].ToString3()) * perWt, 3),
  1274. ActCount = decimal.Parse(dtcRow["ACT_COUNT"].ToString3()),
  1275. JudgeStoveNo = dtcRow["JUDGE_STOVE_NO"].ToString2(),
  1276. ActDimater = decimal.Parse(dtcRow["ACT_DIMATER"].ToString3()),
  1277. ActHeight = decimal.Parse(dtcRow["ACT_HEIGHT"].ToString3())
  1278. };
  1279. remainWt = remainWt - (decimal)cmmWeightMatEntity.ActWeight;
  1280. cmmWeightRecordEntityFull.MatInfos.Add(cmmWeightMatEntity);
  1281. }
  1282. matInfo12.SetDefault(cmmWeightRecordEntityFull);
  1283. }
  1284. else
  1285. {
  1286. if (nutWt > 0)
  1287. matInfo12.SetWt(nutWt);
  1288. }
  1289. }
  1290. public void ShowOutInfoGp(string carNo, decimal nutWt)
  1291. {
  1292. var cmmWeightRecordEntityFull = new CmmWeightRecordEntityFull();
  1293. var dt = ServerHelper.GetData("com.steering.Mcms.MatOutServer.doQueryOutInfoGp", new object[] { carNo }, ob);
  1294. if ((dt != null) && (dt.Rows.Count > 0))
  1295. {
  1296. cmmWeightRecordEntityFull.ShippersName = dt.Rows[0]["STORAGE_NAME_FROM"].ToString2();
  1297. cmmWeightRecordEntityFull.LoadvehicleNo = dt.Rows[0]["OUTSTOCK_DOC"].ToString2();
  1298. cmmWeightRecordEntityFull.ReceiveName = dt.Rows[0]["STORAGE_NAME_TO"].ToString2();
  1299. cmmWeightRecordEntityFull.RecordNumber =
  1300. dt.AsEnumerable().Select(p => decimal.Parse(p["ACT_COUNT"].ToString3())).Sum();
  1301. decimal.Parse(dt.Rows[0]["ACT_COUNT"].ToString3());
  1302. cmmWeightRecordEntityFull.MatName = "内转钢坯";
  1303. cmmWeightRecordEntityFull.MatInfos = new List<CmmWeightMatEntity>();
  1304. var perWt = Math.Round(nutWt / (decimal)cmmWeightRecordEntityFull.RecordNumber, 3);
  1305. var remainWt = nutWt;
  1306. for (var i = 0; i < dt.Rows.Count; i++)
  1307. {
  1308. var dtcRow = dt.Rows[i];
  1309. var cmmWeightMatEntity = new CmmWeightMatEntity
  1310. {
  1311. Steelcode = dtcRow["GRADECODE"].ToString2(),
  1312. Steelname = dtcRow["GRADENAME"].ToString2(),
  1313. ActLenTemp = dtcRow["ACT_LEN"].ToString3(),
  1314. ActWeight =
  1315. i == dt.Rows.Count - 1 ? remainWt : decimal.Parse(dtcRow["ACT_COUNT"].ToString3()) * perWt,
  1316. ActCount = decimal.Parse(dtcRow["ACT_COUNT"].ToString3()),
  1317. JudgeStoveNo = dtcRow["JUDGE_STOVE_NO"].ToString2(),
  1318. ActDimater = decimal.Parse(dtcRow["DIMATER"].ToString3()),
  1319. ActHeight = decimal.Parse(dtcRow["HEIGHT"].ToString3())
  1320. };
  1321. remainWt = remainWt - perWt;
  1322. cmmWeightRecordEntityFull.MatInfos.Add(cmmWeightMatEntity);
  1323. }
  1324. matInfo13.SetDefault(cmmWeightRecordEntityFull);
  1325. }
  1326. else
  1327. {
  1328. if (nutWt > 0)
  1329. matInfo13.SetWt(nutWt);
  1330. }
  1331. }
  1332. private void tbScondWt_SelectedTabChanged(object sender, SelectedTabChangedEventArgs e)
  1333. {
  1334. if (CurrentGrid.ActiveRow != null)
  1335. {
  1336. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  1337. if (current != null)
  1338. if (tbScondWt.ActiveTab.Key == "3")
  1339. ShowWasteInfo(current.CarNo);
  1340. else if (tbScondWt.ActiveTab.Key == "0")
  1341. ShowLoadvehicleInfo(current.CarNo);
  1342. }
  1343. LoadTem();
  1344. }
  1345. private void utnQuery_Click(object sender, EventArgs e)
  1346. {
  1347. Query2();
  1348. }
  1349. private void Query2()
  1350. {
  1351. try
  1352. {
  1353. var dic = new Dictionary<string, object>();
  1354. if (chkTim.Checked)
  1355. {
  1356. dic.Add("time", RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  1357. dic.Add("time1", RegEndTime.Value.ToString("yyy-MM-dd HH:mm:ss"));
  1358. }
  1359. dic.Add("carNo", uteCarNo.Text);
  1360. dic.Add("matType", uceQueryCarType.Text);
  1361. dic.Add("resultNo", utePound.Text);
  1362. dic.Add("orderName", uteOrder.Text);
  1363. dic.Add("shippersName", uteShippersName.Text);
  1364. dic.Add("receiveName", uteReceiveName.Text);
  1365. dic.Add("memo", uteMemo.Text);
  1366. dic.Add("validflag", new List<string> { "1" });
  1367. dic.Add("judgeStoveNo", uteJudgeStoveNo.Text);
  1368. List<CmmWeightResultEntity> list = EntityHelper.GetData<CmmWeightResultEntity>(
  1369. "com.steering.Mcms.ResultServer.doQuery",
  1370. new object[] { dic },
  1371. ob);
  1372. lblCount.Text = string.Format("共{0}条记录", list.Count);
  1373. QueryBS.DataSource = list;
  1374. Comm.RefreshAndAutoSize(ugData);
  1375. }
  1376. catch
  1377. { }
  1378. }
  1379. private void tbMain_SelectedTabChanged(object sender, SelectedTabChangedEventArgs e)
  1380. {
  1381. if (tbMain.SelectedTab.Key == "1")
  1382. Query();
  1383. else
  1384. Query2();
  1385. }
  1386. private void utbReset_Click(object sender, EventArgs e)
  1387. {
  1388. RegStartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 07:00:00"));
  1389. RegEndTime.Value = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 07:00:00"));
  1390. uteCarNo.Text = "";
  1391. uceQueryCarType.Text = "";
  1392. utePound.Text = "";
  1393. uteOrder.Text = "";
  1394. uteShippersName.Text = "";
  1395. uteReceiveName.Text = "";
  1396. uteMemo.Text = "";
  1397. uteJudgeStoveNo.Text = "";
  1398. }
  1399. private void btnDelete_Click(object sender, EventArgs e)
  1400. {
  1401. if (ugData.ActiveRow == null) return;
  1402. var ub = sender as UltraButton;
  1403. if (ub == null) return;
  1404. var data = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
  1405. if (data == null) return;
  1406. ("是否" + ub.Text + " 车辆 " + data.CarNo + " 的过磅单?").Speak();
  1407. if (MessageUtil.ShowYesNoAndQuestion("是否" + ub.Text + " 车牌[" + data.CarNo + "]过磅单?") == DialogResult.No)
  1408. return;
  1409. var ccp = new CoreClientParam
  1410. {
  1411. ServerName = "com.steering.Mcms.LocalTruckScale",
  1412. MethodName = "DoDeleteResult",
  1413. ServerParams = new object[]
  1414. {
  1415. data.ResultNo,
  1416. UserInfo.GetUserName(),
  1417. "重过" == ub.Text ? "2" : "1",
  1418. }
  1419. };
  1420. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1421. if (ccp.ReturnCode != -1)
  1422. {
  1423. MessageUtil.ShowTips(ccp.ReturnInfo);
  1424. if (ccp.ReturnInfo.Equals("操作成功!"))
  1425. {
  1426. Query2();
  1427. Query();
  1428. }
  1429. }
  1430. }
  1431. private void lvTemplate_ItemDoubleClick(object sender, ItemDoubleClickEventArgs e)
  1432. {
  1433. var matInfo = GetMatInfo();
  1434. if ((matInfo != null) && matInfo.AddNew) matInfo.SetDefault(e.Item.Tag as CmmWeightRecordEntityFull, e.Item.Text);
  1435. }
  1436. private void cboPoundList_SelectedValueChanged(object sender, EventArgs e)
  1437. {
  1438. Query();
  1439. }
  1440. private void delete_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1441. {
  1442. if (cmmPoundBase == null)
  1443. {
  1444. MessageBox.Show(@"无磅房权限");
  1445. return;
  1446. }
  1447. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  1448. if ((current == null) || ("" == current.CarNo)) return;
  1449. if (MessageUtil.ShowYesNoAndQuestion("是否删除" + current.CarNo + " 过磅记录?") == DialogResult.No)
  1450. return;
  1451. var ccp = new CoreClientParam
  1452. {
  1453. ServerName = "com.steering.Mcms.RecordServer",
  1454. MethodName = "DoUpdateRecord",
  1455. ServerParams = new object[]
  1456. {
  1457. current.RecordNo
  1458. }
  1459. };
  1460. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1461. if (ccp.ReturnCode != -1)
  1462. if (ccp.ReturnInfo.ToString2().Contains("操作成功"))
  1463. Query();
  1464. else
  1465. MessageUtil.ShowTips(ccp.ReturnInfo);
  1466. }
  1467. private void ugData_InitializeRow(object sender, InitializeRowEventArgs e)
  1468. {
  1469. var data = e.Row.ListObject as CmmWeightResultEntity;
  1470. if (data == null) return;
  1471. if (data.RecordType2 == "201") e.Row.Appearance.BackColor = Color.ForestGreen;
  1472. }
  1473. private void uteCarNo_KeyPress(object sender, KeyPressEventArgs e)
  1474. {
  1475. if (e.KeyChar == 13)
  1476. Query2();
  1477. }
  1478. private void utnUpdate_Click(object sender, EventArgs e)
  1479. {
  1480. if (ugData.ActiveRow == null)
  1481. {
  1482. MessageBox.Show("请选择需要修改磅单记录!");
  1483. return;
  1484. }
  1485. var cmm = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
  1486. var matInfo = GetMatInfoByKey("101" == cmm.RecordType1 ? cmm.RecordType2 : cmm.RecordType1);
  1487. if (matInfo == null)
  1488. {
  1489. MessageBox.Show("该类型不允许修改!");
  1490. return;
  1491. }
  1492. var recordNo = "101" == cmm.RecordType1 ? cmm.RecordNo2 : cmm.RecordNo1;
  1493. if ("207" == cmm.RecordType2 && (cmm.MatType == "钢坯采购"|| cmm.MatType == "钢坯退货" ||
  1494. cmm.MatType == "钢管退货" || cmm.MatType == "采购辅料" || cmm.MatType == "修复返厂" ||
  1495. cmm.MatType == "设备采购" || cmm.MatType == "其他内转" || cmm.MatType == "内转钢管"
  1496. || cmm.MatType == "外购钢管"))
  1497. {
  1498. recordNo = cmm.RecordNo2;
  1499. }
  1500. using (var frmUpdate = new FrmUpdate(ob, cmm, recordNo, canUpdateWt)
  1501. {
  1502. ColumnsM = matInfo.ColumnsM,
  1503. ColumnsC = matInfo.ColumnsC
  1504. })
  1505. {
  1506. frmUpdate.ShowDialog();
  1507. if (frmUpdate.DialogResult == DialogResult.OK)
  1508. Query2();
  1509. }
  1510. }
  1511. private void utbPrint_Click(object sender, EventArgs e)
  1512. {
  1513. if (ugData.ActiveRow == null) return;
  1514. var data = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
  1515. if (data == null) return;
  1516. if ((data.RecordType2 == "201") && (data.GrossWt != null) && (data.GrossWt > 50) && (MessageUtil.ShowYesNoAndQuestion("毛重超过50吨, 是否继续打印磅单?") ==
  1517. DialogResult.No))
  1518. {
  1519. }
  1520. else
  1521. {
  1522. Print(data.ResultNo);
  1523. }
  1524. }
  1525. private void utbPrintSingle_Click(object sender, EventArgs e)
  1526. {
  1527. if (ugData.ActiveRow == null) return;
  1528. var data = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
  1529. if (data == null) return;
  1530. if ((data.RecordType2 == "205") || (data.RecordType2 == "201") || (data.RecordType2 == "200"))
  1531. if ((data.RecordType2 == "201") && (data.GrossWt != null) && (data.GrossWt > 50) && (MessageUtil.ShowYesNoAndQuestion("毛重超过50吨, 是否继续打印磅单?") ==
  1532. DialogResult.No))
  1533. {
  1534. }
  1535. else
  1536. {
  1537. Print(data.ResultNo, true);
  1538. }
  1539. }
  1540. private void unExcel_Click(object sender, EventArgs e)
  1541. {
  1542. var hssfworkbook = new HSSFWorkbook();
  1543. var sheet = hssfworkbook.CreateSheet("磅房统计");
  1544. var index = 0;
  1545. SetHead(sheet, hssfworkbook, index++);
  1546. SetHeadRow(sheet, hssfworkbook
  1547. , new List<string> { "磅房号", "称重类型", "物资名称", "物资数量", "称重次数", "物资净重" },
  1548. new List<int> { 9, 15, 25, 15, 15, 15 },
  1549. index++
  1550. );
  1551. setData(sheet, hssfworkbook, ref index);
  1552. SetSumm(sheet, index, hssfworkbook);
  1553. sheet.ForceFormulaRecalculation = true;
  1554. hssfworkbook.GetCreationHelper().CreateFormulaEvaluator().EvaluateAll();
  1555. using (var saveFileDialog1 = new SaveFileDialog())
  1556. {
  1557. saveFileDialog1.FileName = "磅房统计" + DateTime.Now.ToString("yyMMdd");
  1558. saveFileDialog1.Filter = "Excel文件(*.xls)|*.xls";
  1559. if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  1560. {
  1561. var sFullName = saveFileDialog1.FileName;
  1562. var ms = new MemoryStream();
  1563. hssfworkbook.Write(ms);
  1564. using (var fs = new FileStream(saveFileDialog1.FileName, FileMode.Create, FileAccess.Write))
  1565. {
  1566. var bArr = ms.ToArray();
  1567. fs.Write(bArr, 0, bArr.Length);
  1568. fs.Flush();
  1569. }
  1570. var p = new ProcessStartInfo(sFullName);
  1571. p.WorkingDirectory = Path.GetDirectoryName(sFullName);
  1572. Process.Start(p);
  1573. }
  1574. }
  1575. }
  1576. private void SetSumm(ISheet sheet, int index, HSSFWorkbook hssfworkbook)
  1577. {
  1578. var IRow = sheet.CreateRow(index);
  1579. IRow.Height = 20 * 20;
  1580. var Icell1 = IRow.CreateCell(1);
  1581. Icell1.SetCellValue("合计");
  1582. var style = CenterStyle(hssfworkbook);
  1583. var font = ContextFont(hssfworkbook);
  1584. style.SetFont(font);
  1585. style.BorderTop = BorderStyle.Medium;
  1586. style.BorderBottom = BorderStyle.Medium;
  1587. style.BorderLeft = BorderStyle.Medium;
  1588. style.BorderRight = BorderStyle.Thin;
  1589. //将新的样式赋给单元格
  1590. Icell1.CellStyle = style;
  1591. var Icell12 = IRow.CreateCell(2);
  1592. var style12 = CenterStyle(hssfworkbook);
  1593. style12.SetFont(font);
  1594. style12.BorderTop = BorderStyle.Medium;
  1595. style12.BorderBottom = BorderStyle.Medium;
  1596. style12.BorderLeft = BorderStyle.Thin;
  1597. style12.BorderRight = BorderStyle.Thin;
  1598. //将新的样式赋给单元格
  1599. Icell12.CellStyle = style12;
  1600. var Icell13 = IRow.CreateCell(3);
  1601. var style13 = CenterStyle(hssfworkbook);
  1602. style13.SetFont(font);
  1603. style13.BorderTop = BorderStyle.Medium;
  1604. style13.BorderBottom = BorderStyle.Medium;
  1605. style13.BorderLeft = BorderStyle.Thin;
  1606. style13.BorderRight = BorderStyle.Thin;
  1607. //将新的样式赋给单元格
  1608. Icell13.CellStyle = style13;
  1609. //合并单元格
  1610. sheet.AddMergedRegion(new CellRangeAddress(index, index, 1, 3));
  1611. var list = new List<string>();
  1612. for (var i = 2; i < index; i++)
  1613. list.Add(i + 1 + "");
  1614. var Icell2 = IRow.CreateCell(4);
  1615. if (list.Any())
  1616. {
  1617. //Icell2.SetCellType(CellType.Formula);
  1618. //Icell2.SetCellFormula(string.Format("SUM({0})", string.Join(",", list.Select(p => "E" + p).ToList())));
  1619. //hssfworkbook.GetCreationHelper().CreateFormulaEvaluator().EvaluateFormulaCell(Icell2);
  1620. Icell2.SetCellType(CellType.Formula);
  1621. Icell2.SetCellFormula(string.Format("SUM({0})", "E"+list[0]+":E"+list[list.Count-1]));
  1622. hssfworkbook.GetCreationHelper().CreateFormulaEvaluator().EvaluateFormulaCell(Icell2);
  1623. }
  1624. var style2 = numStyle(hssfworkbook);
  1625. var font2 = ContextFont(hssfworkbook);
  1626. style2.SetFont(font2);
  1627. style2.BorderTop = BorderStyle.Medium;
  1628. style2.BorderBottom = BorderStyle.Medium;
  1629. style2.BorderLeft = BorderStyle.Thin;
  1630. style2.BorderRight = BorderStyle.Thin;
  1631. //将新的样式赋给单元格
  1632. Icell2.CellStyle = style2;
  1633. var Icell3 = IRow.CreateCell(5);
  1634. if (list.Any())
  1635. {
  1636. Icell3.SetCellType(CellType.Formula);
  1637. // Icell3.SetCellFormula(string.Format("SUM({0})", string.Join(",", list.Select(p => "F" + p).ToList())));
  1638. Icell3.SetCellFormula(string.Format("SUM({0})", "F" + list[0] + ":F" + list[list.Count - 1]));
  1639. hssfworkbook.GetCreationHelper().CreateFormulaEvaluator().EvaluateFormulaCell(Icell3);
  1640. }
  1641. var style3 = numStyle(hssfworkbook);
  1642. var font3 = ContextFont(hssfworkbook);
  1643. style3.SetFont(font3);
  1644. style3.BorderTop = BorderStyle.Medium;
  1645. style3.BorderBottom = BorderStyle.Medium;
  1646. style3.BorderLeft = BorderStyle.Thin;
  1647. style3.BorderRight = BorderStyle.Thin;
  1648. //将新的样式赋给单元格
  1649. Icell3.CellStyle = style3;
  1650. var Icell4 = IRow.CreateCell(6);
  1651. if (list.Any())
  1652. {
  1653. Icell4.SetCellType(CellType.Formula);
  1654. // Icell4.SetCellFormula(string.Format("SUM({0})", string.Join(",", list.Select(p => "G" + p).ToList())));
  1655. Icell4.SetCellFormula(string.Format("SUM({0})", "G" + list[0] + ":G" + list[list.Count - 1]));
  1656. hssfworkbook.GetCreationHelper().CreateFormulaEvaluator().EvaluateFormulaCell(Icell4);
  1657. }
  1658. var style4 = numStyle(hssfworkbook);
  1659. var font4 = ContextFont(hssfworkbook);
  1660. style4.SetFont(font4);
  1661. style4.BorderTop = BorderStyle.Medium;
  1662. style4.BorderBottom = BorderStyle.Medium;
  1663. style4.BorderLeft = BorderStyle.Thin;
  1664. style4.BorderRight = BorderStyle.Medium;
  1665. //将新的样式赋给单元格
  1666. Icell4.CellStyle = style4;
  1667. }
  1668. private void setData(ISheet sheet, HSSFWorkbook hssfworkbook, ref int index)
  1669. {
  1670. var index1 = index;
  1671. var data = QueryBS.DataSource as List<CmmWeightResultEntity>;
  1672. if ((data != null) && data.Any())
  1673. data.GroupBy(p => new { p.RecoderLocation2, p.MatName, p.MatType })
  1674. .Select(p => new
  1675. {
  1676. p.Key.MatName,
  1677. p.Key.MatType,
  1678. p.Key.RecoderLocation2,
  1679. count = p.Count(),
  1680. num = int.Parse(p.Select(q => q.MatNum ?? 0).Sum().ToString3()),
  1681. wt = double.Parse(p.Select(q => q.NetWt).Sum().ToString3())
  1682. }).ToList()
  1683. .ForEach(
  1684. p =>
  1685. {
  1686. var IRow = sheet.CreateRow(index1++);
  1687. IRow.Height = 20 * 20;
  1688. for (var i = 0; i < 6; i++)
  1689. {
  1690. var Icell = IRow.CreateCell(i + 1);
  1691. if (i <= 2)
  1692. {
  1693. Icell.SetCellType(CellType.String);
  1694. Icell.SetCellValue(
  1695. i == 0
  1696. ? p.RecoderLocation2
  1697. : i == 1
  1698. ? p.MatType
  1699. : p.MatName);
  1700. }
  1701. else
  1702. {
  1703. Icell.SetCellType(CellType.Numeric);
  1704. if (i == 3)
  1705. Icell.SetCellValue(p.num);
  1706. if (i == 4)
  1707. Icell.SetCellValue(p.count);
  1708. if (i == 5)
  1709. Icell.SetCellValue(p.wt);
  1710. }
  1711. ;
  1712. var style = i <= 2 ? textStyle(hssfworkbook) : numStyle(hssfworkbook);
  1713. style.BorderTop = BorderStyle.Thin;
  1714. style.BorderBottom = BorderStyle.Thin;
  1715. style.BorderLeft = i == 0 ? BorderStyle.Medium : BorderStyle.Thin;
  1716. style.BorderRight = i == 5 ? BorderStyle.Medium : BorderStyle.Thin;
  1717. var font = ContextFont(hssfworkbook);
  1718. //使用SetFont方法将字体样式添加到单元格样式中
  1719. style.SetFont(font);
  1720. //将新的样式赋给单元格
  1721. Icell.CellStyle = style;
  1722. }
  1723. }
  1724. );
  1725. index = index1;
  1726. }
  1727. private void SetHeadRow(ISheet sheet, HSSFWorkbook hssfworkbook, List<string> name, List<int> columsWidth,
  1728. int rowIndex)
  1729. {
  1730. var IRow = sheet.CreateRow(rowIndex);
  1731. IRow.Height = 20 * 20;
  1732. for (var i = 0; i < name.Count; i++)
  1733. {
  1734. sheet.SetColumnWidth(i + 1, columsWidth[i] * 256);
  1735. var Icell = IRow.CreateCell(i + 1);
  1736. Icell.SetCellValue(name[i]);
  1737. var style = CenterStyle(hssfworkbook);
  1738. style.BorderTop = BorderStyle.Medium;
  1739. style.BorderBottom = BorderStyle.Medium;
  1740. style.BorderLeft = BorderStyle.Medium;
  1741. style.BorderRight = BorderStyle.Medium;
  1742. var font = ContextFont(hssfworkbook);
  1743. //使用SetFont方法将字体样式添加到单元格样式中
  1744. style.SetFont(font);
  1745. //将新的样式赋给单元格
  1746. Icell.CellStyle = style;
  1747. }
  1748. }
  1749. private void SetHead(ISheet sheet, HSSFWorkbook hssfworkbook, int rowindex)
  1750. {
  1751. var IRow = sheet.CreateRow(rowindex);
  1752. IRow.Height = 50 * 20;
  1753. var Icell = IRow.CreateCell(1);
  1754. Icell.SetCellValue("磅房统计");
  1755. var style = CenterStyle(hssfworkbook);
  1756. var font = TitleFont(hssfworkbook);
  1757. //使用SetFont方法将字体样式添加到单元格样式中
  1758. style.SetFont(font);
  1759. //将新的样式赋给单元格
  1760. Icell.CellStyle = style;
  1761. //合并单元格
  1762. sheet.AddMergedRegion(new CellRangeAddress(0, 0, 1, 6));
  1763. }
  1764. private static IFont TitleFont(HSSFWorkbook hssfworkbook)
  1765. {
  1766. //新建一个字体样式对象
  1767. var font = hssfworkbook.CreateFont();
  1768. font.FontName = "宋体";
  1769. font.FontHeightInPoints = 30;
  1770. //设置字体加粗样式
  1771. font.Boldweight = (short)FontBoldWeight.Bold;
  1772. return font;
  1773. }
  1774. private static IFont ContextFont(HSSFWorkbook hssfworkbook)
  1775. {
  1776. //新建一个字体样式对象
  1777. var font = hssfworkbook.CreateFont();
  1778. font.FontName = "宋体";
  1779. font.FontHeightInPoints = 12;
  1780. //设置字体加粗样式
  1781. font.Boldweight = (short)FontBoldWeight.Bold;
  1782. return font;
  1783. }
  1784. private ICellStyle CenterStyle(HSSFWorkbook hssfworkbook)
  1785. {
  1786. var style = hssfworkbook.CreateCellStyle();
  1787. //设置单元格的样式:水平对齐居中
  1788. style.Alignment = HorizontalAlignment.Center;
  1789. style.VerticalAlignment = VerticalAlignment.Center;
  1790. return style;
  1791. }
  1792. private ICellStyle textStyle(HSSFWorkbook hssfworkbook)
  1793. {
  1794. var style = hssfworkbook.CreateCellStyle();
  1795. //设置单元格的样式:水平对齐居中
  1796. style.Alignment = HorizontalAlignment.Left;
  1797. style.VerticalAlignment = VerticalAlignment.Center;
  1798. return style;
  1799. }
  1800. private ICellStyle numStyle(HSSFWorkbook hssfworkbook)
  1801. {
  1802. var style = hssfworkbook.CreateCellStyle();
  1803. //设置单元格的样式:水平对齐居中
  1804. style.Alignment = HorizontalAlignment.Right;
  1805. style.VerticalAlignment = VerticalAlignment.Center;
  1806. return style;
  1807. }
  1808. private void CurrentGrid_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  1809. {
  1810. }
  1811. private void CurrentGrid_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
  1812. {
  1813. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  1814. if ((current == null) || ("" == current.CarNo)) return;
  1815. foreach (var cbxCar1Item in cbxCar1.Items)
  1816. if (current.CarNo.StartsWith(cbxCar1Item.ToString2().Trim()))
  1817. {
  1818. cbxCar1.SelectedItem = cbxCar1Item;
  1819. txtCar2.Text = current.CarNo.Replace(cbxCar1Item.ToString2().Trim(), "").Trim();
  1820. }
  1821. if (!tbWt.Tabs["2"].Selected)
  1822. {
  1823. tbWt.Tabs["2"].Selected = true;
  1824. if (current.RecordType != "101")
  1825. tbScondWt.Tabs["2"].Selected = true;
  1826. else
  1827. tbScondWt_SelectedTabChanged(null, null);
  1828. }
  1829. }
  1830. private void utbExport_Click(object sender, EventArgs e)
  1831. {
  1832. GridHelper.ulGridToExcel(ugData, "称重记录");
  1833. }
  1834. private void utbExport2_Click(object sender, EventArgs e)
  1835. {
  1836. GridHelper.ulGridToExcel(CurrentGrid, "称重记录");
  1837. }
  1838. private void cbxCar1_SelectedValueChanged(object sender, EventArgs e)
  1839. {
  1840. txtCar2.Focus();
  1841. if (cbxCar1.Text.Trim() == "厂内")
  1842. txtCar2.Text = "自用车";
  1843. }
  1844. private void splitContainer2_SplitterMoved(object sender, SplitterEventArgs e)
  1845. {
  1846. if (isLoading) return;
  1847. XmlHelper.SetXmlData(_path, "splitContainer2", splitContainer2.SplitterDistance);
  1848. }
  1849. private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
  1850. {
  1851. if (isLoading) return;
  1852. XmlHelper.SetXmlData(_path, "splitContainer1", splitContainer1.SplitterDistance);
  1853. }
  1854. private void frmLocalTruckScale_Shown(object sender, EventArgs e)
  1855. {
  1856. // timer.Start();
  1857. splitContainer1.SplitterDistance = XmlHelper.GetXmlData(_path, "splitContainer1",
  1858. splitContainer1.SplitterDistance);
  1859. splitContainer2.SplitterDistance = XmlHelper.GetXmlData(_path, "splitContainer2",
  1860. splitContainer2.SplitterDistance);
  1861. var x = new FontConverter();
  1862. CurrentGrid.Font =
  1863. x.ConvertFromString(XmlHelper.GetXmlData(_path, CurrentGrid.Name, x.ConvertToString(CurrentGrid.Font)))
  1864. as Font;
  1865. ugData.Font =
  1866. x.ConvertFromString(XmlHelper.GetXmlData(_path, ugData.Name, x.ConvertToString(ugData.Font))) as Font;
  1867. isLoading = false;
  1868. CurrentGrid.DisplayLayout.Bands[0].Columns["RecordType"].EditorComponent = uceType2;
  1869. CurrentGrid.DisplayLayout.Bands[0].Columns["RecordNo"].EditorComponent = delete;
  1870. CurrentGrid.DisplayLayout.Bands[0].Columns["CarNo"].EditorComponent = uteEdit;
  1871. Query();
  1872. Query2();
  1873. try
  1874. {
  1875. if (toolMenu == null) return;
  1876. if (toolMenu.Toolbars[0].Tools.Exists("UpdateWt"))
  1877. canUpdateWt = true;
  1878. toolMenu.Visible = false;
  1879. }
  1880. catch (Exception ex)
  1881. {
  1882. }
  1883. }
  1884. private void CurrentGrid_KeyDown(object sender, KeyEventArgs e)
  1885. {
  1886. if (e.KeyCode == Keys.F5)
  1887. using (var dr = new FontDialog { Font = (sender as Control).Font })
  1888. {
  1889. if (dr.ShowDialog() == DialogResult.OK)
  1890. {
  1891. (sender as Control).Font = dr.Font;
  1892. var x = new FontConverter();
  1893. var font = x.ConvertToString(dr.Font);
  1894. // t = x.ConvertFromString(s) as Font;
  1895. XmlHelper.SetXmlData(_path, (sender as Control).Name, font);
  1896. }
  1897. }
  1898. }
  1899. private void txtCar2_TextChanged(object sender, EventArgs e)
  1900. {
  1901. foreach (var currentGridRow in CurrentGrid.Rows)
  1902. if (currentGridRow.Cells["CarNo"].Value.ToString2() == cbxCar1.Text + txtCar2.Text.Trim())
  1903. if (!tbWt.Tabs["2"].Selected)
  1904. {
  1905. tbWt.Tabs["2"].Selected = true;
  1906. currentGridRow.Activated = true;
  1907. if (currentGridRow.Cells["RecordType"].Value.ToString2() != "101")
  1908. tbScondWt.Tabs["2"].Selected = true;
  1909. else
  1910. tbScondWt_SelectedTabChanged(null, null);
  1911. return;
  1912. }
  1913. tbWt.Tabs["1"].Selected = true;
  1914. }
  1915. private void uteEdit_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1916. {
  1917. if (cmmPoundBase == null)
  1918. {
  1919. MessageBox.Show(@"无磅房权限");
  1920. return;
  1921. }
  1922. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  1923. string carNo;
  1924. using (var update = new UpdateCar { CarNo = current.CarNo })
  1925. {
  1926. var result = update.ShowDialog();
  1927. if (result != DialogResult.OK) return;
  1928. carNo = update.CarNo;
  1929. }
  1930. var ccp = new CoreClientParam
  1931. {
  1932. ServerName = "com.steering.Mcms.RecordServer",
  1933. MethodName = "DoUpdateCarNo",
  1934. ServerParams = new object[]
  1935. {
  1936. current.RecordNo,
  1937. carNo
  1938. }
  1939. };
  1940. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1941. if (ccp.ReturnCode != -1)
  1942. {
  1943. MessageUtil.ShowTips(ccp.ReturnInfo);
  1944. if (ccp.ReturnInfo.ToString2().Contains("操作成功"))
  1945. Query();
  1946. }
  1947. }
  1948. public bool CheckShowKey(string key1, string key2)
  1949. {
  1950. if (key1 == key2) return true;
  1951. if (((key1 == "107") && (key2 == "204")) || ((key2 == "107") && (key1 == "204"))) return true;
  1952. if (((key1 == "108") && (key2 == "205")) || ((key2 == "108") && (key1 == "205"))) return true;
  1953. if (((key1 == "206") && (key2 == "206")) || ((key2 == "109") && (key1 == "206"))) return true;
  1954. return false;
  1955. }
  1956. private void txtCar2_KeyPress(object sender, KeyPressEventArgs e)
  1957. {
  1958. if ((e.KeyChar >= 97) && (e.KeyChar <= 122))
  1959. e.KeyChar = (char)(e.KeyChar - 32);
  1960. }
  1961. private void CurrentGrid_InitializeRow(object sender, InitializeRowEventArgs e)
  1962. {
  1963. var cmmWeightRecord = e.Row.ListObject as CmmWeightRecordEntity;
  1964. if (cmmWeightRecord == null) return;
  1965. if ((cmmWeightRecord.EffRemaind != null) && (cmmWeightRecord.EffRemaind <= 1))
  1966. e.Row.Cells["RecordDate"].Appearance.BackColor = Color.Red;
  1967. }
  1968. private void utbSelect_Click(object sender, EventArgs e)
  1969. {
  1970. using (var BlankPredictionSelect = new BlankPredictionSelect(ob, matInfo3.GetData()))
  1971. {
  1972. if (BlankPredictionSelect.ShowDialog() == DialogResult.OK)
  1973. matInfo3.UpdateData(new CmmWeightRecordEntityFull
  1974. {
  1975. MatName = "连铸圆坯",
  1976. ShippersName = BlankPredictionSelect.ShipperName,
  1977. RecordNumber = BlankPredictionSelect.ListMatNo == null ? null : BlankPredictionSelect.ListMatNo.Sum(p => p.ActCount),
  1978. ReceiveName = "江苏天淮钢管有限公司",
  1979. Memo = BlankPredictionSelect.Memo,
  1980. MatInfos =
  1981. BlankPredictionSelect.ListMatNo ?? new List<CmmWeightMatEntity> { new CmmWeightMatEntity() }
  1982. });
  1983. }
  1984. }
  1985. private void uteChangeType_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1986. {
  1987. if (cmmPoundBase == null)
  1988. {
  1989. MessageBox.Show(@"无磅房权限");
  1990. return;
  1991. }
  1992. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  1993. string type;
  1994. string name;
  1995. using (var changeType = new ChangeType { Type = current.RecordType })
  1996. {
  1997. var result = changeType.ShowDialog();
  1998. if (result != DialogResult.OK) return;
  1999. type = changeType.Type;
  2000. name = changeType.TypeName;
  2001. }
  2002. var ccp = new CoreClientParam
  2003. {
  2004. ServerName = "com.steering.Mcms.RecordServer",
  2005. MethodName = "DoUpdateType",
  2006. ServerParams = new object[]
  2007. {
  2008. current.RecordNo,
  2009. type,
  2010. name
  2011. }
  2012. };
  2013. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  2014. if (ccp.ReturnCode != -1)
  2015. {
  2016. MessageUtil.ShowTips(ccp.ReturnInfo);
  2017. if (ccp.ReturnInfo.ToString2().Contains("成功"))
  2018. Query();
  2019. }
  2020. }
  2021. private void ugData_AfterRowRegionScroll(object sender, RowScrollRegionEventArgs e)
  2022. {
  2023. var dex = e.RowScrollRegion.FirstRow;
  2024. dex.Activate();
  2025. }
  2026. private void CurrentGrid_AfterRowRegionScroll(object sender, RowScrollRegionEventArgs e)
  2027. {
  2028. /* UltraGridRow dex = e.RowScrollRegion.FirstRow;
  2029. dex.Activate();*/
  2030. }
  2031. private void ugData_AfterRowActivate(object sender, EventArgs e)
  2032. {
  2033. ugData.ActiveRow.RowSelectorAppearance.BackColor = Color.LightGreen;
  2034. }
  2035. private void ugData_BeforeRowDeactivate(object sender, CancelEventArgs e)
  2036. {
  2037. ugData.ActiveRow.RowSelectorAppearance.ResetBackColor();
  2038. }
  2039. private void CurrentGrid_BeforeRowDeactivate(object sender, CancelEventArgs e)
  2040. {
  2041. CurrentGrid.ActiveRow.RowSelectorAppearance.ResetBackColor();
  2042. }
  2043. private void utbSelect2_Click(object sender, EventArgs e)
  2044. {
  2045. var carNo = cbxCar1.Text + txtCar2.Text.ToUpper().Trim();
  2046. var cmmWeightRecordEntityFull = new CmmWeightRecordEntityFull();
  2047. var dt = ServerHelper.GetData("com.steering.Mcms.MatOutServer.doQueryOutInfoGp", new object[] { carNo }, ob);
  2048. if ((dt != null) && (dt.Rows.Count > 0) && (dt.Rows[0]["STORAGE_NAME_D"].ToString2() == "天津钢管制造有限公司"))
  2049. {
  2050. cmmWeightRecordEntityFull.ShippersName = "天津钢管制造有限公司";
  2051. cmmWeightRecordEntityFull.LoadvehicleNo = dt.Rows[0]["OUTSTOCK_DOC"].ToString2();
  2052. cmmWeightRecordEntityFull.ReceiveName = "江苏天淮钢管有限公司";
  2053. cmmWeightRecordEntityFull.RecordNumber =
  2054. dt.AsEnumerable().Select(p => decimal.Parse(p["ACT_COUNT"].ToString3())).Sum();
  2055. decimal.Parse(dt.Rows[0]["ACT_COUNT"].ToString3());
  2056. cmmWeightRecordEntityFull.MatName = "连铸圆坯";
  2057. cmmWeightRecordEntityFull.MatInfos = new List<CmmWeightMatEntity>();
  2058. for (var i = 0; i < dt.Rows.Count; i++)
  2059. {
  2060. var dtcRow = dt.Rows[i];
  2061. var cmmWeightMatEntity = new CmmWeightMatEntity
  2062. {
  2063. JudgeStoveNoOld = dtcRow["STOVE_NO"].ToString2(),
  2064. JudgeStoveNo = dtcRow["JUDGE_STOVE_NO"].ToString2(),
  2065. ActDimater = decimal.Parse(dtcRow["DIMATER"].ToString3()),
  2066. ActLenTemp = dtcRow["ACT_LEN"].ToString3(),
  2067. ActCount = decimal.Parse(dtcRow["ACT_COUNT"].ToString3()),
  2068. DocumentNo = dtcRow["OUTSTOCK_DOC"].ToString2(),
  2069. ProOrderNo = dtcRow["ORDER_NO"].ToString2(),
  2070. OrderNo = dtcRow["ORDER_NO"].ToString2(),
  2071. OrderSeq = dtcRow["ORDER_SEQ"].ToString2(),
  2072. OrdNoPk = dtcRow["ORD_PK"].ToString2(),
  2073. Produccode = dtcRow["PRODUCCODE"].ToString2(),
  2074. Producname = dtcRow["PRODUCNAME"].ToString2(),
  2075. Gradecode = dtcRow["GRADECODE"].ToString2(),
  2076. Gradename = dtcRow["GRADENAME"].ToString2(),
  2077. Steelcode = dtcRow["GRADECODE"].ToString2(),
  2078. Steelname = dtcRow["GRADENAME"].ToString2()
  2079. };
  2080. cmmWeightRecordEntityFull.MatInfos.Add(cmmWeightMatEntity);
  2081. }
  2082. matInfo3.SetDefault(cmmWeightRecordEntityFull);
  2083. }
  2084. else
  2085. {
  2086. MessageBox.Show("未找到该车的出库记录!");
  2087. }
  2088. }
  2089. //TODO
  2090. /// <summary>
  2091. /// 必须先打开连接
  2092. /// </summary>
  2093. private bool GetIPVideo(CmmBaseSpotInfoEntity video)
  2094. {
  2095. try
  2096. {
  2097. DhCameraShot tt = new DhCameraShot();
  2098. CarCache.cameraShots = tt;
  2099. CarCache.cameraShots.ip = video.VideoIp;
  2100. CarCache.cameraShots.port = video.VideoPort;
  2101. CarCache.cameraShots.uid = video.VideoUserName;
  2102. CarCache.cameraShots.pwd = video.VideoPassword;
  2103. CarCache.cameraShots.Connection();
  2104. }
  2105. catch (Exception ex)
  2106. {
  2107. // setMsgInfo(txtMsgInfo, "视频连接打开失败:" + ex.Message, "");
  2108. //MessageBox.Show(ex.Message);
  2109. return false;
  2110. }
  2111. return true;
  2112. }
  2113. //如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable
  2114. public void setMsgInfo(Control control, string ResultMessage, string sType)
  2115. {
  2116. setMsgMsg(control, ResultMessage, sType);
  2117. }
  2118. /// <summary>
  2119. /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable 3为check
  2120. /// </summary>
  2121. /// <param name="control"></param>
  2122. /// <param name="ResultMessage"></param>
  2123. /// <param name="sType"></param>
  2124. private void setMsgMsg(Control control, string ResultMessage, string sType)
  2125. {
  2126. if (control.InvokeRequired)
  2127. {
  2128. Action<Control, string, string> action = new Action<Control, string, string>(setMsgInfo);
  2129. Invoke(action, new object[] { control, ResultMessage, sType });
  2130. }
  2131. else
  2132. {
  2133. if (ResultMessage != "true" && ResultMessage != "false")
  2134. {
  2135. control.Text = ResultMessage == null ? "" : ResultMessage.Replace("请远程求助", "").Replace(",请点击语音求助", "");
  2136. }
  2137. else
  2138. {
  2139. switch (sType)
  2140. {
  2141. case "1":
  2142. control.Enabled = ResultMessage == "true" ? true : false;
  2143. ; break;
  2144. case "2":
  2145. control.Visible = ResultMessage == "true" ? true : false;
  2146. ; break;
  2147. case "3":
  2148. ((CheckBox)control).Checked = ResultMessage == "true" ? true : false;
  2149. break;
  2150. default: break;
  2151. }
  2152. }
  2153. }
  2154. }
  2155. //private bool bVoice = false;
  2156. /// <summary>
  2157. /// 必须先打开视频,然后再打开语音
  2158. /// </summary>
  2159. private void VoiceOpen()
  2160. {
  2161. try
  2162. {
  2163. //if (CarCache.cameraShots.StartTalk())
  2164. //{
  2165. // // btnOpenVoice.Text = "关闭对讲";
  2166. // bVoice = true;
  2167. // }
  2168. }
  2169. catch (Exception ex)
  2170. {
  2171. // setMsgInfo(txtMsgInfo, "打开语音失败:" + ex.Message, "");
  2172. //MessageBox.Show("打开语音失败:" + ex.Message);
  2173. }
  2174. }
  2175. /// <summary>
  2176. /// 关闭语音对讲
  2177. /// </summary>
  2178. private void VoiceClose()
  2179. {
  2180. try
  2181. {
  2182. //if (CarCache.cameraShots.StopTalk())
  2183. //{
  2184. // // setMsgInfo(btnOpenVoice, "打开对讲", "");
  2185. // bVoice = false;
  2186. //}
  2187. }
  2188. catch (Exception ex)
  2189. {
  2190. // setMsgInfo(txtMsgInfo, "打开对讲失败:" + ex.Message, "");
  2191. //MessageBox.Show(ex.Message);
  2192. }
  2193. }
  2194. /// <summary>
  2195. /// 对讲
  2196. /// </summary>
  2197. private void btnOpenVoice_Click(object sender, EventArgs e)
  2198. {
  2199. if (panel1.Controls.Count > 0)
  2200. {
  2201. //if (btnOpenVoice.Text == "打开对讲")
  2202. //{
  2203. // VoiceOpen();
  2204. //}
  2205. //else
  2206. //{
  2207. // VoiceClose();
  2208. //}
  2209. }
  2210. }
  2211. /// <summary>
  2212. /// 关闭视频
  2213. /// </summary>
  2214. private void IPVideoClose()
  2215. {
  2216. try
  2217. {
  2218. CarCache.cameraShots.Close();
  2219. }
  2220. catch (Exception ex)
  2221. {
  2222. // setMsgInfo(txtMsgInfo, "关闭对讲失败:" + ex.Message, "");
  2223. //MessageBox.Show(ex.Message);
  2224. }
  2225. }
  2226. private void setPicBoxSet()
  2227. {
  2228. for (int i = 1; i < 5; i++)
  2229. {
  2230. PictureBox pb = new PictureBox();
  2231. pb.Name = "pb" + i;
  2232. pb.Dock = DockStyle.Top;
  2233. pb.Height = 180;
  2234. pb.DoubleClick += new EventHandler(PictureBoxDoubleClick);
  2235. pb.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  2236. PicPnl.Controls.Add(pb);
  2237. CarCache.cameraShots.RealPlay(pb, i);
  2238. }
  2239. }
  2240. private void PictureBoxDoubleClick(object sender, EventArgs e)
  2241. {
  2242. if (iPic != 0)
  2243. {
  2244. CarCache.cameraShots.StopRealPlay(iPic);
  2245. }
  2246. PictureBox picture = (PictureBox)sender;
  2247. if (plImgShow.Visible == false)
  2248. {
  2249. // plImgShow.Location = new Point(170, 140);
  2250. plImgShow.Width = tbMain.Width - plImgShow.Location.X;
  2251. plImgShow.Height = tbMain.Height - plImgShow.Location.Y;
  2252. }
  2253. iPic = Convert.ToInt32(picture.Name.Substring(picture.Name.Length - 1, 1));
  2254. plImgShow.Visible = true;
  2255. CarCache.cameraShots.RealPlay(pictureShow, iPic);
  2256. }
  2257. private int iPic = 0;
  2258. /// <summary>
  2259. /// 不显示大图
  2260. /// </summary>
  2261. private void pictureShow_DoubleClick(object sender, EventArgs e)
  2262. {
  2263. plImgShow.Visible = false;
  2264. CarCache.cameraShots.StopRealPlay(iPic);
  2265. iPic = 0;
  2266. }
  2267. private void UpdatePointState(CmmMonitorEntity Cmm)
  2268. {
  2269. var ccp = new CoreClientParam
  2270. {
  2271. ServerName = "com.steering.Mcms.CmmMonitorServer",
  2272. MethodName = "DoUpdateisTakeOver ",
  2273. ServerParams = new object[]
  2274. {
  2275. JSONFormat.Format(Cmm)
  2276. }
  2277. };
  2278. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  2279. }
  2280. private void btn_SelectedValueChanged(object sender, EventArgs e)
  2281. {
  2282. //tzh 24.11.8 测试 改成10
  2283. lblWtNow.Text = "0.00t";
  2284. CleanCloseDb();
  2285. if (communicationnow != null)
  2286. {
  2287. communicationnow.Communication.Show = false;
  2288. communicationnow.Communication.Stop();
  2289. communicationnow.Communication.ReceiveData -= defultClenttEntity_ReceiveData;
  2290. }
  2291. communicationnow = null;
  2292. Button btnConect = sender as Button;
  2293. //foreach (Control a in ultraPanel21.Controls)//遍历控件有问题,在demo里面测试没有问题
  2294. //{
  2295. // if (a is Button)
  2296. // {
  2297. // a.ForeColor = a.Tag.ToString() == btnConect.Tag.ToString() ? Color.Blue : Color.Green;
  2298. // }
  2299. //}
  2300. if (btnConect.Tag.ToString() == "A")
  2301. {
  2302. btnA.BackColor = Color.Red;
  2303. // btnB.BackColor = btnC.BackColor = Color.Green;
  2304. }
  2305. if (btnConect.Tag.ToString() == "B")
  2306. {
  2307. btnB.BackColor = Color.Red;
  2308. // btnA.BackColor = btnC.BackColor = Color.Green;
  2309. }
  2310. if (btnConect.Tag.ToString() == "C")
  2311. {
  2312. btnC.BackColor = Color.Red;
  2313. // btnB.BackColor = btnA.BackColor = Color.Green;
  2314. }
  2315. PbCache.Load();
  2316. PbCache.sportInfo = CmmBaseSpotInfo.First(p => p.BaseSpotNo == btnConect.Tag.ToString());
  2317. communicationnow = new CommunicationEntity();
  2318. communicationnow.PoundNo = PbCache.sportInfo.BaseSpotNo;
  2319. communicationnow.Communication = new SocketClient
  2320. {
  2321. Ip = PbCache.sportInfo.WeightIp,
  2322. Port = PbCache.sportInfo.WeightPort,
  2323. Show = false
  2324. };
  2325. communicationnow.PoundNo = PbCache.sportInfo.BaseSpotNo;
  2326. communicationnow.Communication.Show = true;
  2327. WeightLoad(communicationnow.Communication, communicationnow.PoundNo);
  2328. GetIPVideo(PbCache.sportInfo);
  2329. setPicBoxSet();
  2330. }
  2331. /// <summary>
  2332. /// 启动采集
  2333. /// </summary>
  2334. /// <param name="communication"></param>
  2335. private void WeightLoad(iCommunication communication, string PNO)
  2336. {
  2337. communication.ReceiveData += defultClenttEntity_ReceiveData;
  2338. CmmBaseProtocolEntity cmmBaseProtocol = null;
  2339. cmmPoundBase = poundInfos.First(p => p.PoundNo == PNO);
  2340. if (cmmPoundBase != null)
  2341. {
  2342. List<CmmBaseProtocolCEntity> protocols = EntityHelper.GetData<CmmBaseProtocolCEntity>(
  2343. "com.steering.Mcms.ProcotolServer.getProcotolId",
  2344. new object[] { cmmPoundBase.PoundProtocolId },
  2345. ob);
  2346. if ((protocols != null) && protocols.Any())
  2347. cmmBaseProtocol = new CmmBaseProtocolEntity
  2348. {
  2349. ProtocolId = cmmPoundBase.PoundProtocolId,
  2350. ListC = protocols
  2351. };
  2352. // cboPoundList.Text = cmmPoundBase.PoundNo;
  2353. }
  2354. communication.ChangeProtocol(new TruckScaleProtocol(cmmBaseProtocol));
  2355. utbConnect_Click(null, null);
  2356. }
  2357. /// <summary>
  2358. /// 保存重量数据
  2359. /// </summary>
  2360. /// <param name="sender"></param>
  2361. /// <param name="e"></param>
  2362. //private void timer1_Tick(object sender, EventArgs e)
  2363. //{
  2364. // double wt;
  2365. // if (double.TryParse(lblWtNow.Text.Replace("t", ""), out wt))
  2366. // {
  2367. // if (wt >= 0.5)
  2368. // {
  2369. // if (PbCache.isLockFrm == false)
  2370. // {
  2371. // PbCache.dtStartTime = DateTime.Now;
  2372. // PbCache.isLockFrm = true;
  2373. // }
  2374. // if (communicationnow == null)
  2375. // return;
  2376. // var info = CmmBaseSpotInfo.First(t => t.BaseSpotNo == communicationnow.PoundNo);
  2377. // var template = new CmmMonitorWeightEntity
  2378. // {
  2379. // WeightNo = Guid.NewGuid().ToString(),
  2380. // BaseSpotNo = info.BaseSpotNo,
  2381. // BaseSpotName = info.BaseSpotName,
  2382. // CollectWeight = communicationnow.Communication.WeightValue,
  2383. // CollectStartTime = PbCache.dtStartTime.ToString()
  2384. // };
  2385. // var list = new List<string >();
  2386. // list.Add(JSONFormat.Format(template));
  2387. // var ccp = new CoreClientParam
  2388. // {
  2389. // ServerName = "com.steering.Mcms.CmmMonitorWeightServer",
  2390. // MethodName = "addCmmMonitorInfo",
  2391. // ServerParams = new object[]
  2392. // {
  2393. // list
  2394. // }
  2395. // };
  2396. // ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  2397. // }
  2398. // if (wt <= 0.3)
  2399. // {
  2400. // if (communicationnow == null)
  2401. // return;
  2402. // if ( PbCache.isLockFrm == true)
  2403. // {
  2404. // PbCache.isLockFrm = false;
  2405. // var template = new CmmMonitorWeightEntity
  2406. // {
  2407. // BaseSpotNo = PbCache.sportInfo.BaseSpotNo,
  2408. // BaseSpotName = PbCache.sportInfo.BaseSpotName,
  2409. // CollectStartTime = PbCache.dtStartTime.ToString(),
  2410. // CollectEndTime = DateTime.Now.ToString(),
  2411. // ActualFirstNo = PbCache.actualFirstNo
  2412. // };
  2413. // var ccp = new CoreClientParam
  2414. // {
  2415. // ServerName = "com.steering.Mcms.CmmMonitorWeightServer",
  2416. // MethodName = "updateBySpotNoStartTime",
  2417. // ServerParams = new object[]
  2418. // {
  2419. // JsonConvert.SerializeObject(template, Formatting.None, new JsonSerializerSettings
  2420. // {ContractResolver = new CamelCasePropertyNamesContractResolver()})
  2421. // }
  2422. // };
  2423. // ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  2424. // }
  2425. // }
  2426. // else
  2427. // {
  2428. // // MessageBox.Show("数据异常!");
  2429. // return;
  2430. // }
  2431. // }
  2432. //}
  2433. /// <summary>
  2434. /// 接管之前,清空
  2435. /// </summary>
  2436. private void CleanCloseDb()
  2437. {
  2438. //*****************这里需要将语音对讲/视频都关闭*******************
  2439. //退出语音登录
  2440. try
  2441. {
  2442. // VoiceClose();
  2443. IPVideoClose();
  2444. }
  2445. catch (Exception ex)
  2446. {
  2447. }
  2448. // ls = null;
  2449. //*****************************************************************
  2450. // flagCarNo = false;
  2451. setMsgInfo(plImgShow, "false", "2");
  2452. /// DataTable dtJld = dtJGPointInfo.Clone();
  2453. // setGridInfo(ultraGridPW, dtJld, this.dtJGPointInfo);
  2454. // setMsgInfo(lbPointName, "", "");
  2455. // setMsgInfo(lbMeterMan, "", "");
  2456. PbCache.Load();
  2457. PbCache.sportInfo = null;
  2458. CarCache.cameraShots = null;
  2459. // PbCache.relations = null;
  2460. setPanelRemovenfo(PicPnl);
  2461. // bCollectionStart = false;
  2462. //关闭采集进程
  2463. // collection.Stop();
  2464. }
  2465. private void GetRecord_No(string carNO, string state)
  2466. {
  2467. var dic = new Dictionary<string, object>();
  2468. if (!string.IsNullOrWhiteSpace(cboPoundList.Text))
  2469. dic.Add("poundNo", cboPoundList.Text);
  2470. dic.Add("validflag", new List<string> { state });
  2471. var list = EntityHelper.GetData<CmmWeightRecordEntity>(
  2472. "com.steering.Mcms.RecordServer.doQueryRecord",
  2473. new object[] { dic },
  2474. ob).Where(p => p.CarNo == carNO).OrderByDescending(p => p.RecordDate).FirstOrDefault();
  2475. }
  2476. public void setPanelRemovenfo(Panel control)
  2477. {
  2478. setPanelRemoveMsg(control);
  2479. }
  2480. /// <summary>
  2481. /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable
  2482. /// </summary>
  2483. /// <param name="control"></param>
  2484. /// <param name="ResultMessage"></param>
  2485. /// <param name="sType"></param>
  2486. private void setPanelRemoveMsg(Panel p)
  2487. {
  2488. if (p.InvokeRequired)
  2489. {
  2490. Action<Panel> action = new Action<Panel>(setPanelRemovenfo);
  2491. Invoke(action, new object[] { p });
  2492. }
  2493. else
  2494. {
  2495. for (int i = p.Controls.Count - 1; i >= 0; i--)
  2496. {
  2497. p.Controls.RemoveAt(i);
  2498. }
  2499. }
  2500. }
  2501. //private void button1_Click(object sender, EventArgs e)
  2502. //{
  2503. // DhCameraShot tt = new DhCameraShot();
  2504. // CarCache.cameraShots = tt;
  2505. // //todu
  2506. // CarCache.cameraShots.ip = "192.168.21.54";
  2507. // CarCache.cameraShots.port = "8000";
  2508. // CarCache.cameraShots.uid = "admin";
  2509. // CarCache.cameraShots.pwd = "hk123456";
  2510. // CarCache.cameraShots.Connection();
  2511. // setPicBoxSet();
  2512. //}
  2513. //private void button2_Click(object sender, EventArgs e)
  2514. //{
  2515. // imageControl = new ImageControl("192.168.21.220","21","admin", "th2021","1", "/pub/",ob);
  2516. // imageControl.Start();
  2517. // try
  2518. // {
  2519. // PbCache.sportInfo = new CmmBaseSpotInfoEntity();
  2520. // PbCache.sportInfo.BaseSpotNo = "testno";
  2521. // PbCache.actualFirstNo = "actualFirstNo";
  2522. // //string strPath = System.Environment.CurrentDirectory +@"\imgShort\formalImg\" +PbCache.sportInfo.BaseSpotNo +"_"+ "PbCache.actualFirstNo" +"_"+ "7.jpg";
  2523. // //Rectangle r = Screen.PrimaryScreen.Bounds;
  2524. // //Image img = new Bitmap(r.Width, r.Height);
  2525. // //Graphics g = Graphics.FromImage(img);
  2526. // //g.CopyFromScreen(new Point(0, 0), new Point(0, 0), r.Size);
  2527. // //img.Save(strPath);
  2528. // // 截取屏幕信息
  2529. // // PbCache.actualFirstNo = CmmImage.ActualFirstNo;
  2530. // Point screenPoint = this.PointToScreen(new Point());
  2531. // Rectangle rect = new Rectangle(screenPoint, this.Size);
  2532. // Image img = new Bitmap(rect.Width, rect.Height);
  2533. // Graphics g = Graphics.FromImage(img);
  2534. // g.CopyFromScreen(rect.X - 1, rect.Y - 1, 0, 0, rect.Size);//"D://file/1.jpg"
  2535. // img.Save(string.Format("{0}\\imgShort\\formalImg\\{1}_{2}_{3}.jpg",
  2536. // AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
  2537. // PbCache.sportInfo.BaseSpotNo,
  2538. // "C" + PbCache.actualFirstNo,
  2539. // 5), System.Drawing.Imaging.ImageFormat.Jpeg);// 最后一张图片名称写死了
  2540. // //最后进行截图操作
  2541. // CameraShotCls cameraShot = new CameraShotCls();
  2542. // // CarCache.cameraShots.CapMethod("PbCache.actualFirstNo");
  2543. // cameraShot.CapMethod(PbCache.actualFirstNo);
  2544. // //*/
  2545. // }
  2546. // catch (Exception ex)
  2547. // {
  2548. // // l.WriteLog(5, PbCache.lockCarNo + "截图失败");
  2549. // MessageBox.Show(ex.ToString());
  2550. // }
  2551. //}
  2552. //private void button3_Click(object sender, EventArgs e)
  2553. //{
  2554. // communicationnow = new CommunicationEntity();
  2555. // communicationnow.Communication = new SocketClient
  2556. // {
  2557. // Ip = "127.0.0.1",
  2558. // Port = "4001",
  2559. // Show = true
  2560. // };
  2561. // communicationnow.PoundNo = "A";
  2562. // communicationnow.Communication.Show = true;
  2563. // WeightLoad(communicationnow.Communication, communicationnow.PoundNo);
  2564. //}
  2565. private void playVioce(string btName)
  2566. {
  2567. try
  2568. {
  2569. bool rets;
  2570. // CarCache.cameraShots.Connection();
  2571. rets = CarCache.cameraShots.PlayMusic(System.Environment.CurrentDirectory + "\\sound\\称重完成.wav");
  2572. // if (rets) MessageBox.Show("【 称重完成】语音播放成功!");
  2573. }
  2574. catch (Exception ex)
  2575. {
  2576. ex.ToString();
  2577. }
  2578. }
  2579. private void timer2_Tick(object sender, EventArgs e)
  2580. {
  2581. try
  2582. {
  2583. if (communicationnow != null && communicationnow.Communication.Show == true)
  2584. {
  2585. var c4 = new CmmLoadinfoEntity
  2586. {
  2587. Loadip = strip,
  2588. BaseSpotNo = communicationnow.PoundNo,
  2589. };
  2590. var ccp4 = new CoreClientParam
  2591. {
  2592. ServerName = "com.steering.Mcms.CmmLoadinfoServer",
  2593. MethodName = "addLoadinfo",
  2594. ServerParams = new object[]
  2595. {
  2596. JSONFormat.Format(c4)
  2597. }
  2598. };
  2599. ccp4 = ExecuteNonQuery(ccp4, CoreInvokeType.Internal);
  2600. }
  2601. getcolors();
  2602. }
  2603. catch
  2604. { }
  2605. }
  2606. void getcolors()
  2607. {
  2608. //if (communicationnow == null)
  2609. // return;
  2610. try
  2611. {
  2612. loadinfo = EntityHelper.GetData<CmmLoadinfoCEntity>(
  2613. "com.steering.Mcms.CmmLoadinfoServer.queryAll",
  2614. new object[] { },
  2615. ob);
  2616. getColor(btnB);
  2617. getColor(btnA);
  2618. getColor(btnC);
  2619. }
  2620. catch
  2621. { }
  2622. }
  2623. /// <summary>
  2624. /// 通过系统时间和最近一次时间对比,判断是否在线
  2625. /// </summary>
  2626. /// <param name="b"></param>
  2627. void getColor(Control b)
  2628. {
  2629. Button btnco = (Button)b;
  2630. if ((communicationnow != null) && (btnco.Tag.ToString() == communicationnow.PoundNo) && (communicationnow.Communication.Show == true))
  2631. {
  2632. btnco.BackColor = Color.Red;
  2633. return;
  2634. }
  2635. int countco = 0;
  2636. TimeSpan ts = new TimeSpan();
  2637. foreach (var p in loadinfo)
  2638. {
  2639. DateTime updatetime = Convert.ToDateTime(p.Actualtime);
  2640. DateTime time = Convert.ToDateTime(p.UpdateTime);
  2641. ts = updatetime.Subtract(time);
  2642. if (ts.TotalDays == 0)
  2643. {
  2644. if (ts.TotalHours == 0)
  2645. {
  2646. if (ts.TotalMinutes == 0)
  2647. {
  2648. if (ts.Seconds <= 7)
  2649. {
  2650. if ((btnco.Tag.ToString() == p.BaseSpotNo.ToString()) && (p.Loadip != strip))
  2651. {
  2652. countco++;
  2653. }
  2654. }
  2655. }
  2656. }
  2657. }
  2658. }
  2659. if (countco == 0)
  2660. {
  2661. btnco.UseVisualStyleBackColor = true;
  2662. }
  2663. if (countco >= 1)
  2664. {
  2665. btnco.BackColor = Color.Green;
  2666. }
  2667. }
  2668. void addActual(string spot, string record)
  2669. {
  2670. var c2 = new CmmActualWeightEntity
  2671. {
  2672. BaseSpotNo = spot,
  2673. RecordNo = record,
  2674. };
  2675. var ccp3 = new CoreClientParam
  2676. {
  2677. ServerName = "com.steering.Mcms.CmmActualWeightServer",
  2678. MethodName = "addActualWeight",
  2679. ServerParams = new object[]
  2680. {
  2681. JSONFormat.Format(c2)
  2682. }
  2683. };
  2684. ccp3 = ExecuteNonQuery(ccp3, CoreInvokeType.Internal);
  2685. }
  2686. private void btn_Click(object sender, EventArgs e)
  2687. {
  2688. //tzh 24.11.8 测试 改成10
  2689. lblWtNow.Text = "0.00t";
  2690. CleanCloseDb();
  2691. if (communicationnow != null)
  2692. {
  2693. communicationnow.Communication.Show = false;
  2694. communicationnow.Communication.Stop();
  2695. communicationnow.Communication.ReceiveData -= defultClenttEntity_ReceiveData;
  2696. }
  2697. communicationnow = null;
  2698. lblStatus.SafeRefreshControl(() => lblStatus.Text = "重量采集已断开");
  2699. }
  2700. private void ugData_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
  2701. {
  2702. var current = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
  2703. if ((current == null) || ("" == current.ResultNo)) return;
  2704. var loadinfo1 = EntityHelper.GetData<CmmWorkImageEntity>(
  2705. "com.steering.Mcms.CmmWorkImageServer.doQuery",
  2706. new object[] { current.RecordNo1 },
  2707. ob);
  2708. var loadinfo2 = EntityHelper.GetData<CmmWorkImageEntity>(
  2709. "com.steering.Mcms.CmmWorkImageServer.doQuery",
  2710. new object[] { current.RecordNo2 },
  2711. ob);
  2712. if ((loadinfo1.Count == 0) && (loadinfo2.Count == 0))
  2713. {
  2714. MessageBox.Show("没有单号" + current.ResultNo + "图片记录");
  2715. return;
  2716. }
  2717. Form form = frmLocalTruckImageShow.GetSingleton(ob, current, CmmBaseSpotInfo[0]); // 有参数
  2718. form.Show();
  2719. form.Activate();
  2720. }
  2721. private void uctMemo_EditorButtonClick(object sender, EditorButtonEventArgs e)
  2722. {
  2723. if (cmmPoundBase == null)
  2724. {
  2725. MessageBox.Show(@"无磅房权限");
  2726. return;
  2727. }
  2728. var current = CurrentGrid.ActiveRow.ListObject as CmmWeightRecordEntity;
  2729. string Memo;
  2730. using (var update = new ChangeMemo { Memo = current.Memo })
  2731. {
  2732. var result = update.ShowDialog();
  2733. if (result != DialogResult.OK) return;
  2734. Memo = update.Memo;
  2735. }
  2736. var ccp = new CoreClientParam
  2737. {
  2738. ServerName = "com.steering.Mcms.RecordServer",
  2739. MethodName = "DoUpdateMemo",
  2740. ServerParams = new object[]
  2741. {
  2742. current.RecordNo,
  2743. Memo
  2744. }
  2745. };
  2746. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  2747. if (ccp.ReturnCode != -1)
  2748. {
  2749. MessageUtil.ShowTips(ccp.ReturnInfo);
  2750. if (ccp.ReturnInfo.ToString2().Contains("操作成功"))
  2751. Query();
  2752. }
  2753. }
  2754. private void button1_Click(object sender, EventArgs e)
  2755. {
  2756. playVioce("称重完成");
  2757. }
  2758. private void button1_Click_1(object sender, EventArgs e)
  2759. {
  2760. lblWt.Text = "1.00t";
  2761. }
  2762. private void button2_Click(object sender, EventArgs e)
  2763. {
  2764. // playVioce("称重完成");
  2765. lblWt.Text = "2.00t";
  2766. }
  2767. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  2768. {
  2769. if (checkBox3.Checked)
  2770. {
  2771. qitahuipi.Visible = true;
  2772. }
  2773. else
  2774. {
  2775. qitahuipi.Visible = false;
  2776. }
  2777. }
  2778. private void ultraButton2_Click(object sender, EventArgs e)
  2779. {
  2780. using (var BlankPredictionSelect = new BlankPredictionSelect(ob, matInfo20.GetData()))
  2781. {
  2782. if (BlankPredictionSelect.ShowDialog() == DialogResult.OK)
  2783. matInfo20.UpdateData(new CmmWeightRecordEntityFull
  2784. {
  2785. MatName = "连铸圆坯",
  2786. ShippersName = BlankPredictionSelect.ShipperName,
  2787. RecordNumber = BlankPredictionSelect.ListMatNo == null ? null : BlankPredictionSelect.ListMatNo.Sum(p => p.ActCount),
  2788. ReceiveName = "江苏天淮钢管有限公司",
  2789. Memo = BlankPredictionSelect.Memo,
  2790. MatInfos =
  2791. BlankPredictionSelect.ListMatNo ?? new List<CmmWeightMatEntity> { new CmmWeightMatEntity() }
  2792. });
  2793. }
  2794. }
  2795. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  2796. {
  2797. if (checkBox1.Checked)
  2798. {
  2799. chkSteelCar.Visible = false;
  2800. chkGross.Visible = false;
  2801. }
  2802. else
  2803. {
  2804. chkGross.Visible = true;
  2805. chkSteelCar.Visible = true;
  2806. }
  2807. }
  2808. private void qitahuipi_SelectedTabChanged(object sender, SelectedTabChangedEventArgs e)
  2809. {
  2810. LoadTem2();
  2811. if ((tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  2812. (tbScondWt.ActiveTab.Key == "2") && qitahuipi.ActiveTab != null && qitahuipi.ActiveTab.Key == "102")
  2813. {
  2814. ultraButton2.Visible = true;
  2815. }
  2816. else
  2817. {
  2818. ultraButton2.Visible = false;
  2819. }
  2820. }
  2821. private void button3_Click(object sender, EventArgs e)
  2822. {
  2823. cmmPoundBase = poundInfos.First(p => p.PoundNo == "A");
  2824. }
  2825. private void chkSteelCar_CheckedChanged(object sender, EventArgs e)
  2826. {
  2827. if (chkSteelCar.Checked == true)
  2828. {
  2829. checkBox1.Visible = false;
  2830. }
  2831. else
  2832. {
  2833. checkBox1.Visible = true;
  2834. }
  2835. }
  2836. private void timer1_Tick(object sender, EventArgs e)
  2837. {
  2838. Query();
  2839. }
  2840. private void button4_Click(object sender, EventArgs e)
  2841. {
  2842. button1_Click(null, null);
  2843. }
  2844. private void LoadTem2()
  2845. {
  2846. if (_templateList == null) return;
  2847. var key = GetKey2();
  2848. if (string.IsNullOrWhiteSpace(key)) return;
  2849. if ((_cmmInputRecordEntities != null) && _cmmInputRecordEntities.Any())
  2850. {
  2851. var matInfo = GetMatInfo();
  2852. if (matInfo != null)
  2853. matInfo.iniMatName(
  2854. _cmmInputRecordEntities.Where(
  2855. p => (p.RecordKey == key) || string.IsNullOrWhiteSpace(p.RecordKey)).ToList());
  2856. }
  2857. lvTemplate.Items.Clear();
  2858. lvTemplate.Items.AddRange(_templateList.Where(p => CheckShowKey(p.TemplateKey, key))
  2859. .Select(p =>
  2860. {
  2861. var
  2862. temp =
  2863. new UltraListViewItem(p.TemplateName, null, null) { Key = p.TemplateNo };
  2864. try
  2865. {
  2866. temp.Tag =
  2867. XmlHelper.FromXElement<CmmWeightRecordEntityFull>(XElement.Parse(p.TemplateXml));
  2868. }
  2869. catch (Exception)
  2870. {
  2871. // ignored
  2872. }
  2873. return temp;
  2874. }
  2875. ).
  2876. ToArray()
  2877. );
  2878. }
  2879. private string GetKey2()
  2880. {
  2881. return tbWt.ActiveTab.Key == "1"
  2882. ? (tbFirstWt.ActiveTab == null ? "" : tbFirstWt.ActiveTab.Key)
  2883. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "1") &&
  2884. (tbOther.ActiveTab != null)
  2885. ? tbOther.ActiveTab.Key
  2886. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) && (tbScondWt.ActiveTab.Key == "0")
  2887. ? "201"
  2888. : (tbWt.ActiveTab.Key == "2") && (tbScondWt.ActiveTab != null) &&
  2889. (tbScondWt.ActiveTab.Key == "2")&& qitahuipi.Visible==true
  2890. ? qitahuipi.ActiveTab.Key
  2891. : "";
  2892. }
  2893. private void utbSaveAsT2_Click(object sender, EventArgs e)
  2894. {
  2895. if (cmmPoundBase == null)
  2896. {
  2897. MessageBox.Show(@"无磅房权限");
  2898. return;
  2899. }
  2900. if (tbWt.ActiveTab == null) return;
  2901. var matInfo = GetMatInfo();
  2902. if (matInfo != null)
  2903. {
  2904. var cmmWeightRecord = matInfo.GetData();
  2905. string projectName;
  2906. using (var fractureInfo = new ProjectName("模板名"))
  2907. {
  2908. fractureInfo.ShowDialog();
  2909. if (fractureInfo.DialogResult != DialogResult.OK) return;
  2910. projectName = fractureInfo.ProjectNameStr;
  2911. }
  2912. var template = new CmmRecordTemplateEntity
  2913. {
  2914. CreateUser = UserInfo.GetUserName(),
  2915. TemplateKey = GetKey2(),
  2916. TemplateLocation = cmmPoundBase.PoundNo,
  2917. TemplateXml = cmmWeightRecord.ToString(),
  2918. TemplateName = projectName
  2919. };
  2920. var ccp = new CoreClientParam
  2921. {
  2922. ServerName = "com.steering.Mcms.TemplateServer",
  2923. MethodName = "DoSaveTemplateNo",
  2924. ServerParams = new object[]
  2925. {
  2926. JsonConvert.SerializeObject(template, Formatting.None, new JsonSerializerSettings
  2927. {ContractResolver = new CamelCasePropertyNamesContractResolver()})
  2928. }
  2929. };
  2930. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  2931. if (ccp.ReturnCode != -1)
  2932. {
  2933. MessageUtil.ShowTips(ccp.ReturnInfo);
  2934. if (ccp.ReturnInfo.Equals("保存成功!"))
  2935. LoadTempate2();
  2936. }
  2937. }
  2938. }
  2939. private void LoadTempate2()
  2940. {
  2941. /* if (cmmPoundBase == null)
  2942. return;
  2943. */
  2944. _templateList = EntityHelper.GetData<CmmRecordTemplateEntity>(
  2945. "com.steering.Mcms.TemplateServer.doQueryTempate",
  2946. new object[] { "" },
  2947. ob);
  2948. qitahuipi_SelectedTabChanged(null, null);
  2949. }
  2950. private void btnPlay_Click(object sender, EventArgs e)
  2951. {
  2952. try
  2953. {
  2954. bool rets;
  2955. // CarCache.cameraShots.Connection();
  2956. rets = CarCache.cameraShots.PlayMusic(System.Environment.CurrentDirectory + "\\sound\\"+ cmbVioce.Text+".wav");
  2957. // if (rets) MessageBox.Show("【 称重完成】语音播放成功!");
  2958. }
  2959. catch (Exception ex)
  2960. {
  2961. ex.ToString();
  2962. }
  2963. }
  2964. private void ultraButton3_Click(object sender, EventArgs e)
  2965. {
  2966. if (ugData.ActiveRow == null) return;
  2967. var data = ugData.ActiveRow.ListObject as CmmWeightResultEntity;
  2968. if (data == null) return;
  2969. if ((data.RecordType2 == "201") && (data.GrossWt != null) && (data.GrossWt > 50) && (MessageUtil.ShowYesNoAndQuestion("毛重超过50吨, 是否继续打印磅单?") ==
  2970. DialogResult.No))
  2971. {
  2972. }
  2973. else
  2974. {
  2975. Print2(data.ResultNo);
  2976. }
  2977. }
  2978. }
  2979. }