Wednesday, June 16, 2010

How to display arabic numbers in crystal reports

Introduction:
I was working on Arabic Project. And there is an issue to show the Arabic Number display in Crystal Report. I face this issue and i couldn't find a solution for display Arabic numbers in crystal reports so I create a Formula and use Replace function.

Background:
It may be useful for Arabic Number Display on your windows forms / Web forms.

Using the code:
stringVar StrArb := ToText({ROTT.Aux_f_3});

StrArb :=
Replace (StrArb ,"0" , "٠" );
StrArb :=
Replace (StrArb ,"1" ,"١" );
StrArb :=
Replace (StrArb ,"2" ,"٢" );
StrArb :=
Replace (StrArb ,"3" ,"٣" );
StrArb :=
Replace (StrArb ,"4" ,"٤" );
StrArb :=
Replace (StrArb ,"5" ,"٥" );
StrArb :=
Replace (StrArb ,"6" ,"٦" );
StrArb :=
Replace (StrArb ,"7" ,"٧" );
StrArb :=
Replace (StrArb ,"8" ,"٨" );
StrArb :=
Replace (StrArb ,"9" ,"٩" );

This is the easy way to convert Numbers into Arabic Number Display..
:D
Its very easy and useful :)

STEP 1:
CLICK ON FORMULA WORKSHOP ( CREATE FORMULA)






STEP 2:

Enter the Formula Name:

STEP 3:
WRITE THE FORMULA CODE FOR DISPLAY ARABIC NUMBER IN CRYSTAL REPORT
stringVar
StrArb := ToText({ROTT.Aux_f_3});
StrArb :=
Replace (StrArb ,"0" , "٠" );
StrArb :=
Replace (StrArb ,"1" ,"١" ); StrArb := Replace (StrArb ,"2" ,"٢" );
StrArb :=
Replace (StrArb ,"3" ,"٣" );
StrArb :=
Replace (StrArb ,"4" ,"٤" );
StrArb :=
Replace (StrArb ,"5" ,"٥" );
StrArb :=
Replace (StrArb ,"6" ,"٦" );
StrArb :=
Replace (StrArb ,"7" ,"٧" );
StrArb :=
Replace (StrArb ,"8" ,"٨" );
StrArb :=
Replace (StrArb ,"9" ,"٩" ); 1) Save Formula and close the formula workshop window
2) click on Field explorer
3) In
Field explorer drag drop your formula on your report

Monday, June 14, 2010

Data Mining: What is Data Mining?

Data Mining: What is Data Mining?

Introduction

Generally, data mining (sometimes called data or knowledge discovery) is the process of analyzing data from different perspectives and summarizing it into useful information - information that can be used to increase revenue, cuts costs, or both. Data mining software is one of a number of analytical tools for analyzing data. It allows users to analyze data from many different dimensions or angles, categorize it, and summarize the relationships identified. Technically, data mining is the process of finding correlations or patterns among dozens of fields in large relational databases.

Continuous Innovation

Although data mining is a relatively new term, the technology is not. Companies have used powerful computers to sift through volumes of supermarket scanner data and analyze market research reports for years. However, continuous innovations in computer processing power, disk storage, and statistical software are dramatically increasing the accuracy of analysis while driving down the cost.

Example

For example, one Midwest grocery chain used the data mining capacity of Oracle software to analyze local buying patterns. They discovered that when men bought diapers on Thursdays and Saturdays, they also tended to buy beer. Further analysis showed that these shoppers typically did their weekly grocery shopping on Saturdays. On Thursdays, however, they only bought a few items. The retailer concluded that they purchased the beer to have it available for the upcoming weekend. The grocery chain could use this newly discovered information in various ways to increase revenue. For example, they could move the beer display closer to the diaper display. And, they could make sure beer and diapers were sold at full price on Thursdays.

Data, Information, and Knowledge

Data

