frmLocalTruckScaleNew.cs 132 KB

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