-->

Saturday, July 18, 2015

How to bind label control in asp.net

Step-1: Open Visual Studio IDE
Step-2 : Create New Web Project

ASP.NET empty website


Step-3: In Solution Explorer Add new item 
Solution Explorer Add new item


Step-4: Select web form in middle pane also select c# in left pane

Step-5: Change name of the webform as "labelbind.aspx" also select place code in separate file check box
Step-6:   Right click on  Project name and add new item  again.
Step-7: Open a new dialog window Select SQL SERVER database  name as a "database.mdf"
Step-8: After click ok Button . a new dialog appear on the screen 
Do you want to place the file in App_data folder
Step-9: Click Ok Button in dialog window
Step-10: Open Server Explorer
Step-11 Make a new table inside Database

Step-12:
make a new table


Step-13: fill This Table with Some value
Step-14: Open  " labelbind.aspx " page
Step-15: Drag and Drop label control onto the labelbind.aspx page from toolbox

Step-16: Add this code in Design page



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="labelbind.aspx.cs" Inherits="labelbind" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="">
            UserId:<%# myname %>


        </asp:Label>
    </div>
    </form>
</body>
</html>

Step-17 Add this code in .cs file


using System;
using System.Data.SqlClient;

public partial class labelbind : System.Web.UI.Page
{
    public string myname;
    SqlConnection con = new SqlConnection();
    SqlCommand cmd = new SqlCommand();


    protected void Page_Load(object sender, EventArgs e)
    {
        con.ConnectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True";
        con.Open();
        cmd.CommandText = "select * from [Employee]";
        cmd.Connection = con;
        SqlDataReader rd = cmd.ExecuteReader();
        while (rd.Read())
        {
            myname = rd["Emp_Name"].ToString ();

        }
        this.DataBind();

     

    }
}


OutPut 


bind label output

Friday, July 17, 2015

Student and fees management project in c#

Introduction 
This project is related to school management system. In this project we have a Sql Database to store student information also store their fees details. The main motive behind the project is to persist the student information in single place. So,we can retrieve that information easily and quickly.

Front-end and Back-end:
Front-end : Windows form with c# as business logic
Back-end :  SQL Server 2014

How to run this:


How to design the system

  1. First to add new windows form in the solution.
  2. Add some control in the form.
  3. Now, add business logic in the code file.
Module in the project
  1. Add new Student: Through this module we can add student details like : Student name, Student father name , Student mother name, Student address etc.
  2. Edit Details :  You can edit details of student by their enrollment id.
  3. Search Student details : You can search stored student details by student name. In this project we can add auto complete type functionality.
  4. Delete Student Details
How to Download :  Mail me : narenkumar851@gmail.com

Monday, July 13, 2015

Use of ProgressBar in WPF also add it in Status bar with animation effect

In this article i will show you, how to use progress bar in wpf (Window Presentation Foundation) and how to add it in status bar dynamically. Actually i explained it with basic information, today i will explain more about it. In this article, first to add a status bar in the page after that add a TextBlock control in it. Now the code look like :


<Grid>

        <StatusBar Name="sbar1" Background="BlueViolet" VerticalAlignment="Bottom">
            <StatusBarItem>
                <TextBlock>Status:</TextBlock>
            </StatusBarItem>
        </StatusBar>
    </Grid>

Now, create a new function just after the InitializeComponent() method, it means you can view your progress bar on window load.  

Code behind code

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;

namespace WpfApplication2
{
    /// <summary>
    /// Interaction logic for progressbar.xaml
    /// </summary>
    public partial class progressbar : Window
    {
        public progressbar()
        {
            InitializeComponent();
            
            createprogressbar();
        }

        private void createprogressbar()
        {
            ProgressBar pb2 = new ProgressBar();
            pb2.IsIndeterminate = false;
            pb2.Orientation = Orientation.Horizontal;
            pb2.Width = 100;
            pb2.Height = 25;
           
            Duration dur = new Duration(TimeSpan.FromSeconds(30));
            DoubleAnimation dblani = new DoubleAnimation(200.0, dur);
            pb2.BeginAnimation(ProgressBar.ValueProperty, dblani);
            sbar1.Items.Add(pb2);

        }

  
    }
}

Now, code generate the following output:

Use of ProgressBar in WPF also add it in Status bar with animation effect


Here,
  1. Create a ProgressBar class object also set some data members like width, height etc.
  2. Set the animation by BeginAnimation method( )

Sunday, July 12, 2015

Accept only number by TextBox using Jquery

You can say, how to apply restriction on input using Jquery. Here, meaning of restriction is, TextBox accept only numbers. Everyone know that TextBox control take character,string, numeric and special character as a input. But in some application we need only single feature like, it accept only number. So, the first question raise in my mind, how to do this, what is the logic behind this.
Logic behind this:
  1. First to get the key code like number 8 == backspace, some following keycode available here 
  2.  Now, match the keycode with the input character, if match then input character are not allowed.
Here are simple example of it:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Accept only numbers</title>
<script src="scripts/jquery-1.10.2.js"></script>
<script>
$(function () {
$('#Text1').keydown(function (er) {

if (er.altKey || er.ctrlKey || er.shiftKey) {
er.preventDefault();
}
else {

var key = er.keyCode;
if (!((key == 8) || (key == 46) || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105))) {

er.preventDefault();
}

}


});

});

</script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
<input id="Text1" type="text" />
    </div>
    </form>
</body>
</html>
Now code generate the following output:

Accept only number by TextBox using Jquery
Here are some related article:

Monday, July 6, 2015

Online mobile shopping project in ASP.NET

INTRODUCTION
This project is aimed at developing a Web application that depicts online Shopping of mobiles and purchasing using Payment Gateway. Using this software, companies can improve the efficiency of their services. Online Shopping is one of the applications to improve the marketing of the company’s products. This web application involves all the features of the online shopping.


The project entitled Online Mobile Shopping enables customer to buy mobiles or accessories from anywhere through online. This application advertises some of the products for shopping. To buy products, customer has to create an account. Those who does not have an account, they can only view the available product. They can’t buy it. Once the customer has created account, not only he can view the products, he can also add the product to the cart and also he can place an order to buy those products. This application then generates bill for that particular customer. After the confirmation, the customer has to enter his credit card details to buy those products.

Home page :


Online mobile shopping project in ASP.NET


OVERVIEW:
The project entitled “Online Mobile Shopping” enables customer to buy mobiles or accessories from anywhere through online. This application advertises some of the products for shopping. To buy products, customer has to create an account. Those who does not have an account, they can only view the available product. They can’t buy it. Once the customer has created account, not only he can view the products, he can also add the product to the cart and also he can place an order to buy those products. This application then generates bill for that particular customer. After the confirmation, the customer has to enter his credit card details to buy those products.

OVERALL DESCRIPTION:
Product Perspective: The product will be developed completely independent and dynamic website. Customer must have an account to purchase the product. This application stores all the information in the database which can be retrieved whenever needed and all the validations are performed during the entry of the data by the user thus ensuring that the user can not enter any wrong data which could cause problem later.

Signup page of Mobile shopping project:

Signup page of Mobile shopping project:


Product Function: Initially customer has to register to the website to access most of the features of the application. The customer has to enter the details like username, password…etc. After registration customer will be able to purchase products and the purchased product can be added to the cart. Later customer has to enter his credit card details to buy the products. The confirmation of debit card numbers will be handled by the Pay pal website.
User Characteristics: The user of this product is supposed to be fairly educated about the usage of the computers. He should understand how to store products and he should have knowledge about various products so that they could be saved. A person who has no knowledge of computers will find it difficult to understand the system. But with a little knowledge it will be very easy to handle the project.

Admin: Admin adds the new product and accessories and stores in the database which can be retrieved and used whenever needed and all the validation are performed during the entry of the data. Thus it ensures that the user cannot enter any wrong data which would cause problem later.

User: This application allows the user to access all the products available. To buy the products, customer must create an account in this website.


