05-31-2012 08:46 AM - edited 05-31-2012 08:46 AM
Here's the class file for the control.
06-01-2012 01:17 AM
07-25-2013 12:40 AM - edited 07-25-2013 08:07 AM
Here's a simplyfied version of the Control, we use it to create a new Contact with some fields filled with values from a sql-query.
using Act.Framework.Contacts; using Act.Shared.ComponentModel; using Act.UI; using System; using System.Data.SqlClient; using System.Windows.Forms; namespace Act.Configbutton { [ CustomControlAttribute(true), // mark as a custom control LayoutToolboxItemFriendlyName(), // give the control a name ] class Configbutton : Button { private ActApplication ACTapp; public Configbutton() { ACTapp = Act.UI.ActApplication.Instance; this.Click += btn_clicked; } ~Configbutton() { this.Click -= btn_clicked; } private void btn_clicked(object sender, EventArgs de) { SqlConnection sqlConn = new SqlConnection("<your connection string>"); SqlCommand sqlComm = new SqlCommand("<sql query>", sqlConn); Contact c = ACTapp.ActFramework.Contacts.CreateContact(); c.Fields["Department", Act.Framework.MutableEntities.FieldNameType.Alias] = "<dept. to set>"; sqlConn.Open(); SqlDataReader sqlRead = sqlComm.ExecuteReader(); c.Fields["<Fieldname in ACT>", Act.Framework.MutableEntities.FieldNameType.Alias] = sqlRead.Read()?sqlRead[0]:"<Value if empty recordset was returned from reader>"; c.Update(); sqlRead.Close(); sqlRead.Dispose();//don't know if the disposing is neccessary sqlComm.Dispose(); sqlConn.Close(); sqlConn.Dispose(); ACTapp.UIContactManager.ShowContact(c); } public static string LayoutToolboxFriendlyName { get { return "<Give the control a name>"; } } } }