private void UpdateButtons() { int[] selectedrows = gridView1.GetSelectedRows(); if (selectedrows.Length == 0) { simpleButton3.Enabled = false; simpleButton4.Enabled = false; } else { if (gridView1.GetFocusedRow() is Trionic5Tools.TransactionEntry) { Trionic5Tools.TransactionEntry sh = (Trionic5Tools.TransactionEntry)gridView1.GetFocusedRow(); if (sh.IsRolledBack) { simpleButton4.Enabled = true; simpleButton3.Enabled = false; } else { simpleButton4.Enabled = false; simpleButton3.Enabled = true; } } } }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { // get selected row and decide what to show/not to show Point p = gridControl1.PointToClient(Cursor.Position); GridHitInfo hitinfo = gridView1.CalcHitInfo(p); int[] selectedrows = gridView1.GetSelectedRows(); if (hitinfo.InRow) { int grouplevel = gridView1.GetRowLevel((int)selectedrows.GetValue(0)); if (grouplevel >= gridView1.GroupCount) { //Console.WriteLine("In row"); if (gridView1.GetFocusedRow() is Trionic5Tools.TransactionEntry) { Trionic5Tools.TransactionEntry sh = (Trionic5Tools.TransactionEntry)gridView1.GetFocusedRow(); if (sh.IsRolledBack) { rollForwardToolStripMenuItem.Enabled = true; rolllBackToolStripMenuItem.Enabled = false; } else { rollForwardToolStripMenuItem.Enabled = false; rolllBackToolStripMenuItem.Enabled = true; } } } } }
public void AddToTransactionLog(TransactionEntry entry) { entry.TransactionNumber = _transCollection.Count + 1; _transCollection.Add(entry); //SaveTransactionLog(); AddTransactionToFile(entry, true); //UpdateNumberOfTransActions(); //UpdateChecksum(); }
private void simpleButton4_Click(object sender, EventArgs e) { // cast roll forward if (gridView1.GetFocusedRow() is Trionic5Tools.TransactionEntry) { Trionic5Tools.TransactionEntry sh = (Trionic5Tools.TransactionEntry)gridView1.GetFocusedRow(); CastRollForwardEvent(sh); gridView1.FocusedRowHandle++; } }
private void simpleButton3_Click(object sender, EventArgs e) { // cast rollback if (gridView1.GetFocusedRow() is Trionic5Tools.TransactionEntry) { Trionic5Tools.TransactionEntry sh = (Trionic5Tools.TransactionEntry)gridView1.GetFocusedRow(); CastRollBackEvent(sh); // move the selected cursor one row up, if possible gridView1.FocusedRowHandle--; } }
public void SetEntryNote(TransactionEntry ChangedEntry) { foreach (TransactionEntry entry in _transCollection) { if (entry.TransactionNumber == ChangedEntry.TransactionNumber) { entry.Note = ChangedEntry.Note; } } SaveTransactionLog(); }
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { // note was edited? if (e.Column.Name == gcNote.Name) { // save the transaction log again (and reload?) Trionic5Tools.TransactionEntry sh = (Trionic5Tools.TransactionEntry)gridView1.GetRow(e.RowHandle); //MessageBox.Show("You changed the note into: " + sh.Note); CastNoteChangedEvent(sh); } }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) { if (destType == typeof(string) && value is TransactionEntry) { // Cast the value to an Employee type TransactionEntry pp = (TransactionEntry)value; return(pp.EntryDateTime.ToString() + ", " + pp.SymbolAddress + ", " + pp.SymbolLength); } return(base.ConvertTo(context, culture, value, destType)); }
public void ReadTransactionFile() { _transCollection = new TransactionCollection(); if (VerifyChecksum()) { FileInfo fi = new FileInfo(m_fileName); Int32 _entryCount = readInt32FromFile(m_fileName, 4); FileStream fs = new FileStream(m_fileName, FileMode.Open); fs.Seek(8, SeekOrigin.Begin); using (BinaryReader br = new BinaryReader(fs)) { // byte[] allBytes = br.ReadBytes((int)fi.Length - 8); //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after for (int t = 0; t < _entryCount; t++) { Int32 transActionNumber = br.ReadInt32(); byte isRolledBack = br.ReadByte(); byte day = br.ReadByte(); byte month = br.ReadByte(); Int16 year = br.ReadInt16(); byte hour = br.ReadByte(); byte minute = br.ReadByte(); byte second = br.ReadByte(); DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second)); Int32 address = br.ReadInt32(); Int16 NoteLength = br.ReadInt16(); byte[] notedata = br.ReadBytes(NoteLength); string note = string.Empty; for (int i = 0; i < notedata.Length; i += 2) { string Hex = string.Empty; Hex += Convert.ToChar(notedata[i]); Hex += Convert.ToChar(notedata[i + 1]); int value = Convert.ToInt32(Hex, 16); note += Convert.ToChar(value); } Int16 length = br.ReadInt16(); byte[] beforeData = br.ReadBytes(length); byte[] afterData = br.ReadBytes(length); // read day TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, note); _transCollection.Add(entry); } } fs.Close(); } }
private void rollForwardToolStripMenuItem_Click(object sender, EventArgs e) { // cast rollforward event to the main form // and reload the list int[] selectedrows = gridView1.GetSelectedRows(); int grouplevel = gridView1.GetRowLevel((int)selectedrows.GetValue(0)); if (grouplevel >= gridView1.GroupCount) { //Console.WriteLine("In row"); if (gridView1.GetFocusedRow() is Trionic5Tools.TransactionEntry) { Trionic5Tools.TransactionEntry sh = (Trionic5Tools.TransactionEntry)gridView1.GetFocusedRow(); CastRollForwardEvent(sh); } } }
private void AddTransactionToFile(TransactionEntry entry, bool updateChecksum) { // append at the end of the file //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after AppendInt32ToFile(entry.TransactionNumber); AppendByteToFile(Convert.ToByte(entry.IsRolledBack)); // not rolled back AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Day)); AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Month)); AppendInt16ToFile(Convert.ToInt16(entry.EntryDateTime.Year)); AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Hour)); AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Minute)); AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Second)); AppendInt32ToFile(entry.SymbolAddress); AppendInt16ToFile(Convert.ToInt16(entry.Note.Length * 2)); // now add double hex all characters for (int i = 0; i < entry.Note.Length; i++) { byte curByte = Convert.ToByte(entry.Note[i]); string Hex = curByte.ToString("X2"); AppendByteToFile(Convert.ToByte(Hex[0])); AppendByteToFile(Convert.ToByte(Hex[1])); } AppendInt16ToFile(Convert.ToInt16(entry.SymbolLength)); AppendDataToFile(entry.DataBefore); AppendDataToFile(entry.DataAfter); // update number of entries Int32 _entryCount = readInt32FromFile(m_fileName, 4); _entryCount++; if (updateChecksum) { writeInt32ToFile(m_fileName, 4, _entryCount); UpdateChecksum(); } // update checksum }
public TransactionCollection ReadTransactionFileVersion1(string filename) { TransactionCollection m_transCollection = new TransactionCollection(); Int32 _entryCount = readInt32FromFile(filename, 4); FileStream fs = new FileStream(filename, FileMode.Open); fs.Seek(8, SeekOrigin.Begin); using (BinaryReader br = new BinaryReader(fs)) { //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after for (int t = 0; t < _entryCount; t++) { Int32 transActionNumber = br.ReadInt32(); byte isRolledBack = br.ReadByte(); byte day = br.ReadByte(); byte month = br.ReadByte(); Int16 year = br.ReadInt16(); byte hour = br.ReadByte(); byte minute = br.ReadByte(); byte second = br.ReadByte(); DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second)); Int32 address = br.ReadInt32(); Int16 length = br.ReadInt16(); byte[] beforeData = br.ReadBytes(length); byte[] afterData = br.ReadBytes(length); // read day TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, ""); m_transCollection.Add(entry); } } fs.Close(); return(m_transCollection); }
public bool Contains(TransactionEntry value) { // If value is not of type Int16, this will return false. return(List.Contains(value)); }
public int Add(TransactionEntry value) { return(List.Add(value)); }
public int IndexOf(TransactionEntry value) { return(List.IndexOf(value)); }
public void Insert(int index, TransactionEntry value) { List.Insert(index, value); }
public TransactionsEventArgs(TransactionEntry entry) { this._entry = entry; }
public void Remove(TransactionEntry value) { List.Remove(value); }