Monday, November 5, 2012

change RadGrid Telrik Control Filter Globalization Text

the function to change filter Text to be in arabic language for radGrid Control
Imports Telerik.Web.UI
Public Sub ChangeRadGridFilterText()
        Dim Menu As GridFilterMenu = RadGrid1.FilterMenu
        Dim item As RadMenuItem
        For Each item In Menu.Items

            Select Case item.Text

                Case "NoFilter"
                    item.Text = "كل العناصر بدون تصفية"
                Case "Contains"
                    item.Text = "يحتوي على"
                Case "DoesNotContain"
                    item.Text = "لا يحتوي على"
                Case "StartsWith"
                    item.Text = "يبدأ ب "
                Case "EndsWith"
                    item.Text = "ينتهي ب "
                Case "EqualTo"
                    item.Text = "يساوي قيمة "
                Case "NotEqualTo"
                    item.Text = "لا يساوي قيمة "
                Case "GreaterThan"
                    item.Text = "أكبر من  "
                Case "LessThan"
                    item.Text = "أقل من  "
                Case "GreaterThanOrEqualTo"
                    item.Text = "أكبر من أو يساوي  "
                Case "LessThanOrEqualTo"
                    item.Text = "أقل من أو يساوي  "
                Case "Between"
                    item.Text = "بين رقمين "
                Case "NotBetween"
                    item.Text = "ليس بين رقمين "
                Case "IsEmpty"
                    item.Text = "قيمة فارغ  "
                Case "NotIsEmpty"
                    item.Text = "ليس قيمة فارغة  "
                Case "IsNull"
                    item.Text = "يساوي Null "
                Case "NotIsNull"
                    item.Text = "لا يساوي Null "
            End Select
        Next
    End Sub

Friday, September 7, 2012

set flash in object tag transparent to all page contents such as menues

  <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj2" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
            border="0" width="400px" height="288px" usemap="images/MapStatement.swf">
            <param name="movie" value="images/MapStatement.swf" />
            <param name="quality" value="High" />
            <param name="wmode" value="transparent" />
            <embed src="images/map.swf" pluginspage="http://www.macromedia.com/go/getflashplayer"
                type="application/x-shockwave-flash" name="obj2" width="400px" height="288px"
                wmode="transparent" /></object>



as the example we have wmode property and wmode parameter to affects on flash transparency .



Monday, July 23, 2012

Read Rss feed using vb.net

the following code sample read from Rss Xml File and write file content as html inside iframe in web page .
Imports System.Xml
Imports System.ServiceModel.Syndication

 Sub Press_News_Get()
 
        Try
            Dim ARB As String = Server.MapPath("intranet/Saudi_Press_Agent.xml")
            Dim reader As New XmlTextReader(ARB)
            Dim feed As SyndicationFeed = SyndicationFeed.Load(reader)

            For Each item As SyndicationItem In feed.Items
                Dim NewTitle As String = item.Title.Text
                Dim url As String = item.Links(0).Uri.ToString()
                Dim lnk As New HtmlAnchor
                lnk.InnerHtml = NewTitle
                lnk.HRef = url
                lnk.Target = "_blank"
                ml.Controls.Add(New LiteralControl("<span class=""sep"">وكالة الأنباء السعودية</span>"))
                ml.Controls.Add(lnk)
                ml.Attributes.Add("style", "color:blue;;margin:0px;padding:0px")

                ml.Controls.Add(New LiteralControl("&nbsp;&nbsp;&nbsp;&nbsp;"))
                lnk.Attributes.Add("style", "text-decoration:none;margin:0px;padding:0px")
            Next
 Catch ex As Exception
            Response.Write(ex.Message)
        End Try

    End Sub

Sunday, July 22, 2012

Create Rss Using System.ServiceModel.Syndication

To Create Rss Using System.ServiceModel.Syndication
add reference for the library in your project .

