frmLocalTruckScaleNew.cs 131 KB

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