Showing posts with label VB. Show all posts
Showing posts with label VB. Show all posts

Wednesday, June 26, 2013

The basic functionalities of 3 - Tier or N-Tier Architecture




Presentation Layer
  •  Gathering information from the user
  • Sending the user information to the business services from processing
  • Receiving the result of the business services processing
  • Presenting those results to the user

Business Layer

  • Receiving input from the presentation tier.
  • Interacting with the data services to perform the business operations.
  • Sending the processed results to the presentation tier.

Data Service Layer

  • Storage of data
  • Retrieval of data
  • Maintenance of data
  • Integrity of data

Thursday, September 15, 2011

Adding, Retrieving Name objects from a Hashtable in C#.Net

Hashtable is nothing but a collection of objects. To get brief idea,

Take a few instance of Name Class and add them to a Hashtable. Your Name will be value for Hashtable but you need to decide about key. key will unique in the Hashtable. When you are retrieving values from Hashtable this key place a major role.

First thing you need to add is namespace for Hashtable.

using System.Collections;

then take few instance of your class Name.

//Creating few instances for Class Name
Name emmu = new Name("Emmaneale", "Mendu");
Name vamshi = new Name("Vamshi", "Malyala");
Name pradeep = new Name("Pradeep", "Kandula");

We got our Values ready. So lets use initials as our key to insert into Hastable as shown below.

//Add Names into Hashtable
Hashtable SampleHashtbl = new Hashtable();
SampleHashtbl.Add("EM", emmu);
SampleHashtbl.Add("VM", vamshi);
SampleHashtbl.Add("PK", pradeep);

here if you try to use duplicates for key. You will get an error as shown in Figure 1.

 Figure 1
Done with inserting. Now lets retrieve them and display on our page.

 //Retrieve Names from Hastable
 Name ex = (Name)SampleHashtbl["EM"];   
 if (ex != null)
    Response.Write(ex.FullName + "<br/>");
 else
    Response.Write("NOT FOUND<br/>");

To retrieve we need key string. If it didn't found the key it returns null. So check before display.

That's a small example on Hashtable.

Here is the Complete Code and Output in Figure 2.

protected void Page_Load(object sender, EventArgs e)
    {
        //Creating few instances for Class Name
        Name emmu = new Name("Emmaneale", "Mendu");
        Name vamshi = new Name("Vamshi", "Malyala");
        Name pradeep = new Name("Pradeep", "Kandula");

        //Add Names into HashTable
        Hashtable SampleHashtbl = new Hashtable();
        SampleHashtbl.Add("EM", emmu);
        SampleHashtbl.Add("VM", vamshi);
        SampleHashtbl.Add("PK", pradeep);

        //Retrieve Names from HasTable
        Name ex = (Name)SampleHashtbl["EM"];   
        if (ex != null)
            Response.Write(ex.FullName + "<br/>");
        else
            Response.Write("NOT FOUND<br/>");

        ex = (Name)SampleHashtbl["VM"];
        if (ex != null)
            Response.Write(ex.FullName + "<br/>");
        else
            Response.Write("NOT FOUND<br/>");

        ex = (Name)SampleHashtbl["PK1"];
        if (ex != null)
            Response.Write(ex.FullName + "<br/>");
        else
            Response.Write("NOT FOUND<br/>");
    }

    public class Name
    {
        string FirstName;
        string LastName;

        //Constructor for our Class
        public Name(string first, string last)
        {
            FirstName = first;
            LastName = last;
        }

        //public property for FullName
        public string FullName
        {
            get
            {
                return FirstName + " " + LastName;
            }
        }
    }

 Figure 2


Emmaneale Mendu
.Net Developer

Thursday, September 8, 2011

Arrays with C# Classes

Arrays with C# Classes

Arrays works as collections of items, for instance strings. You can use them to gather items in a single group.

Here Below Example i created a Class called Name. In which we have a Two variables, A constructor expecting two inputs First and Last name. and a property that returns Full Name of a Person Name.

Its a very simple example where i am putting all Names in to an array called GroupOfFriends. Printing all Names is very easy you can use either For loop or Foreach Loop. I used Foreach.

I used WebSite page to work on this example:

.cs Code Calling Class Name from Page_Load

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

public partial class September_Sep08 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Creating few instances for Class Name
        Name emmu = new Name("Emmaneale", "Mendu");
        Name vamshi = new Name("Vamshi", "Malyala");
        Name pradeep = new Name("Pradeep", "Kandula");

        //Creating an Array to maintain Group of Names
        Name[] GroupOfFriends = { emmu, vamshi, pradeep };

        Response.Write("List of Names in the FriendsList:<br/>");

        //Using foreach to print the Names
        foreach (Name p in GroupOfFriends)
        {
            Response.Write(p.FullName + "<br/>");
        }
    }

    public class Name
    {
        string FirstName;
        string LastName;

        //Constructor for our Class
        public Name(string first, string last)
        {
            FirstName = first;
            LastName = last;
        }

        //public property for FullName
        public string FullName
        {
            get
            {
                return FirstName + " " + LastName;
            }
        }
    }
}

Your outPut looks like below Figure

Sunday, August 14, 2011

What are the two different levels of variables that are supported by ASP.Net

  • Page Level variable : Int, float, char, string and all other .Net data type whose scope is limited to that particular page only.
  • Object level variable : Application Level, Session Level that is used to access the data throughout the application.

Tuesday, August 9, 2011

What is ASP.NET?

  • ASP stands for Active Server Pages
  • ASP.NET is the name of the MICROSOFT technology used for web site development.
  • There are several other technologies exist for web development.
  • ASP.NET is the technology from MICROSOFT and it is widely used one.
  • ASP.NET is not ASP. ASP.NET is an entirely new technology for server side scripting. It was written from the ground up and is not backward compatible with classic ASP.
  • ASP.NET is NOT a programming language like C# or VB.NET.
  • ASP.NET development requires a programming language like C# or VB.NET to write code.
  • ASP.NET technology comes with a rich set of components and controls that make the web development very easy.
  • Visual Studio .Net is the editor from MICROSOFT which helps you develop ASP.NET sites faster
  • IIS(Internet Information Syatems) is the web server from MICROSOFT which supports ASP.NET. To develop ASP.NET web sites, you must have IIS installed in your computer.