step2: Create your Rss XML using this function sample
Public Function GetNewsRss() As Rss20FeedFormatter
        Dim feed As SyndicationFeed = New SyndicationFeed()
        feed.Authors.Add(New SyndicationPerson("info@mwa.gov.sa"))
        'feed.Categories.Add(New SyndicationCategory("How To Sample Code"))
        feed.Description = New TextSyndicationContent("أخر الاخبار الخاصة بالمديرية العامة للمياه بمنطقة المدينة المنورة")
        feed.Title = New TextSyndicationContent("أخبار المديرية العامة للمياه بمنطقة المدينة المنورة")
        feed.Copyright = New TextSyndicationContent("جميع الحقوق محفوظة لموقع المديرية العامة للمياه بمنطقة المدينة المنورة")
        feed.Links.Add(New SyndicationLink(New Uri("http://www.mwa.gov.sa/index.aspx")))

        Dim objConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("mwa_mwa_gov_saConnectionString").ConnectionString)
        Dim sql As String = "SELECT News.FrontID,News.Headline, News.InnerNews, NewsImage.NImage, News.NImage_ID, News.LinkType, News.MoreLink, News.Headline FROM News LEFT OUTER JOIN NewsImage ON News.NImage_ID = NewsImage.NImage_ID WHERE (News.ShowFront = 'true') ORDER BY News.FColOrder"
        Dim adp As New SqlDataAdapter(sql, objConnection)
        Dim ds As New DataSet
        objConnection.Open()
        adp.Fill(ds)
        objConnection.Close()
        Dim items As New List(Of SyndicationItem)()
        If (ds.Tables(0).Rows.Count > 0) Then
            Dim i As Integer
            For i = 0 To ds.Tables(0).Rows.Count - 1
                Dim NewItem As SyndicationItem = New SyndicationItem( _
                           ds.Tables(0).Rows(i)("Headline").ToString(), _
                           ds.Tables(0).Rows(i)("InnerNews").ToString(), _
                           New Uri("http://www.mwa.gov.sa/News.aspx?ID=" & ds.Tables(0).Rows(i)("FrontID").ToString()), _
                           "New_" & i, _
                            DateTime.Now)
                items.Add(NewItem)

            Next
            feed.Items = items
        End If
        Return New Rss20FeedFormatter(feed)
    End Function

------------------------------------------------------------------------
step3: Response in page load with Rss20FeedFormatter returned from your previous function .

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Clear()
        Response.ContentEncoding = System.Text.Encoding.UTF8
        Response.ContentType = "text/xml"

        Dim rssWriter As XmlWriter = XmlWriter.Create(Response.Output)
        Dim rssFormatter As New Rss20FeedFormatter()
        rssFormatter = GetNewsRss()
        rssFormatter.WriteTo(rssWriter)
        rssWriter.Close()

        Response.End()

    End Sub

Wednesday, June 6, 2012

المستندات المطلوبة لاصدار اقامة مولود - اضافة مولود علي الاقامة

إجراءات طلب إضافة المواليد
 
 
إجراءات إضافة مواليد خارج المملكة :

