Search Chirayu Software Solutions Blog

Monday, September 30, 2013

Link to Free MySQL Edition

Saturday, September 28, 2013

Yes or No confirm box using jQuery

                    .html('<div><h6>Are you sure?</h6></div>')
                        modal: true, title: 'Delete message', zIndex: 10000, autoOpen: true,
                        width: 'auto', resizable: false,
                        buttons: {
                            Yes: function () {
                                // $(obj).removeAttr('onclick');                                
                                // $(obj).parents('.Parent').remove();

                            No: function () {
                        close: function (event, ui) {

NewLine in C#

Program that uses Environment.NewLine: C#

using System;

class Program
    static void Main()
 // Use string concat to combine two literals
 // with the newline constant.
 string s = "First line" +
     Environment.NewLine +
     "Second line";


First line
Second line

convert dataset into csv file

Code Snippet
Dim str As New StringBuilder
For Each dr As DataRow In Me.NorthwindDataSet.Customers
     For Each field As Object In dr.ItemArray
     str.Append(field.ToString & ",")
     str.Replace(",", vbNewLine, str.Length - 1, 1)

     My.Computer.FileSystem.WriteAllText("C:\temp\testcsv.csv", str.ToString, False)
Catch ex As Exception
     MessageBox.Show("Write Error")

End Try

Thursday, September 26, 2013

check if a program is already running in c#

 if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1)
                //application is already running
                MessageBox.Show("Cannot start,  please close it before starting again");


run an external program in c#

using System.Diagnostics;

class Program
    static void Main()
 // Use Process.Start here.

Getting Date only from a DateTime Object

DateTime date1 = new DateTime(2008, 6, 1, 7, 47, 0);

// Get date-only portion of date, without its time.
DateTime dateOnly = date1.Date;
// Display date using short date string.
// Display date using 24-hour clock.
Console.WriteLine(dateOnly.ToString("MM/dd/yyyy HH:mm"));   
// The example displays the following output to the console: 
//       6/1/2008 7:47:00 AM 
//       6/1/2008 
//       6/1/2008 12:00 AM 
//       06/01/2008 00:00

How to identify if a string is a number?

This will return true if input is all numbers. Don't know if it's any better than TryParse, but it will work.
Regex.IsMatch(input, @"^\d+$")
If you just want to know if it has one or more numbers mixed in with characters, leave off the ^ + and$.
Regex.IsMatch(input, @"\d")
Edit: Actually I think it is better than TryParse because a very long string could potentially overflow TryParse.