Monday, 15 June 2015

Introduction to object oriented programing in C#

Class: A class is a blue print of an object that contains members and functions in it.

for ex:

class A
{
int a;
string s;
public void int sum(int a, int b
{
}
}

Object:An object is a instance of a class. You can create object of a class and access all the public variable and methods of that class.

for ex:

A objA=new Obj A();
int sum=a.sum(a,b);

Tuesday, 26 May 2015

What is Xaml?

XAML stands for extensible Application markup language, is variant of xml describing GUI. In winforms GUI framework was created in same language that you would use for interacting with the GUI like vb.net or c#.net.

Sunday, 10 May 2015

Hello World in WPF- WPF Tutorial

In xaml:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="60">Hello World</TextBlock>
    </Grid>
</Window>

After run program





For more info visit:
http://webxperts.co.in/


Loop throuth all textboxes in Winforms

For iterating through all textboxes in winforms:

foreach (TextBox TextBox in this.Controls.OfType<TextBox>())
            {
                if (TextBox.BackColor == Brushes.Green)
                {
                    //your code
                }
            }

Sunday, 22 March 2015

Design Patterns:Three layred or Tiered architechture

This article will provide you the basic knowledge of Layered architecture.

3 tier architecture
What is layer- A layer is a reusable code that can be used any where, in any project.
in .net a layer is setup as a project.
We can have multiple layers to segregate our project.
We are going to discuss three layered architecture here. in three layered architecture we have three layers:
1.Data Access Layer
2.Business Logic Layer
3.Presentation Logic Layer

1.Data Access Layer(DAL)- Data access layer is basically used to interact with database. We use ado.net to access database in this layer. BAL layer interact with DAL to interact with database. BAL call DAL function to send and receive data to database.

2.Business Access Layer(BAL)-BAL layer is basically used to define business logic, calculations, conversions and all the stuff that is required by Presentation Layer.

3.Presentation Logic Layer- This layer is basically used for user interface. Presentation layer always interact to BAL layer for any data required or to send any data to database.

Benifits of layered architecture:
1.Easy to maintain of code. Because all layers are seperated from other so we can change to any layer easyily.
2.Reusability of code: We can use the code anywhere in the same project or any other project using reference.
3.Provide a segregated architecutre.

Sunday, 15 February 2015

Ineterface with example in C#

Interface Definition: An interface is basically a contract or service which will implemented by other classes.
This implements the rules which will forced to use by derived classes.
Interface has only declarations of methods and properties. They do not have body in method they
have only the signatures.
Declaring Interfaces:

public interface IUser
{
void AddUser(User user);
void EditUser(int Id)
User GetUserByID(int Id);
}
Implementation:

public class User:IUser
{
public User GetUserByID(int Id)
{
 var context=...................;
var user=context.Users.find(Id);
return user;
}
public EditUser(int Id)
{
var context=...................;
var user=context.Users.find(Id);
context.Entry(user).State=EntityState.Modified;
context.SaveChanges();
}
public void AddUser(User user)
{
var context=...................;
context.Users.Add(user);
context.SaveChanges();
}
}

Thursday, 8 January 2015

How to add all the rows of a column to string with comma seperated

 Introduction: Here we have to add all the rows of a column to string with comma seperated.
Description:I am going to use coalesce function of sql server to achieve the result.
Query:

DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ',', '') + Name
FROM tbl_Names
print @Names