1. تسديد رسوم تأشيرة الدخول بقيمة 2000 ريال سعودي عبر نظام سداد الالي  . 
2. تقرير طبي بأحد المستشفيات أو المستوصفات المعتمدة (يتم إرسال التقرير آلياً) .
     لمعرفة المستشفيات المعتمدة (إفادةاو كشف التطعيمات . 
3. تعبئة نموذج الطلب باسم الطفل + صورتين (4×6) . 
4. تتم الإضافة خلال 3 شهور حسب ختم الدخول. 
5.  في حالة عدم الاضافة بعد 3 شهور يغرم بموجب المادة 55من نظام الإقامة  
6. أن يكون المولود داخل المملكة أثناء الإضافة.
7. تأمين طبي .
  
إجراءات إضافة مواليد داخل المملكة:

1. احضار جواز سفر مستقل له. 
2. إحضار شهادة ميلاده وصورة منها. 
3. تعبئة نموذج الطلب باسم الطفل + صورتين (4×6) . 
4. في حالة عدم الاضافة بعد سنة من تاريخ الولادة يغرم بموجب المادة 61 من نظام الإقامة.
ملاحظة :
بالنسبة لمواليد داخل المملكة يترتب عليه غرامة قدرها (1000) ريال في حال التأخر عن  الإضافة أكثر من سنة ، أما مواليد خارج المملكة فيترتب عليه غرامة ماليه قدراها (500) ريال  في حال التأخر عن الإضافة أكثر من ثلاثة أشهر من تاريخ الدخول.


http://www.gdp.gov.sa/sites/pgd/ar-SA/Procedures/ForeignProcedures/BornAddition/Pages/default.aspx

Sunday, June 3, 2012

asp.net page clear Textboxes

this function clear All Form Textboxes

    Public Function EmptyTextBoxes(ByVal parent As Control)
        For Each C As Control In parent.Controls
            If TypeOf (C) Is TextBox Then
                CType(C, TextBox).Text = ""
            End If
            If C.HasControls Then
                EmptyTextBoxes(C)
            End If
        Next
    End Function 
 
Calling the function may be in page load or any event need to reset your form on its action 
Calling 
  EmptyTextBoxes(Me
 
 

Saturday, May 5, 2012

asp.net Set Cookie for Client Pc using c#

   public void setCookie()
    {


        if ((chk_remember_me.Checked))
        {
            HttpCookie aCookie = new HttpCookie("mwa_gov_saChatInfo");
            Response.Cookies.Remove("mwa_gov_saChatInfo");
            Response.Cookies.Add(aCookie);
            aCookie.Values.Add("UserName",HttpUtility.UrlEncode(txtName.Value) );
            aCookie.Values.Add("Email", txtEmail.Value );
            aCookie.Expires = DateTime.Now.AddMonths(2);
            Response.Cookies.Add(aCookie);
        }
        else
        {
            HttpCookie cookie = Request.Cookies["mwa_gov_saChatInfo"];
            if (cookie != null)
            {
                HttpCookie aCookie = new HttpCookie("mwa_gov_saChatInfo");
                aCookie.Expires = DateTime.Now.AddMonths(-2);
                Response.Cookies.Add(aCookie);
                chk_remember_me.Checked = false;
            }
        }
    }

Friday, May 4, 2012

vb.net Sql server Query Parametrized Select Statement

This Sample Code Clarify how to call Sql statement using Parameters to Avoid Sql Injection problem

 Dim dsEmails As New DataSet()
Using connection As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("mwa_mwa_gov_saConnectionString").ToString())
 Dim myDataAdapter As New SqlDataAdapter("SELECT [ID], [UserId], [UserName], [FirstName], [FatherName],[GrandfatherName], [FamilyName], [Email], [SubscriptionNo], [MobileNo] From IUSers Where ID=@ID", connection)
                        myDataAdapter.SelectCommand.Parameters.Add("@ID", SqlDbType.Int, 11)
                        myDataAdapter.SelectCommand.Parameters("@ID").Value = Convert.ToInt32(s) 'Request.Cookies("ID").Value)
   myDataAdapter.Fill(dsEmails)
   connection.Close()
   myDataAdapter.Dispose()
 End Using

asp.net Password Validation example

using System;
using System.Text.RegularExpressions;

public void CreateNewUserAccount(string name, string password)
{
    // Check name contains only lower case or upper case letters, 
    // the apostrophe, a dot, or white space. Also check it is 
    // between 1 and 40 characters long
    if ( !Regex.IsMatch(userIDTxt.Text, @"^[a-zA-Z'./s]{1,40}$"))
      throw new FormatException("Invalid name format");

    // Check password contains at least one digit, one lower case 
    // letter, one uppercase letter, and is between 8 and 10 
    // characters long
    if ( !Regex.IsMatch(passwordTxt.Text, 
                      @"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$" ))
      throw new FormatException("Invalid password format");

    // Perform data access logic (using type safe parameters)
    ...
}

Sunday, April 29, 2012

VB.NET Oracle Call Function with Parameters

WHEN we need to call Oracle Database Function from vb.net Code Using System.Data.Oracle Client we will need to Pass Function Parameters and receive Function Return Value

so this action Can be Handled by the following Code Sample
NOTE: I have db function called ENCRYPT_STR S have two input arguments and one output return value so , i declared Oracle Command and define it's type as Stored Procedure and pass command text as SchemaName.FunctionName
then deal with command to add parameters and receive Return value and return it after .
    Public Function EncriptLoginData(ByVal username As String, ByVal EncKey As String) As String
        Dim Result_Encripted As String = String.Empty
                    'define Oracle Command
        Dim cmd As New Data.OracleClient.OracleCommand
        cmd.CommandType = Data.CommandType.StoredProcedure
        cmd.CommandText = "MAIN.ENCRYPT_STR"
        cmd.Connection = OConn
        OConn.ConnectionString = ConnString
        If OConn.State <> ConnectionState.Open Then OConn.Open()
        With cmd
            .Parameters.Add("var1", OracleType.VarChar, 100).Direction = ParameterDirection.Input
            .Parameters.Add("p_key", OracleType.VarChar, 100).Direction = ParameterDirection.Input
            .Parameters.Add("encUserName", OracleType.VarChar, 4000).Direction = ParameterDirection.ReturnValue
            .Parameters("var1").Value = username
            .Parameters("p_key").Value = EncKey

        End With
        cmd.ExecuteScalar()
        Result_Encripted = cmd.Parameters("encUserName").Value.ToString()
        cmd.Dispose()
        OConn.Close()
        OConn.Dispose()
        Return Result_Encripted
    End Function

Saturday, April 28, 2012

get Client Ip Address Using Asp.net c#

to get Client Ip address use the following code
 if (Context.Request.ServerVariables["HTTP_VIA"] != null) // using proxy
                            {
                                                              Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();  // Return real client IP.
                            }
                            else// not using proxy or can't get the Client IP
                            {
                                Context.Request.ServerVariables["REMOTE_ADDR"].ToString(); //While it can't get the Client IP, it will return proxy IP.
                            }

Tuesday, April 24, 2012

flexigrid-1.1 fix Html table Using Jquery

flexigrid-1.1 is very nice javascript and css Library to fix Html table sorting drag and drop view and hide table column

Link for Download files.

http://code.google.com/p/flexigrid/downloads/list

C++ program to rotate and capitalize sentences.

The program will start by asking the user to enter a multi-word sentence. The program will then the
program will rotate the sentence and print out the rotated sentence. Moreover, the first letter of each word of sentence must be capitalized. All other words must be in lower case.

#include "stdafx.h"
#include <iostream>
#include "conio.h"
#include "vector"
#include <sstream>

using namespace std;

int _tmain(int argc)
{
      char sentence[1000];
    bool cap_it = true;
    cout << "enter your sentence.\n";
    cin.getline(sentence, 1000);
    for (int i = 0; i < strlen(sentence); i++)
    {
        if (isalpha(sentence[i]) && cap_it == true)
        {
            sentence[i] = toupper(sentence[i]);
            cap_it = false;
        }
        else
            if (isspace (sentence[i]))
                cap_it = true;
    }

    cout << endl <<  endl;

     istringstream converter(sentence);

    vector<string> words((istream_iterator<string>(converter)),  istream_iterator<string>());

    copy(words.rbegin(), words.rend(), ostream_iterator<string>(cout, " "));
  getch();

    return 0;
}

c++ calculate the hypotenuse of a right angle triangle

A program to calculate the hypotenuse of a right angle triangle.Your program will ask the user for the lengths of the two  sides adjacent to the right angle. It will then calculate the  hypotenuse and print the result along with the input out to screen.

Solution:
#include "stdafx.h"
#include <iostream>
#include <string>
#include "math.h"
#include "conio.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    //A program to calculate the hypotenuse of a right angle triangle

        double a,b,Result;

   
        cout<<"enter the first length side "<<endl;;
        cin>>a;

        cout<<"enter the second length side " <<endl;
        cin>>b;
        Result =  sqrt((a*a)+(b*b));

        cout<<"the result of the hypotenuse  == " << Result;
    getch();
   
 return 0;

}

