-
I take on projects of all sizes for businesses of all sizes. Contact me for a no obligation initial discussion.
A properly designed database provides your business with access to up-to-date, accurate information.
Bespoke applications for a independent solution or add-on module will extend the capability of your existing system.
Monthly Archives: July 2012
Interrupt Port Handling
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// this moved out here so it can be used by other methods static OutputPort LED; public static void Main() { LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true); // the pin will generate interrupt on high and low edges InterruptPort IntButton = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.LDR, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth); // add an interrupt handler to the pin IntButton.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt); //do anything you like here Thread.Sleep(Timeout.Infinite); } static void IntButton_OnInterrupt(uint port, uint state, DateTime time) { // set LED to the switch state LED.Write(state == 0); } |
Posted in .Net Micro
Comments Off on Interrupt Port Handling
Switch Statement
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
DateTime currentTime = DateTime.Now; int day = (int)currentTime.DayOfWeek; switch (day) { case 0: Debug.Print("Sunday"); break; case 1: Debug.Print("Monday"); break; case 2: Debug.Print("Tuesday"); break; case 3: Debug.Print("Wednsday"); break; case 4: Debug.Print("Thursday"); break; case 5: Debug.Print("Friday"); break; case 6: Debug.Print("Saturday"); break; default: Debug.Print("We should never see this"); break; } |
Posted in .Net Micro
Comments Off on Switch Statement
Enumeration
An Enumeration is very similar to a constant.
|
1 2 3 4 5 6 7 8 9 10 |
enum Command { MOVE = 1, STOP = 2, RIGHT = 3, LEFT = 4, } //now we can send a command... SendCommand(Command.LEFT); SendCommand(Command.STOP); |
Posted in .Net Micro
Comments Off on Enumeration
Classes
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
class MyClass { int Add(int a, int b) { return a + b; } } Example of a public method using a private method public int Add(int a, int b) { // the object can use private methods // inside the class only DoSomething(); return a + b; } private void DoSomething() { } |
Posted in .Net Micro
Comments Off on Classes
Methods
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
int Add(int var1, int var2) { int var3; var3 = var1 + var2; return var3; } string Add(int var1, int var2) { int var3; var3 = var1 + var2; string MyString; MyString = var3.ToString(); return MyString; } string Add(int var1, int var2) { return (var1+var2).ToString(); } |
Posted in .Net Micro
Comments Off on Methods
AX BC- Query with Joins
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
try { AxaptaRecord[] tableArray = new AxaptaRecord[2]; AxaptaRecord APMObjectTableRecord = DynAx.CreateAxaptaRecord("APMObjectTable"); AxaptaRecord WarrantyTableRecord = DynAx.CreateAxaptaRecord("WarrantyInvoiceTable"); tableArray[0] = APMObjectTableRecord; tableArray[1] = WarrantyTableRecord; DynAx.ExecuteStmt("select * from %1 join %2", tableArray); while (APMObjectTableRecord.Found) { string Id = (string)APMObjectTableRecord.get_Field("APMObjectId").ToString(); string Amount = (string)WarrantyTableRecord.get_Field("Amount").ToString().ToString(); APMObjectTableRecord.Next(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Don't Panic!"); } |
Posted in C# Development
Comments Off on AX BC- Query with Joins
AX BC- Read a Record
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
try { DynRec = DynAx.CreateAxaptaRecord("smmBusRelTable"); string fieldName = ("Status"); string fieldValue = ("Active"); DynRec.ExecuteStmt(string.Format("select * from %1 where %1.{0} == '{1}'", fieldName, fieldValue)); List<String> QueryList = new List<string>(); while (DynRec.Found) { QueryList.Add((string)DynRec.get_Field("BusRelAccount")); DynRec.Next(); } MainGrid.DataSource = (from item in QueryList select new { item }).ToList(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Don't Panic!"); } |
Posted in C# Development
Comments Off on AX BC- Read a Record
AX BC- Update a Record
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
try { // Create an Axapta record for the StateAddress table. DynRec = DynAx.CreateAxaptaRecord("APMObjectTable"); // Execute a query to retrieve an editable record where the name is MyState. DynRec.ExecuteStmt("select forupdate * from %1 where %1.APMObjectId == 'HLH000001'"); // If the record is found then update the name. if (DynRec.Found) { // Start a transaction that can be committed. DynAx.TTSBegin(); string _text = @""; _text += "Line One\n"; _text += "Line Two\n"; _text += "Line Three\n"; _text += "Line Four\n"; DynRec.set_Field("APMObjectDescription", _text); DynRec.Update(); // Commit the transaction. DynAx.TTSCommit(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Don't Panic!"); } |
Posted in C# Development
Comments Off on AX BC- Update a Record
AX BC- Log Off
|
1 2 3 4 5 6 7 8 9 |
try { DynAx.Logoff(); Application.DoEvents(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Don't Panic!"); } |
Posted in C# Development
Comments Off on AX BC- Log Off
AX BC- Log On
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
try { StatusBar.Text = "Logging On..."; Application.DoEvents(); // Authenticate the user and establish a session. DynAx.Logon(null, null, null, @"\\ediaxsql01v\DynamicsAX\Application\Share\config\64bit\AX09SP1-Capital-TEST.axc"); Application.DoEvents(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Don't Panic!"); } |
Posted in C# Development
Comments Off on AX BC- Log On


