Posts

Register winform app HotKeys - C#

Image
Hotkey is a very useful shortcut for complex application. Sometimes we build application with much feature include in it hence will result of bad experience of end user because the feature dont have the shortcut keys. Here is a sample to add shortcut keys or hotkeys for winform app in C# code. GlobalHotkeys.cs using System; using System.Windows.Forms; using System.Runtime.InteropServices; namespace Hotkeys {     public class GlobalHotkey     {         private int modifier;         private int key;         private IntPtr hWnd;         private int id;         public GlobalHotkey(int modifier, Keys key, Form form)         {             this.modifier = modifier;             this.key = (int)key;             this.hWnd = form.Handle;             id = this.GetHashCode();         }         public bool Register()         {             return RegisterHotKey(hWnd, id, modifier, key);         }         public bool Unregiser()         {             return UnregisterHotKey(hWnd, id);         }      

Get each table size in mssql database

This is the snippet to get each table size in the schema/catalogue database. MSSQL Code SELECT     t.NAME AS TableName,     s.Name AS SchemaName,     p.rows AS RowCounts,     SUM(a.total_pages) * 8 AS TotalSpaceKB,     SUM(a.used_pages) * 8 AS UsedSpaceKB,     (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB FROM     sys.tables t INNER JOIN         sys.indexes i ON t.OBJECT_ID = i.object_id INNER JOIN     sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id INNER JOIN     sys.allocation_units a ON p.partition_id = a.container_id LEFT OUTER JOIN     sys.schemas s ON t.schema_id = s.schema_id WHERE     t.NAME NOT LIKE 'dt%'     AND t.is_ms_shipped = 0     AND i.OBJECT_ID > 255 GROUP BY     t.Name, s.Name, p.Rows ORDER BY     t.Name By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

How to "PUT" and "GET" queue item IBM WebSphere Queue - C#

This is example C# code how to insert value into IBM WebSphere  Queue, and Get The Queue value back. You can use Queue to store some information to processed later without involve database. You can read more about IBM WebSphere queue in here Put Message C# Code MQQueueManager queueManager;             MQQueue queue;             MQMessage queueMessage;             MQPutMessageOptions queuePutMessageOptions;             MQGetMessageOptions queueGetMessageOptions;             string ChannelInfo;             string channelName;             string transportType;             string connectionName;             //get channel info             char[] separator = { '/' };             string[] ChannelParams;             ChannelInfo = "CHANNEL3/TCP/172.19.37.2";             ChannelParams = ChannelInfo.Split(separator);             channelName = ChannelParams[0];             transportType = ChannelParams[1];             connectionName = ChannelParams[2];             //g

How to get user name of logon windows user.

This Code shows how to get user name of log on windows user. Here is the code : C# Code  string a; a = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(); MessageBox.Show(a.ToString()); By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

How to specify WhereCondition in Transformation - Nested Control - kentico 8, 7, 6

Image
Before this i wonder how to pass some where condition in transformation repeater. So i ask the kentico guys and he give me a solution which i think i can share to the others. So in your transformation you can specify the <script runat="server"></script> element. This is where you can pass the where condition. Let see the example : Transformation Code <cms:queryrepeater id="repItems" ... DelayedLoading="true" ... /> <script runat="server"> protected void Page_PreRender(object sender, EventArgs e) { queryrepeater.WhereCondition= "NodeAliasPath LIKE '"+(string)Eval("NodeAliasPath")+"'"; queryrepeater.ReloadData(true); } </script> Note : queryrepeater dont have DelayedLoading properties, use DataBindByDefault="false" instead. By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites

Update Panel - Handle async partial-page state with client script

This is a sample script you can put at the master page. So that you dont need to have updatepanel progress every time you add the update panel in you aspx page. Script  <div id="pageUpdating"></div>     <script type="text/javascript">         Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);         function BeginRequestHandler(sender, args) {             //page is begin request, you can put code to lock screen etc.               writePageLoading();         }         Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler)         function endRequestHandler(sender, args) {             //page load successfully , end request               RemoveLoading();             if (args.get_error() != undefined && args.get_error().httpStatusCode == '500') {                 //if have error                 var errorMessage = args.get_error().message;                 alert(errorMessage + &qu

Who is connected to database - Sample Application C#

Image
This is a sample application just to show who is currently connected into database MSSQL. The application actually just execute MSSQL command " sp_who " and show the data into datagrid. Below is a screen shoot of the sample application. Code Behind View Who Is Connected Form          public Form1()         {             InitializeComponent();         }         private void button2_Click(object sender, EventArgs e)         {             this.Close();         }         private void button1_Click(object sender, EventArgs e)         {             string ipaddress = textBox1.Text;             string username = textBox2.Text;             string password = textBox3.Text;             string dbNAme = textBox4.Text;             ViewUserActive form = new ViewUserActive();             form.popupInformation(ipaddress, username, password, dbNAme);                }         private void Form1_Load(object sender, EventArgs e)         {                  } Code Behind ViewUserActive Form