C++ Compute Average of two Numbers (Average Program)

The Program Compute Average for Two Numbers Entered by User

#include "stdafx.h"
#include <iostream>
#include "conio.h"
#include "vector"
#include <sstream>
using namespace std;

int _tmain(int argc)
{
    string str ;
    vector<int> vect;


     cout<<"enter the string of numbers"<<endl;
     cin >> str ;
    stringstream ss(str);
int i;
double sum = 0 ;
while (ss >> i)
{
        vect.push_back(i);

        if (ss.peek() == ',')
                ss.ignore();
}
 vector< int >::const_iterator constIterator;

   // display vector elements using const_iterator
   for ( constIterator = vect.begin();constIterator != vect.end(); ++constIterator )
   {
       sum=sum+*constIterator;
   }
   cout<<"Numbers  Sum  =  " << sum  <<endl;
   cout<<"Numbers Count   =  " << vect.size()  <<endl;
   cout<<"Numbers  Average  =  " << sum/vect.size()  <<endl;
   cout << endl;
getch();
    return 0;
}

C++ Swap Two Numbers Using Pointer

this Program to swap Two Numbers Using Pointer



#include "stdafx.h"
# include <iostream>
using namespace std;
void p_swap(int *pNum1, int *pNum2);
int main(void)
{
int num1=0, num2=0;
cout << "Enter two numbers to swap between them: " << endl << "Number (1): ";

cin >> num1;
cout << "Number (2): ";
cin >> num2;
     p_swap(&num1, &num2 );    //pass the addresses
     cout<< endl<< "After the swap, number1 is " << num1 << endl<< " number2 is " << num2 << "."<< endl;
system ("pause");
     return 0;
}

//-------------- Function to reverse two values
void p_swap(int *pNum1, int *pNum2)    // receiving addresses not values
{
     int temp;    // temporary holding variable

     temp = *pNum1;    // swap the values stored at the addresses
     *pNum1 = *pNum2;
     *pNum2 = temp;

     return;     // main( )'s variables, not copies of them, have been changed


C++ program to return input string length

the code receive line from user and print out his line characters count