OBJECTIVE
This software helps customer to find different mobiles, their features, and new updates easily. It is designed such a way that one can view all the updates of the mobile from any place through online. The software will help in easy maintaining and updating products in the website for the administrator. Also quick and easy comparison of different products for the customers
Online Mobile Shopping project is aimed at developing a Web application that depicts online Shopping of mobiles and purchasing using Payment Gateway.
Using this software, companies can improve the efficiency of their services. Online Shopping is one of the applications to improve the marketing of the company’s products. This web application involves all the features of the online shopping.

ABOUT THE PROJECT
1. HARDARE REQUIREMENTS:-
Processor: Pentium 4 or above
RAM :1 GB or above
Hard disk :40 GB or above

2. SOFTWARE REQUIREMENTS:-
Microsoft Visual Studio 2013
SQL Database 2014

3. PROJECT ANALYSIS:-
4. PROJECT IMPLEMENTATION:-
LANGUAGES USED:-
Front End: ASP.NET
Back End: Microsoft SQL Server 2008

MODULES:- The modules used in this software are as follows:-

LOGIN: This module has a drop down list box from where we have to select ADMIN or USER. The ADMIN has all the rights in the software including updating the status of his site. The other fields in login are username and password. If the username and password are correct then it is directed to next page.

NEW USER: This module is for the users who do not have their account. Here user is allowed to create an account to login. The account creation is done by filling the registration form with user details such as name, phone, email etc.

PRODUCT: This module has information regarding the mobiles such as its name, model, color, price information, its features etc. The ADMIN has the authority to Add, Delete, Update etc. The USER can only view the Mobile, add to cart only those in the stock etc.

ACCESSORIES: This module consists of various available accessories of the Mobile with its name and picture, price information etc.

SEARCH: This module helps the customer to ease his search based on his budget or interest. The search can be done on different categories like mobile model name, model number, color, price etc.

CART: User can select any number of Mobile and add to the cart. He can also remove from the cart if he dislikes it later.

PAYMENT: This module describes the payment done by the customer. The payment information can include information like the model purchased, quantity, mode of payment (cash, loan) etc.

STOCKS: This gives the details regarding the products available for sale.

Download : please mail me: narenkumar851@gmail.com

Sunday, July 5, 2015

Difference between MYSQL and MSACCESS

MYSQL is used to store data permanently also MSACCESS is used. But both are different technology so today i will discuss about difference between both.

MYSQL
MSACCESS
Fully RDBMS
RDBMS
Large application
Small application
Multiple DB Engine
Single DB Engine
More ACID(Atomicity Consistency Integrity Durability) of transaction
Less ACID property of transaction
Easy referential Integrity
Hard Referential integrity
Open source
Product of Microsoft
License Free
License paid
Good Execution Speed
Poor Execution Speed
Good Performance
Poor performance
Platform Independent
Platform dependent
Hard Maintenance
Easy Maintenance

Saturday, July 4, 2015

How to use OpenFileDialog control in wpf to read txt file

Today i am talking about OpenFileDialog control. This control is used for picking some files from computer drive or location. I have already learn about OpenFileDialog control in windows form article. Today, the same article i cover using WPF. The logics are same in all language but some presentation of the language are different Like previous article cover by windows form and this article present by xaml language. Lets take a simple example: In this example, we will pick the text file from computer and read this file by using TextBox.

<Grid>
        <TextBox x:Name="textBox" HorizontalAlignment="Left" Height="44" Margin="39,33,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="300"/>
        <Button x:Name="button" Content="Browse" HorizontalAlignment="Left" Margin="344,33,0,0" VerticalAlignment="Top" Width="130" Height="44" Click="button_Click"/>
        <TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="152" Margin="59,108,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="386"/>

    </Grid>


Code behind file

  private void button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.DefaultExt = ".txt";
            ofd.Filter = "Text Document (.txt)|*.txt";
            if(ofd.ShowDialog()==true)
            {
                string filename = ofd.FileName;
                textBox.Text = filename;
                textBox1.Text = File.ReadAllText(filename);
            }

        }
Here OpenFileDialog control is exist in Microsoft.Win32 namespace. So use it by using "using" keyword. If you want to take only text file by this control then use Filter property. After picked file you can read this by using ReadAllText method of  File class.

Now , code generate the following output
How to use OpenFileDialog control in wpf to read txt file

© Copyright 2013 Computer Programming | All Right Reserved