internal void DisplayData() { DataTable dataTable = new DataSet("LogDataSet").Tables.Add("AllValues"); KMPLogDataSet.RegisterInUseRow registerInUseRow = this.KMPDS.RegisterInUse[0]; dataTable.Columns.Add(new DataColumn() { DataType = typeof(int), ColumnName = "Id" }); dataTable.Columns.Add("TimeStamp", typeof(DateTime)); if (registerInUseRow.INFO) { dataTable.Columns.Add("Info Code", typeof(double)); dataTable.Columns.Add("Info", typeof(string)); } if (registerInUseRow.LogQOS) { dataTable.Columns.Add("LogQOS Code", typeof(double)); dataTable.Columns.Add("LogQOS", typeof(string)); } foreach (KMPLogDataSet.RegistersRow registersRow in this.KMPDS.Registers) { DataRow row = dataTable.NewRow(); row["Id"] = registersRow.Id; row["TimeStamp"] = registersRow.Date; if (registerInUseRow.INFO) { row["Info Code"] = registersRow.INFO; row["Info"] = ClsUtils.InfoCodeToString(Convert.ToDouble(registersRow.INFO)); } if (registerInUseRow.INFO) { row["LogQOS Code"] = registersRow.LogQOS; row["LogQOS"] = ClsUtils.LogQOSCodeToString(registersRow.LogQOS); } dataTable.Rows.Add(row); } this.grdInfoLog.DataSource = dataTable; this.grdInfoLog.DataBind(); this.grdInfoLog.DisplayLayout.Bands[0].Columns["Id"].Hidden = true; this.grdInfoLog.DisplayLayout.Override.ColumnAutoSizeMode = ColumnAutoSizeMode.AllRowsInBand; }
private void ReadInfoLog() { string ErrorMessage = ""; byte UnitId = (byte)0; ushort num1 = (ushort)1; Functions functions = new Functions(); ArrayList arrayList1 = new ArrayList(); ArrayList arrayList2 = new ArrayList(); DataTable dataTable = new DataSet("InfoLogDataSet").Tables.Add("AllValues"); dataTable.Columns.Add(new DataColumn() { DataType = typeof(int), ColumnName = "Id" }); dataTable.Columns.Add("Date", typeof(DateTime)); dataTable.Columns.Add("Info Code", typeof(double)); dataTable.Columns.Add("Info", typeof(string)); ArrayList arrValues1 = new ArrayList(); ArrayList arrValues2 = new ArrayList(); bool flag = true; this.ReadCustomerNo(); if (flag && functions.GetHistInfoData((byte)63, (ushort)1003, (ushort)1, (byte)16, arrValues1, out UnitId, out ErrorMessage) && functions.GetHistInfoData((byte)63, (ushort)99, (ushort)1, (byte)16, arrValues2, out UnitId, out ErrorMessage) && functions.GetHistInfoData((byte)63, (ushort)1003, (ushort)17, (byte)16, arrValues1, out UnitId, out ErrorMessage) && functions.GetHistInfoData((byte)63, (ushort)99, (ushort)17, (byte)16, arrValues2, out UnitId, out ErrorMessage) && functions.GetHistInfoData((byte)63, (ushort)1003, (ushort)33, (byte)4, arrValues1, out UnitId, out ErrorMessage) && functions.GetHistInfoData((byte)63, (ushort)99, (ushort)33, (byte)4, arrValues2, out UnitId, out ErrorMessage)) { for (byte index = (byte)0; (int)index < arrValues2.Count; ++index) { DataRow row = dataTable.NewRow(); row["Id"] = ((int)num1 + (int)index); double num2 = (double)arrValues1[(int)index]; int year = 2000 + Convert.ToInt32(num2) / 10000; int month = Convert.ToInt32(num2) % 10000 / 100; int day = Convert.ToInt32(num2) % 100; DateTime dateTime; try { dateTime = new DateTime(year, month, day); } catch { dateTime = new DateTime(2000, 1, 1); } row["Date"] = dateTime; double infoCode = (double)arrValues2[(int)index]; row["Info Code"] = infoCode; row["Info"] = ClsUtils.InfoCodeToString(infoCode); dataTable.Rows.Add(row); } this.grdInfoLog.DataSource = dataTable; this.grdInfoLog.DataBind(); this.grdInfoLog.DisplayLayout.Bands[0].Columns["Id"].Hidden = true; this.grdInfoLog.DisplayLayout.Override.ColumnAutoSizeMode = ColumnAutoSizeMode.AllRowsInBand; if (dataTable.Rows.Count <= 0) { return; } DataTable graphData = dataTable.Clone(); foreach (DataRow dataRow in (InternalDataCollectionBase)dataTable.Rows) { DataRow row = graphData.NewRow(); row["Date"] = dataRow["Date"]; row["Info Code"] = dataRow["Info Code"]; graphData.Rows.Add(row); } graphData.Columns.Remove("Id"); graphData.Columns.Remove("Info"); FrmGraph frmGraph = new FrmGraph(this.m_CustomerNo); frmGraph.MdiParent = this.MdiParent; frmGraph.ShowTime = true; frmGraph.SetData(graphData); frmGraph.Show(); } else { int num3 = (int)MessageBox.Show("Lost the connection to the MC601 Meter!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }