RSS

Convert Simple Number to Arabic Number.


You can use this code both Web & Desktop Application.

Code 1: the HTML code:

<form id=”form1″ runat=”server”>

<asp:TextBox ID=”txtNumber” runat=”server”></asp:TextBox>

<br />

<asp:Label ID=”lblmsg” runat=”server”></asp:Label>

<br />

<asp:Button ID=”btnConvert” runat=”server” Text=”Convert to Arabic” />

</form>

 

Code 2: Code Behind

 

Protected Sub btnConvert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

 

‘Call Function

Me.lblmsg.Text = “Arabic Number : <b>” & TranslateNumerals(Me.txtNumber.Text.Trim) & “</b>”

End Sub

 

 

Public Shared Function TranslateNumerals(ByVal sIn As String) As String

 

Dim enc As New System.Text.UTF8Encoding

 

Dim utf8Decoder As System.Text.Decoder

 

utf8Decoder = enc.GetDecoder

 

Dim sTranslated = New System.Text.StringBuilder

 

Dim cTransChar(1) As Char

 

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

 

‘ Start Converting characters into Arabic mode.

 

Dim aChars() As Char = sIn.ToCharArray

 

For Each c As Char In aChars

 

If Char.IsDigit(c) Then

 

bytes(1) = 160 + CInt(Char.GetNumericValue(c))

 

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

 

sTranslated.Append(cTransChar(0))

 

Else

 

sTranslated.Append(c)

 

End If

 

Next

 

TranslateNumerals = sTranslated.ToString

 

End Function

 

 

After you run the page, enter some English number and then click “Convert to Arabic” button to display the entered number in Arabic number mode.

picArabicNo2

Advertisements
 
Leave a comment

Posted by on October 2, 2014 in Vb.Net

 

Tags: ,

Split string on multiple delimited pass function sql


In This Article , i will write function that  split the string based onmultiple delimiters pass  and also remove the Extra spaces around the string.

--Create this user deinfed function.
 
CREATE FUNCTION dbo.[UDF_Split_String_On_Multiple_Delimiters]
(
      @String VARCHAR(MAX),  -- Variable for string
      @delimiter VARCHAR(50) -- Delimiter in the string
)
RETURNS @Table TABLE(        --Return type of the function
Splitcolumn VARCHAR(MAX)
)
BEGIN
 
        DECLARE @Xml AS XML
        DECLARE @REVISED_STRING VARCHAR(MAX)
 
        ;WITH N1 (n) AS (SELECT 1 UNION ALL SELECT 1),
        N2 (n) AS (SELECT 1 FROM N1 AS X, N1 AS Y),
        N3 (n) AS (SELECT 1 FROM N2 AS X, N2 AS Y),
        N4 (n) AS (SELECT ROW_NUMBER() OVER(ORDER BY X.n)
        FROM N3 AS X, N3 AS Y)
 
        SELECT @REVISED_STRING=STUFF((SELECT '' + (Case When
                PATINDEX('%[' + @delimiter + ']%',SUBSTRING(@String,Nums.n,1)) >0
                Then ',' else LTRIM(RTRIM(SUBSTRING(@String,Nums.n,1))) end)
        FROM N4 Nums WHERE Nums.n<=LEN(@String)  FOR XML PATH('')),1,0,'')
 
        SET @Xml = cast(('<a>'+replace(@REVISED_STRING,
                ',','</a><a>')+'</a>') AS XML)
 
        INSERT INTO @Table SELECT A.value('.', 'varchar(max)')
                as [Column] FROM @Xml.nodes('a') AS FN(a)
 
RETURN
END
GO
 
Call Function (One way)
 
 SELECT * FROM dbo.[UDF_Split_String_On_Multiple_Delimiters] (String , multiple delimiter)
SELECT * FROM dbo.[UDF_Split_Based_On_Multiple_Delimiters]
('sajjad,ahmed ; waleed; Ali',',;:')
 
Call Function(Second Way)
 
 SELECT * FROM dbo.[UDF_Split_String_On_Multiple_Delimiters] (String , multiple delimiter)
SELECT * FROM dbo.[UDF_Split_Based_On_Multiple_Delimiters]
('sajjad[}]ahmed [}] waleed[}]Ali','[}]')
GO
 
 
Leave a comment

Posted by on July 23, 2014 in SQL Query

 

Tags:

Devexpress Gridview RepositoryItemCheckEdit changes immediatelly


If you have a Gridview with the first column edited with an RepositoryItemCheckEdit and with the datasource an runtime created datatable.
What I want to obtain and I not succeeded yet is to count the rows from the datatable with check on the first column and put the result in a labelimmediatelly after user changes check state of repository.

but if you check/Uncheck checkbox   RepositoryItemCheckEdit  Event then your Count not match with Gridview Checkbox.if you use different event of Gridview . the solution of your problem is..

[VB.NET]
Private Sub repositoryItemCheckEdit1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
    gridView1.PostEditor()
    CountChecked()
End Sub

The PostEditor method posts the edited value to the underlying source. I’ve attached a sample demonstrating how it works. Please test it and let us know your result.

the CountChecked method as follows:

[VB.NET]
Private Sub CountChecked()
    Dim checkedCount As Integer = 0
    Dim dt As DataTable = CType(gridControl1.DataSource, DataTable)
    For i As Integer = 0 To dt.Rows.Count - 1
        If CBool(dt.Rows(i)("Check")) Then
            checkedCount += 1
        End If
    Next i
    labelControl1.Text = "Checked: " & checkedCount.ToString()
End Sub

Reference :

https://www.devexpress.com/Support/Center/Question/Details/Q583442

 

 

 

 

 

 

 
1 Comment

Posted by on July 4, 2014 in WinForm

 

Tags: ,

Disable Textbox Paste Option in Winform


If you want to disable paste option on text box in Winform Application then this code very helpful for you.

Vb.Net
Private Sub txtbarcode_KeyDown(sender As Object, e As KeyEventArgs) Handles txtArabicName.KeyDown

If e.Control And e.KeyValue = 86 Then
e.Handled = True
e.SuppressKeyPress = True
End If
End Sub

 C#

private void txtbarcode_KeyDown(object sender, KeyEventArgs e)
{
	if (e.Control & e.KeyValue == 86) {
		e.Handled = true;
		e.SuppressKeyPress = true;


	}
}
 
Leave a comment

Posted by on May 27, 2014 in WinForm

 

Tags: , ,

How to disable the default Context Menu devexpress


If you want to Hide context menu on specific TextBoxt (Devexpress) Control then use this following Code,Write this code on Form Load Event

C#: 

ContextMenu emptyMenu = new ContextMenu();

this.components.Add(emptyMenu);

txtBardcode.Properties.ContextMenu = emptyMenu;

 VB.Net

 
Dim emptyMenu As New ContextMenu()

Me.components.Add(emptyMenu)

txtBardcode.Properties.ContextMenu = emptyMenu

 

 

 

ContextMenu

 
Leave a comment

Posted by on May 27, 2014 in WinForm

 

Tags: , ,

Multiple GET methods in ASP.NET Web API


The default  controller web api gives you has the following pattern The built in GET,POST,PUT convention that web API.supports .I have found to support extra GET methods and support the normal REST methods as well.

public class MyController : ApiController
    {
        // GET api/test
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }
 
        // GET api/test/5
        public string Get(int id)
        {
            return "value";
        }
 
        // POST api/test
        public void Post([FromBody]string value)
        {
        }
 
        // PUT api/test/5
        public void Put(int id, [FromBody]string value)
        {
        }
 
        // DELETE api/test/5
        public void Delete(int id)
        {
        }
    }

the Problems start  when you want to define more than one  “GET” method that goes by a different name.which always get one method & give Error.

  public class MyController : ApiController
    {
        // GET api/test
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }
 
        // GET api/test/GetAllWithFilter
        [HttpGet]
        public IEnumerable<string> GetAllWithFilter()
        {
            return new string[] { "value1"};
        }
 
        // GET api/test/5
        public string Get(int id)
        {
            return "value";
        }
 
        // POST api/test
        public void Post([FromBody]string value)
        {
        }
 
        // PUT api/test/5
        public void Put(int id, [FromBody]string value)
        {
        }
 
        // DELETE api/test/5
        public void Delete(int id)
        {
        }
    }

This shouldn’t be that hard to fix on the surface but the built in route that enables this convention.I searched around for a while to figure out how to solve this then finally ran across a great Stackoverflow post here that nails it and http://lonetechie.com/2013/03/04/fixing-multiple-actions-were-found-that-match-the-request-aspnet-webapi/.

Replace your built in route in WebApiConfig with this (updated for latest release).

 config.Routes.MapHttpRoute("DefaultApiWithId", "api/v1/{controller}/{id}",
 new{ id = RouteParameter.Optional}, new{ id =@"\d+"}); 

config.Routes.MapHttpRoute("DefaultApiWithAction", "api/v1/{controller}/{action}"); 

config.Routes.MapHttpRoute("DefaultApiGet", "api/v1/{controller}",
 new{ action ="Get"}, new{ httpMethod =new HttpMethodConstraint(HttpMethod.Get)}); 

config.Routes.MapHttpRoute("DefaultApiPost", "api/v1/{controller}",
 new{ action ="Post"}, new{ httpMethod =new HttpMethodConstraint(HttpMethod.Post)});

 config.Routes.MapHttpRoute("DefaultApiPut", "api/v1/{controller}", 
new{ action ="Put"}, new{ httpMethod =new HttpMethodConstraint(HttpMethod.Put)}); 

config.Routes.MapHttpRoute("DefaultApiDelete", "api/v1/{controller}", 
new{ action ="Delete"}, new{ httpMethod =new HttpMethodConstraint(HttpMethod.Delete)});

 


 
Leave a comment

Posted by on May 21, 2014 in MVC, Web API

 

Tags: ,

Add custom Code in Mysql Table Column Using Query


if you face problem like that then this code very helpful for you and save your lot of time.

Example: if you want to add Table Unique code after data Enter and you want to inter unique code in sequence with custom code type then use this way.i added image for your help to understand.

After Alter to add new Column with the name of locationCode then you first run this query for number sequence

SET@rank:=0;update T
set Number=@rank:=@rank+1

My Code:

SET @rank:=0;
update location
set LocationCode=@rank:=@rank+1

After Execute this code table column appear Value in Number sequence.if you set custom code type then..


UPDATE Table SET Column= Concat('0', Column);

MyCode: 


update location
set LocationCode=Concat('LOC-', LocationCode)



Add custom Secuance With Query



 

 

 
Leave a comment

Posted by on April 14, 2014 in My SQL

 

Tags: ,