Posts

Showing posts from July, 2007

Crystal Report Formula - ToWords - Remove 'xx/100' the trailing string.

Left(ToWords(Sum ({YourTable.Field})), InStr(ToWords(Sum ({YourTable.Field})), " and ")) & " and " & ToWords(ToNumber (Right(ToText(Sum ({YourTable.Field})), 2 )), 0) & " cents."

LPAD in T-SQL and Crystal Report Formula

I am sure there should have some neater ways to do this but if all you need are just working version, here it goes. T-SQL REPLICATE('0', 8 - LEN(LTRIM(STR(YourTableField)))) + LTRIM(STR(YourTableField)) Crystal Report Formula StringVar Message := ""; StringVar Num := {YourCrystalReportTable.Field}; Num := Trim (Num); NumberVar Counter := 8 - Length(Num) ; While (Counter > 0) do ( Message := Message & "0"; Counter := Counter - 1; ); Message := Message & Num

Workflow in ASP.NET

Same codes except placing static variable static WorkflowRuntime wr = new WorkflowRuntime(); in Application_Start of global.asax then (quoted from MSLearning) If you use the WorkflowWebRequestContext object to access the workflow runtime, you cannot add services such as persistence or scheduling services because the workflow is already started. If you try to add services to the runtime when it has already started it will generate an error. Instead, to configure the runtime with services, use the <workflowRuntime> section in the Web.config file: [Web.config] <configuration> <configSections> <section name="WorkflowRuntime" type="WorkflowRuntimeSection, System.Workflow.Runtime" /> </configSections> </configuration>

Host Workflow in .NET WinForm

Add reference to - System.Workflow.Activities - System.Workflow.Runtime - System.Workflow.ComponentModel - <the MyWorkflow assembly> in the WinForm codes, add member variable WorkflowRuntime myWorkflowRuntime = new WorkflowRuntime() Then, in the constructor of the winform. //setup event handler myWorkflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArg>(wr_WFCompleted); myWorkflowRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArg>(wr_WFTerminated); //handler for the workflow thread. void wr_WFCompleted(object sender, WorkflowCompletedEventArg e) { MessageBox.Show("Workflow output" + e.OutputParameters["Field"].ToString()); } //to kick start the work flow thread. Type type = typeof(MyNamespace.MyWorkflow); //to pass parameter to the workflow thread. Dictionary<string, object> param = Dictionary<string, object>; param.Add("Field", System.Convert.ToInt32(123)); WorkflowInst

WPF sample

(Nothing new, codes taken from MSLearning) <Application x:Class="MyApp" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml"> Startup="MyApp_Startup" Activated="MyApp_Activated" Deactivated="MyApp_Deactivated" SessionEnding="MyApp_SessionEnding" Exit="MyApp_Exit" </Application> C# public class MyApp : Application { StackPanel rootPanel; Window win; protected override void OnStartup(StartupEventArgs e) { win = new System.Windows.Window(); rootPanel = new StackPanel(); win.Content = rootPanel; win.Show(); } void MyApp_Startup (object sender, StartupEventArgs e) { //singleton model and where sharing information pages uses Properties. MyApp.Current.Properties["TextFromPage1"] = txtBox.Text; // Retrieve the

Hosting WPF (Avalon Control) in WinForm quick info

Though this code snippet already available in the Win SDK sample. //the host should be a private member variable. ElementHost host = new ElementHosy(); host.Dock = DockStyle.Fill; myPanel.Controls.Add(host); //adding the control the panel control in the winform. //the variable datatype available after added reference //to the WPF/Avalon control and WPF namespace) avControl = new MyNamespace.MyAVControl(); avControl.InitializeComponent(); host.Child = avControl; //control has been linked to the winform //The RoutedEventHandler is used because the WPF in this case is a //child control. There are 3 type of event routing namely direct, tunnel and bubble. //refer http://msdn2.microsoft.com/en-us/library/ms742806.aspx#why_use //for more info on the event on WPF. avControl.Loaded += new RoutedEventHandler(avCtrl_Loaded); //To use Avalon control in Win32 which wrap the Avalon control into HwndSource //refer http://blogs.msdn.com/nickkramer/archive/2005/07/17/439659.aspx