using com.hnshituo.core.webapp.vo; using Common; using Common.vo.pb; using Infragistics.Win.UltraWinGrid; using JC_MeasuringSystem; using MeterModuleLibrary; using MeterPlugInLibrary; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Net; using System.Threading; using System.Windows.Forms; namespace BeltScaleSystem { public partial class frmBeltInstrument1 : Form { public frmBeltInstrument1() { InitializeComponent(); } private Log lg = Log.GetInstance(); private BaseDbCls bd = new BaseDbCls(); private string strIpAddress = ""; private MeterBaseScalePointService monitorService = new MeterBaseScalePointService(); private void frmMonitor_Load(object sender, EventArgs e) { PbCacheMonitor.frmMsgClosingTime = DateTime.Now; #region 载入计量点的信息 bd.setBaseDbScalePoint(); setGridData(); strIpAddress = GetIP(); #endregion 载入计量点的信息 //thVoice.Start(); } /// /// 计量点信息 /// public void setGridData() { DataTable dt = dtJGPointInfo.Clone(); if (PbCacheMonitor.sportInfoList!=null&& PbCacheMonitor.sportInfoList.Count>0&& PbCacheMonitor.ltMeterBaseScalePoint != null && PbCacheMonitor.ltMeterBaseScalePoint.Count > 0) { foreach (MeterBaseScalePoint mwm in PbCacheMonitor.ltMeterBaseScalePoint) { DataRow dr = dt.NewRow(); dr["scalePointNo"] = mwm.scalePointNo; dr["baseSpotNo"] = mwm.baseSpotNo; dr["baseSpotName"] = mwm.baseSpotName; dr["monitorUserNo"] = mwm.monitorUserNo; dr["collectionCodeA"] = mwm.collectionCode; dr["collectionCodeB"] = mwm.collectionCodeB; dt.Rows.Add(dr); } } ClsControlPack.CopyDataToDatatable(ref dt, ref this.dtJGPointInfo, true); } private void ultraGridPW_CellChange(object sender, CellEventArgs e) { ultraGridPW.UpdateData(); UltraGridRow ugr = ultraGridPW.ActiveRow; if (ugr != null) { if (ugr.Cells["UNCK"].Value.ToString().ToLower() == "false") { ucBeltInstrumentInfo_Real u = (ucBeltInstrumentInfo_Real)flPanel.Controls["uc" + ugr.Cells["baseSpotNo"].Text]; flPanel.Controls.RemoveByKey("uc" + ugr.Cells["baseSpotNo"].Text); u.Close(); } else { ucBeltInstrumentInfo_Real uc = new ucBeltInstrumentInfo_Real(); uc.Name = "uc" + ugr.Cells["baseSpotNo"].Text; uc.collectionCodeA = ugr.Cells["collectionCodeA"].Text.Trim(); uc.collectionCodeB = ugr.Cells["collectionCodeB"].Text.Trim(); uc.sIpAddress = strIpAddress; uc.sPointNo = ugr.Cells["baseSpotNo"].Text; uc.sPointName = ugr.Cells["baseSpotName"].Text; uc.BorderStyle = BorderStyle.FixedSingle; flPanel.Controls.Add(uc); } } } /// /// 界面关闭 /// /// /// private void frmMonitor_FormClosing(object sender, FormClosingEventArgs e) { try { List uGrid = GridHelper.UltraGridGetChooseRows(ultraGridPW, "UNCK"); if (uGrid.Count == 0) { return; } foreach (UltraGridRow ugr in uGrid) { if (ugr.Cells["UNCK"].Value.ToString().ToUpper() == "TRUE") { ucBeltInstrumentInfo_Real u = (ucBeltInstrumentInfo_Real)flPanel.Controls["uc" + ugr.Cells["baseSpotNo"].Text]; flPanel.Controls.RemoveByKey("uc" + ugr.Cells["baseSpotNo"].Text); u.Close(); ugr.Cells["UNCK"].Value = false; } } } catch (Exception ex) { lg.WriteLog(4, "关闭皮带秤计量异常:" + ex.Message); } finally { } } /// /// 获取IP地址 /// /// public string GetIP() { try { IPHostEntry ipHost = Dns.Resolve(Dns.GetHostName()); IPAddress ipAddr = ipHost.AddressList[0]; return ipAddr.ToString(); } catch (Exception ex) { Random rd = new Random(); MessageBox.Show("GetIP方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n!" + ex); lg.WriteLog(13, "GetIP方法异常:" + ex.Message); return rd.Next(99999, 999999) + ""; } } } }