Data are any facts, numbers, or text that can be processed by a computer. Today, organizations are accumulating vast and growing amounts of data in different formats and different databases. This includes:

  • operational or transactional data such as, sales, cost, inventory, payroll, and accounting
  • nonoperational data, such as industry sales, forecast data, and macro economic data
  • meta data - data about the data itself, such as logical database design or data dictionary definitions

Information

The patterns, associations, or relationships among all this data can provide information. For example, analysis of retail point of sale transaction data can yield information on which products are selling and when.

Sunday, June 13, 2010

Displaying Arabic Number. VB.Net

Displaying Arabic Number.


Imports System.Text

Private Sub Button1_Click
(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Label1.Text = TextBox1.Text
Label3.Text = ConvertToArabicNumerals(TextBox1.Text)


End Sub



Public Function ConvertToArabicNumerals(ByVal input As String) As String


Dim utf8Encoder As System.Text.UTF8Encoding = New UTF8Encoding()

Dim utf8Decoder As System.Text.Decoder = utf8Encoder.GetDecoder()

Dim convertedChars As New System.Text.StringBuilder()

Dim convertedChar As Char() = New Char(0) {}

Dim bytes As Byte() = New Byte() {217, 160}

Dim inputCharArray As Char() = input.ToCharArray()

For Each c As Char In inputCharArray


If Char.IsDigit(c) Then


bytes(1) = Convert.ToByte(160 + Char.GetNumericValue(c))

utf8Decoder.GetChars(bytes, 0, 2, convertedChar, 0)


convertedChars.Append(convertedChar(0))
Else

convertedChars.Append(c)

End If
Next

Return convertedChars.ToString()

End Function

Wednesday, June 09, 2010

ASP.NET / VB.net Calendar Popup with eworldui

ASP.NET / VB.net Calendar Popup with e-world ui

Page Directives:
Calendar 1

<%@ Register TagPrefix="ew" Namespace="eWorld.UI" Assembly="eWorld.UI, Version=1.9.0.0, Culture=neutral, PublicKeyToken=24d65337282035f2" %>

<div>

Calendar 2

<ew:calendarpopup class="tableproptext_az" id="dtExpDate" runat="server" Width="184px" CssClass="tableproptext_az"

ImageUrl="site\images\calendar.png" Height="20px" Font-Names="Tahoma,Arial" ControlDisplay="TextBoxImage"

widht="200">

<WeekdayStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="Black" BackColor="White">WeekdayStyle>

<MonthHeaderStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="White" BackColor="Green">MonthHeaderStyle>

<OffMonthStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="Gray" BackColor="AntiqueWhite">OffMonthStyle>

<GoToTodayStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="Black" BackColor="White">GoToTodayStyle>

<TodayDayStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="Black" BackColor="Pink">TodayDayStyle>

<DayHeaderStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="White" BackColor="Navy">DayHeaderStyle>

<WeekendStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="Black" BackColor="LightGray">WeekendStyle>

<SelectedDateStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="White" BackColor="Green">SelectedDateStyle>

<ClearDateStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="Black" BackColor="White">ClearDateStyle>

<HolidayStyle Font-Size="X-Small" Font-Names="Tahoma,Arial" ForeColor="Black" BackColor="White">HolidayStyle>

ew:calendarpopup>

div>



Reff: www.eworldui.net

Download Link:

Download DLL for calendar popup


------------------------
A demo for this control is located here: View Demo
Download
Download!
You can download the installation files by clicking here. Remember, if you have downloaded another component, you do not need to download this one. They are all apart of the same assembly. Also, you have the option of downloading the .NET 1.0, .NET 1.1, .NET 2.0, or .NET 3.5 assemblies, however while .NET 1.0 and .NET 1.1 are in synch with each other, the 2.0 and 3.5 assemblies have much more vast functionality contained within them.

Download Now!

Tuesday, June 08, 2010

Tanhai --- Singer Lucky Ali

Tanhai --- Singer Lucky Ali






Lyrics

TANHAI HA ......
KASI ROOT AAI HA
JOODA HO JAAON MA
-----------------
AAGAB UA AAFSANA
KESYA KEYA BAATLANA
SUMHAJ NA AAYA
-----------------
HER AIK DIL MA RAHTI HA
JAAYSA AARMAN KOI

VB.NET Strings with Padding

Padding Strings.

PadRight and PadLeft string with vb,net

The PadLeft and PadRight methods can be used to pad strings. The PadLeft method right-aligns and pads a string so that its rightmost character is the specified distance from the beginning of the string. The PadRight method left-aligns and pads a string so that its rightmost character is a specified distance from the end of the string. These methods return new String objects that can either be padded with empty spaces or with custom characters. Listign 3 shows how to use these methods.

Listing 3. Using padding methods.

Dim strOutput As String
Dim str1 As String = "My String"
strOutput = (str1.PadLeft(20, "-"))
Dim str2 As String = "My String"
strOutput = (str2.PadRight(20, "-"))

===================================
Output

-------------------My String
My String-------------------

================================

Working with Strings in .NET using VB.NET

.NET Framework library provides classes to work with strings and these classes are common to all .NET language including C# and VB.NET. In this tutorial, I will discuss how to use these classes to work with strings using VB.NET.

Comparing Strings.

The Compare method compares two strings and returns an integer value. The return value of Compare method can be less than zero, greater than zero or equals to zero.

Value Meaning.

Less than zero When first string is less than second.
Zero When both strings are equal.
Greater than zero When first string is greater than zero.

The following code compares two strings and return results on the System console.

' Comparing two strings
'===============================================
Dim str1 As String = "ppp"
Dim str2 As String = "ccc"
Dim res As Int16 = String.Compare(str1, str2)
Console.WriteLine("First result:" + res.ToString())
str2 = "ttt"
res = String.Compare(str1, str2)
Console.WriteLine("Second result:" + res.ToString())
str1 = "ttt"
res = String.Compare(str1, str2)
Console.WriteLine("Third result:" + res.ToString())
'===============================================

The CompareTo method is an instance method. It compares a value (either a string or on object) with a string instance. Return values of this method are same as the Compare method. The following source code compares two strings.

' CompareTo Method
Dim str As String = "kkk"
Console.WriteLine(str.CompareTo(str1))

Copy and Concatenating Strings.

The Concat method adds strings (or objects) and returns a new string. Using Concat method, you can add two strings, two objects and one string and one object or more combinations of these two.

The following source code concatenate two strings.

Dim str1 As String = "ppp"
Dim str2 As String = "ccc"
Dim strRes As String = String.Concat(str1, str2)
Console.WriteLine(strRes)

The following source code concatenates one string and one object.

Dim obj As Object = 12
strRes = String.Concat(str1, obj)
Console.WriteLine(strRes)

The Copy method copies contents of a string to another. The Copy method takes a string as input and returns another string with the same contents as the input string. For example, the following code copies str1 to strRes.

strRes = String.Copy(str1)
Console.WriteLine("Copy result :" + strRes)

The CopyTo method copies a specified number of characters from a specified position in this instance to a specified position in an array of characters. For example, the following example copies contents of str1 to an array of characters. You can also specify the starting character of a string and number of characters you want to copy to the array.

Dim str1 As String = "pp"
Dim chrs(2) As Char
str1.CopyTo(0, chrs, 0, 2)
Console.WriteLine(chrs(0) + chrs(1))

The Clone method returns a new copy of a string in form of object. The following code creates a clone of str1.

Dim str1 As String = "ppp"
Dim objClone As Object = str1.Clone()
Console.WriteLine("Clone :" + objClone.ToString())

The Join method is useful when you need to insert a separator (String) between each element of a string array, yielding a single concatenated string. For example, the following sample inserts a comma and space (", ") between each element of an array of strings.

Dim str1 As String = "ppp"
Dim str2 As String = "ccc"
Dim str3 As String = "kkk"
Dim allStr() As String = New String() {str1, str2, str3}
Dim strRes As String = String.Join(", ", allStr)
Console.WriteLine("Join Results: " + strRes)

Adding, Removing and Replacing Strings.

The Insert method inserts a specified string at a specified index position in an instance. For example, the following source code inserts "bbb" after second character in str1 and the result string is "pbbbpp".

Dim str1 As String = "ppp"
Dim strRes As String = str1.Insert(2, "bbb")
Console.WriteLine(strRes.ToString())

The Remove method deletes a specified number of characters from a specified position in a string. This method returns result as a string. For example, the following code removes three characters from index 3.

Dim s As String = "123abc000"
Console.WriteLine(s.Remove(3, 3))

The Replace method replaces all occurrences of a specified character in a string. For example, the following source code replaces all p character instances of str1 with character l and returns string "lll".

Dim str1 As String = "ppp"
Dim repStr As String = str1.Replace("p", "l")
Console.WriteLine("Replaced string:" + repStr.ToString())

The Split method separates strings by a specified set of characters and places these strings into an array of strings. For example, the following source code splits strArray based on ',' and stores all separated strings in an array.

Dim str1 As String = "ppp"
Dim str2 As String = "ccc"
Dim str3 As String = "kkk"
Dim strAll3 As String = str1 + ", " + str2 + ", " + str3
Dim strArray() As String = strAll3.Split(",")

Uppercase and Lowercase.

The ToUpper and ToLower methods convert a string in uppercase and lowercase respectively. These methods are easy to use. The following code shows how to use ToUppler and ToLower methods.

Dim aStr As String = "adgas"
Dim bStr As String = "ABNMDWER"
Dim strRes As String = aStr.ToUpper()
Console.WriteLine("Uppercase:" + strRes.ToString())
strRes = bStr.ToLower()
Console.WriteLine("Lowercase:" + strRes.ToString())

Formatting Strings.

You can use the Format method to create formatted strings and concatenate multiple strings representing multiple objects. The Format method automatically converts any passed object into a string.

For example, the following code uses integer, floating number and string values and format them into a string using the Format method.

Listing 1. Using Format method to format a string.

Dim val As Int16 = 7
Dim name As String = "Mr. John"
Dim num As Double = 45.06F
Dim str As String = String.Format("Days Left : {0}. Current DataTime: {1:u}. \n String: {2}, Float: {3}", val, DateTime.Now, name, num)
Console.WriteLine(str)



Trimming and Removing Characters from Strings.

The String class provides Trim, TrimStart and TrimEnd methods to trim strings. The Trim method removes white spaces from the beginning and end of a string. The TrimEnd method removes characters specified in an array of characters from the end of a string and TrimStart method removes characters specified in an array of characaters from the beginning of a string.

You can also use the Remove method to remove characters from a string. The Listing 2 code shows how to use these methods.

Dim str As String = " C# "
Console.WriteLine("Hello{0}World!", str)
Dim trStr As String = str.Trim()
Console.WriteLine("Hello{0}World!", trStr)
str = "Hello World!"
Dim chArr() As Char = {"e", "H", "l", "o", " "}
trStr = str.TrimStart(chArr)
Console.WriteLine(trStr)
str = "Hello World!"
Dim chArr1() As Char = {"e", "H", "l", "o", " "}
trStr = str.TrimEnd(chArr1)
Console.WriteLine(trStr)
Dim MyString As String = "Hello Delta World!"
Console.WriteLine(MyString.Remove(5, 10))

Padding Strings.

The PadLeft and PadRight methods can be used to pad strings. The PadLeft method right-aligns and pads a string so that its rightmost character is the specified distance from the beginning of the string. The PadRight method left-aligns and pads a string so that its rightmost character is a specified distance from the end of the string. These methods return new String objects that can either be padded with empty spaces or with custom characters. Listign 3 shows how to use these methods.

Listing 3. Using padding methods.

Dim str1 As String = "My String"
Console.WriteLine(str1.PadLeft(20, "-"))
Dim str2 As String = "My String"
Console.WriteLine(str2.PadRight(20, "-"))

The output of Listing 3 is shown in Number 2

Output

----------My String
My String----------

Using StringBuilder Class.

The StringBuilder class represents a mutable string of characters. It's called mutable because it can be modified once it has been created by using Append, Insert, Remove, and Replace methods.

Note: When there are multiple concatenation operations are involved with strings, for performance reasons it is recommended to use StringBuilder instead of String.

The StringBuilder class is defined in the System.Text namespace. Before you use the StringBuilder class make sure you add the following line in your application:

imports System.Text

Table 2 describes the StringBuilder class properties.

Property Description
Capacity Represents the maximum number of characters that can be contained in the memory allocated by the current instance.
Chars Represens the character at the specified position.
Length Represents the number of characters.
MaxCapacity Returns the maximum capacity.

Table 2. The StringBuilder class properties.

Table 3 describes the StringBuilder class methods.

Method Description
Append Appends a string at the end of this string.
AppendFormat Appends a formatted string.
EnsureCapaciry Ensures that the capacity of string is as specified value.
Inserts Inserts string at the specified position.
Remove Removes a range of characters from the string.
Replace Replaces all occurrences of a character from the string.

Table 3. The StringBuilder class methods.

Using StringBuilder properties and methods is pretty simple. Listing 4 uses StringBuilder class to append, insert, remove and replace characters of a string.

Listing 4. Using StringBuilder class to append, add, replace and remove characters.

Dim builder As StringBuilder = New StringBuilder("Hello C# World!", 20)
Dim cap As Int16 = builder.EnsureCapacity(55)
builder.Append(". This is a class test.")
Console.WriteLine(builder)
builder.Insert(26, " String Builder")
Console.WriteLine(builder)
builder.Remove(5, 9)
Console.WriteLine(builder)
builder.Replace("!", "?")
Console.WriteLine(builder)
Console.WriteLine("Length of string is:" + builder.Length.ToString())
Console.WriteLine("Capacity of string is:" + builder.Capacity.ToString())

Count the Characters in a Text Area Example

In forms when using text boxes or text areas with limited character length (usually needed for forms that submit data to a database) it is always a good idea to tell the user how many characters they have remaining. This javascript snippet is especially useful for textarea fields since they can't be assigned a text limit in HTML but can be restricted using this code.

The following example shows how you can do this. This is a very simple and cute idea to help the user know exactly how many characters can be typed further. Do these small add-ons to your forms and they will look really professional. We recommend using this counter inside CMS solutions and custom built Admin Panels where your clients/visitors can be instructed to use all browsers like IE, Opera, FireFox, Netscape or Safari.

Java script






HTML CODE

Maximum Number of characters for this text box is 255.





You have 255 characters remaining
for your description...

Tuesday, June 01, 2010

Sql Server Get Current Year

SELECT CURRENT_TIMESTAMP as CurrentDateTime

Result


CurrentDateTime

1

2010-06-01 15:19:18.653



SELECT year (getdate()) as Year


Year

1

2010




SELECT right(year(getdate()),2) as year


CurrentDateTime

1

10




There are three ways to retrieve the current datetime in SQL SERVER.
CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}

CURRENT_TIMESTAMP
CURRENT_TIMESTAMP is a nondeterministic function. Views and expressions that reference this column cannot be indexed. CURRENT_TIMESTAMP can be used to print the current date and time every time that the report is produced.

GETDATE()
GETDATE is a nondeterministic function. Views and expressions that reference this column cannot be indexed. GETDATE can be used to print the current date and time every time that the report is produced.

{fn Now()}
The {fn Now()} is an ODBC canonical function which can be used in T-SQL since the OLE DB provider for SQL Server supports them. {fn Now()} can be used to print the current date and time every time that the report is produced.

If you run following script in Query Analyzer. I will give you same results. If you see execution plan there is no performance difference. It is same for all the three select statement.
SELECT CURRENT_TIMESTAMP
GO
SELECT {fn NOW()}
GO
SELECT GETDATE()
GO