Saturday, 1 March 2014

A Small Application to Show Individual and Group Emp Records with Generate Sal Dynamically(Used Master Page)

Here i have taken 5 .aspx pages (AboutUs.aspx, ContactUs.aspx, Home.aspx, IndividualEmpDetails.aspx , GroupEmpDetails.aspx) and for giving consistent look and feel using Master page. In IndividualEmpDetails page only you will see the Individual Emp records using DDL control and GroupEmpDetails page you will see the Group of Emp records using Gridview control with CRUD operations and here Total Sal will generate automatically after putting Sal & Commission.

Ans:-

MasterPage.master:-

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
 
    <title>Master Page</title>
 
</head>
<body>
    <form id="form1" runat="server">
 <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
   <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
   <ContentTemplate>
    <table>
 
    <tr>
    <td width='100px' height='75px'><img src="Images/Water%20lilies.jpg" width='100px' height='75px' /></td>
    <td colspan='2' width='1000px' height='75px'><img src="Images/Sunset.jpg" width='1000px' height='75px' /></td>
    </tr>
 
    <tr>
    <td width='100px' height='600px' align="center">
    <asp:ContentPlaceHolder id="head" runat="server">
    This is for left side content place holder
    </asp:ContentPlaceHolder>
    </td>
    <td width='900px' height='600px' align="center">
    <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
    This is for center content place holder
    </asp:ContentPlaceHolder>
    </td>
     
    <td width='100px' height='600px' align="center"><img src="Images/Winter.jpg"  width='100px' height='600px' /></td>
    </tr>
     
    <tr>
    <td colspan='2' width='1000px' height='50px'><img src="Images/Blue%20hills.jpg" width='1000px' height='50px' /></td>
   <td width='100px' height='50px'><img src="Images/Water%20lilies.jpg" width='100px' height='50px' /></td>
    </tr>
     
 
    </table>
 </ContentTemplate>
 </asp:UpdatePanel>
        <div align="center" width='1100px' height='25px'>Copy Right-2014 @ Acess Meditech Pvt.Ltd. </div>
    </div>
    </form>
</body>
</html>

IndividualEmpDetails.aspx:-

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="IndividualEmpDetails.aspx.cs" Inherits="_Default" MasterPageFile="~/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div>
     
<center>
<%-- <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>--%>
<div>
    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
   <ContentTemplate>
<table>
<tr><td colspan='3' align="center"><b>Get Individual Employee Details</b></td></tr>
    
<tr><td>Emp ID</td><td>:</td><td><asp:DropDownList ID="DdlId" runat="server" AutoPostBack="true" onselectedindexchanged="DdlId_SelectedIndexChanged"></asp:DropDownList></td></tr>
<tr><td>Emp Name</td><td>:</td><td><asp:TextBox ID="txtName" runat="server"></asp:TextBox></td></tr>
<tr><td>Job</td><td>:</td><td><asp:TextBox ID="txtJob" runat="server"></asp:TextBox></td></tr>
<tr><td>Sal</td><td>:</td><td><asp:TextBox ID="txtSal" runat="server"></asp:TextBox></td></tr>
<tr><td>Commission</td><td>:</td><td><asp:TextBox ID="txtComm" runat="server"></asp:TextBox></td></tr>
<tr><td>Total Salary</td><td>:</td><td><asp:TextBox ID="txtTotSal" runat="server"></asp:TextBox></td></tr>

</table>
     </ContentTemplate>
 </asp:UpdatePanel>
<div>
   <asp:Label ID="lblMsg" runat="server" Text="message"></asp:Label>
</div>

</div>

</center>
</div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <div>
    
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/GroupEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">GroupEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" NavigateUrl="~/IndividualEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">IndividualEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Home.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Home..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink5" NavigateUrl="~/About Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">About..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink3" NavigateUrl="~/Contact Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Contact Us..</asp:HyperLink>
</div>
</asp:Content>

IndividualEmpDetails.aspx.cs:-

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    Class1 obj = new Class1();
    SqlConnection cn = null;
    SqlCommand cmd = null;
    SqlDataAdapter da = null;
    DataTable dt = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDdlEmpDetailsById();
        }
    }
    void BindDdlEmpDetailsById()
    {
        cn = new SqlConnection(obj.GetConnection());
        cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spGetIndividualEmpRecords";
        da = new SqlDataAdapter(cmd);
        dt = new DataTable();
        da.Fill(dt);
        DdlId.DataSource = dt;
        DdlId.DataTextField = "ename";
        DdlId.DataValueField = "id";
        DdlId.DataBind();
        DdlId.Items.Insert(0,"--Select--");
    }

    protected void DdlId_SelectedIndexChanged(object sender, EventArgs e)
    {
        cn = new SqlConnection(obj.GetConnection());
        
        cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spGetIndividualEmpRecordsById";
        cmd.Parameters.AddWithValue("@id",DbType.Int32).Value=DdlId.SelectedValue.ToString();
        try
        {
            cn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                txtName.Text = dr["ename"].ToString();
                txtSal.Text = dr["sal"].ToString();
                txtComm.Text = dr["comm"].ToString();
                txtJob.Text = dr["job"].ToString();
                txtTotSal.Text = dr["totalsal"].ToString();
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
        finally
        {
            cn.Close();
        }
  
    }
}

GroupEmpDetails.aspx:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GroupEmpDetails.aspx.cs" Inherits="GroupEmpDetails" MasterPageFile="~/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div><b>Get Group Employee Details</b></div>
    <div>
    <script type="text/javascript" language="javascript">
        function Addition(val) {
            var num1 = parseInt(document.getElementById("<%=txtAddSal.ClientID %>").value);
            var num2 = parseInt(document.getElementById("<%=txtAddComm.ClientID %>").value);

            var result = num1 + num2;
            document.getElementById("<%=txtAddTotalSal.ClientID %>").value = result;
        }
    </script>
    </div>
<%--    <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>--%>
<div>
    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
    <ContentTemplate>    
    <asp:GridView ID="GridView1" runat="server" Width='700px' AllowPaging="True" 
        AutoGenerateColumns="False" PageSize="5" 
        onpageindexchanging="GridView1_PageIndexChanging" BackColor="White" 
        BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
        AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" 
        onrowcancelingedit="GridView1_RowCancelingEdit" 
        onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing" 
        onrowupdating="GridView1_RowUpdating" > <%--ShowFooter="true"--%>
        <RowStyle BackColor="White" ForeColor="#003399" />
        <Columns>
            <asp:TemplateField HeaderText="ID">
              <EditItemTemplate>
                    <asp:TextBox ID="txtId" Width="100px" runat="server" Text='<%# Bind("id") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblId" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                    
                </ItemTemplate>
              <FooterTemplate>
                    <asp:TextBox ID="txtAddId" ReadOnly="true" runat="server"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="EName">
                <EditItemTemplate>
                    <asp:TextBox ID="txtEName" Width="100px" runat="server" Text='<%# Bind("ename") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblEName" runat="server" Text='<%# Bind("ename") %>'></asp:Label>
                </ItemTemplate>
            <%-- <FooterTemplate>
                    <asp:TextBox ID="txtAddName" runat="server"></asp:TextBox>
                </FooterTemplate>--%>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Job">
                <EditItemTemplate>
                    <asp:TextBox ID="txtJob" Width="100px" runat="server" Text='<%# Bind("job") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblJob" runat="server" Text='<%# Bind("job") %>'></asp:Label>
                </ItemTemplate>
               <%--<FooterTemplate>
                    <asp:TextBox ID="txtAddJob" runat="server"></asp:TextBox>
                </FooterTemplate>--%>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Salary">
                <EditItemTemplate>
                    <asp:TextBox ID="txtSal" Width="100px" runat="server" Text='<%# Bind("sal") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblSal" runat="server" Text='<%# Bind("sal") %>'></asp:Label>
                </ItemTemplate>
               <%--<FooterTemplate>
                    <asp:TextBox ID="txtAddSal" onkeyup="Addition(1)" value="0" runat="server"></asp:TextBox>
                </FooterTemplate>--%>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Commission">
                <EditItemTemplate>
                    <asp:TextBox ID="txtComm" Width="100px" runat="server" Text='<%# Bind("comm") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblComm" runat="server" Text='<%# Bind("comm") %>'></asp:Label>
                </ItemTemplate>
                <%--<FooterTemplate>
                    <asp:TextBox ID="txtAddComm" onkeyup="Addition(2)" value="0" runat="server"></asp:TextBox>
                </FooterTemplate>--%>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="TotalSalary">
                <EditItemTemplate>
                    <asp:TextBox ID="txtTotalSal" Width="100px" runat="server" Text='<%# Bind("totalsal") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblTotalSal" runat="server" Text='<%# Bind("totalsal") %>'></asp:Label>
                </ItemTemplate>
              <%-- <FooterTemplate>
                    <asp:TextBox ID="txtAddTotalSal" onkeyup="Addition(3)" value="0" runat="server" ></asp:TextBox>
                </FooterTemplate>--%>
                
            </asp:TemplateField>
            
        </Columns>
        <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
        <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
        <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
    </asp:GridView>
    </ContentTemplate>
    </asp:UpdatePanel>
</div>
<div>
<asp:TextBox ID="txtAddId" placeholder="id" Width='100px' ReadOnly="true" runat="server"></asp:TextBox>
<asp:TextBox ID="txtAddName" placeholder="ename" Width="100px" runat="server"></asp:TextBox>
<asp:TextBox ID="txtAddJob" placeholder="job" Width="100px" runat="server"></asp:TextBox>
 <asp:TextBox ID="txtAddSal" Width="100px" onkeyup="Addition(1)" value="0" runat="server"></asp:TextBox>
 <asp:TextBox ID="txtAddComm" Width="100px" onkeyup="Addition(2)" value="0" runat="server"></asp:TextBox>
  <asp:TextBox ID="txtAddTotalSal" Width="100px" onkeyup="Addition(3)" value="0" runat="server" ></asp:TextBox>
</div>
<div>
<asp:Button ID="btnAdd" runat="server" Text="Generate ID" onclick="btnAdd_Click" />
&nbsp;
<asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click"/>
&nbsp;
<asp:Button ID="btnClear" runat="server" Text="Clear" onclick="btnClear_Click" />

</div>

<div>
    <asp:Label ID="lblMsg" runat="server" Text="Message"></asp:Label>
</div>


</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <div>
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/GroupEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">GroupEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" NavigateUrl="~/IndividualEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">IndividualEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Home.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Home..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink5" NavigateUrl="~/About Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">About..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink3" NavigateUrl="~/Contact Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Contact Us..</asp:HyperLink>
</div>
</asp:Content>

GroupEmpDetails.aspx.cs:-

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class GroupEmpDetails : System.Web.UI.Page
{
    Class1 obj = new Class1();
    SqlConnection cn = null;
    SqlCommand cmd = null;
    SqlDataAdapter da = null;
    DataTable dt = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindEmpGroupData();
        }
    }
   void BindEmpGroupData()
{
    cn = new SqlConnection(obj.GetConnection());
        cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spGetAllEmpRecords";
        da = new SqlDataAdapter(cmd);
        dt = new DataTable();
        da.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();
}

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindEmpGroupData();
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        txtAddName.Focus();
        cn = new SqlConnection(obj.GetConnection());
        cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spGetIdIncreamentByMax";
        string i = "";
        try
        {
            cn.Open();
            i = cmd.ExecuteScalar().ToString();
            txtAddId.Text = i;

            //TextBox txtaddid = GridView1.FooterRow.FindControl("txtAddId") as TextBox;
            //txtaddid.Text = i;

        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
        finally
        {
            cn.Close();
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        cn = new SqlConnection(obj.GetConnection());
        cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spSaveEmpDetails";
        cmd.Parameters.AddWithValue("@id",txtAddId.Text);
        cmd.Parameters.AddWithValue("@ename",txtAddName.Text);
        cmd.Parameters.AddWithValue("@job",txtAddJob.Text);
        cmd.Parameters.AddWithValue("@sal",txtAddSal.Text);
        cmd.Parameters.AddWithValue("@comm",txtAddComm.Text);
        cmd.Parameters.AddWithValue("@totalsal",txtAddTotalSal.Text);
        int rowAffected=0;
        try
        {
            cn.Open();
            rowAffected = cmd.ExecuteNonQuery();
            if (rowAffected > 0)
            {
                lblMsg.Text = "Saved..";
            }
            else
            {
                lblMsg.Text = "Not Saved..";
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text =ex.Message;
        }
        finally
        {
            cn.Close();
        }
        BindEmpGroupData();
    }
    protected void btnClear_Click(object sender, EventArgs e)
    {
        txtAddId.Text = String.Empty.ToString();
        txtAddName.Text = String.Empty.ToString();
        txtAddJob.Text = String.Empty.ToString();
        txtAddSal.Text = String.Empty.ToString();
        txtAddComm.Text = String.Empty.ToString();
        txtAddTotalSal.Text = String.Empty.ToString();
        BindEmpGroupData();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        BindEmpGroupData();
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        BindEmpGroupData();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        cn = new SqlConnection(obj.GetConnection());
        cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spDeleteEmpDetails";
        GridViewRow grdvw = (GridViewRow)GridView1.Rows[e.RowIndex];
        Label lblid = (Label)grdvw.FindControl("lblId");
        cmd.Parameters.AddWithValue("@id", SqlDbType.Int).Value = lblid.Text;
        
        int rowAffected = 0;
        try
        {
            cn.Open();
            rowAffected = cmd.ExecuteNonQuery();
            if (rowAffected > 0)
            {
                lblMsg.Text = "Deleted..";
            }
            else
            {
                lblMsg.Text = "Not Deleted..";
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
        finally
        {
            cn.Close();
        }
        BindEmpGroupData();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        cn = new SqlConnection(obj.GetConnection());
        cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spUpdateEmpDetails";
        GridViewRow grdvw = (GridViewRow)GridView1.Rows[e.RowIndex];
        TextBox txtid = (TextBox)grdvw.FindControl("txtId");
        TextBox txtename = (TextBox)grdvw.FindControl("txtEName");
        TextBox txtjob = (TextBox)grdvw.FindControl("txtJob");
        TextBox txtsal = (TextBox)grdvw.FindControl("txtSal");
        TextBox txtcomm = (TextBox)grdvw.FindControl("txtComm");
        TextBox txttotalsal = (TextBox)grdvw.FindControl("txtTotalSal");

        cmd.Parameters.AddWithValue("@id",txtid.Text);
        cmd.Parameters.AddWithValue("@ename", txtename.Text);
        cmd.Parameters.AddWithValue("@job", txtjob.Text);
        cmd.Parameters.AddWithValue("@sal", txtsal.Text);
        cmd.Parameters.AddWithValue("@comm", txtcomm.Text);
        cmd.Parameters.AddWithValue("@totalsal", txttotalsal.Text);
        int rowAffected = 0;
        try
        {
            cn.Open();
            rowAffected = cmd.ExecuteNonQuery();
            if (rowAffected > 0)
            {
                lblMsg.Text = "Updated..";
            }
            else
            {
                lblMsg.Text = "Not Updated..";
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
        finally
        {
            cn.Close();
        }
        GridView1.EditIndex = -1;
        BindEmpGroupData();
    }
}

About Us.aspx:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="About Us.aspx.cs" Inherits="About_Us" MasterPageFile="~/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
Hi i am Subas Junior Software Engineer of Acess Meditech Pvt.Ltd.
<br />
and we are working on some medical and Insurance related sites
<br />
provided services to our clients if has any issiue on that sites.
<br />
<br />
Thanks And regards
<br />
Subas..
</div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/IndividualEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">IndividualEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" NavigateUrl="~/GroupEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">GroupEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Home.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Home..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink5" NavigateUrl="~/About Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">About..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink3" NavigateUrl="~/Contact Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Contact Us..</asp:HyperLink>
</div>
</asp:Content>

Contact Us.aspx:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Contact Us.aspx.cs" Inherits="Contact_Us" MasterPageFile="~/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
Acess Meditech Pvt.Ltd.
<br />
Humayun Nagar,Almas Plaza
<br />
PL. No-303,Hyderabad,AP.
</div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/IndividualEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">IndividualEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" NavigateUrl="~/GroupEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">GroupEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Home.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Home..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink5" NavigateUrl="~/About Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">About..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink3" NavigateUrl="~/Contact Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Contact Us..</asp:HyperLink>
</div>
</asp:Content>

Home.aspx:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" MasterPageFile="~/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
Welcome..To..Home
</div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/IndividualEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">IndividualEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" NavigateUrl="~/GroupEmpDetails.aspx" Font-Underline="true" ForeColor="Blue" runat="server">GroupEmpDetails..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Home.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Home..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink5" NavigateUrl="~/About Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">About..</asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink3" NavigateUrl="~/Contact Us.aspx" Font-Underline="true" ForeColor="Blue" runat="server">Contact Us..</asp:HyperLink>
</div>
</asp:Content>

For  Get Connection Write Code in Class File:-

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
    public string GetConnection()
    {
        string strCon = "server=.;database=subsdb;user id=sa;pwd=123";
        return strCon;
    }
}

For Create Table and Stored Procedure:-

use SubsDB

--only create table here
create table tblTestEmp(id int constraint p_k primary key,ename varchar(30),sal money,comm money,totalsal money)

--only insert table here
insert into tblTestEmp(id,ename,sal,comm,totalsal)values(1,'ewr',15000,300,10000+300)

create proc spGetAllEmpRecords
as
begin
select * from tblTestEmp
end

create proc spGetIndividualEmpRecords
as
begin
select ename+'-'+CAST(id as varchar) as ename,id from tblTestEmp
end

create proc spGetIndividualEmpRecordsById(@id int)
as
begin
select * from tblTestEmp where id=@id
end

create proc spGetIdIncreamentByMax
as
begin
select MAX(id)+1 as id from tblTestEmp
end

create proc spSaveEmpDetails(@id int,@ename varchar(30),@sal money,@comm money,@totalsal money,@job varchar(30))
as
begin
insert into tblTestEmp(id,ename,sal,comm,totalsal,job)values(@id,@ename,@sal,@comm,@totalsal,@job)
end

create proc spDeleteEmpDetails(@id int)
as
begin
delete from tblTestEmp where id=@id;
end

create proc spUpdateEmpDetails(@id int,@ename varchar(30),@sal money,@comm money,@totalsal money,@job varchar(30))
as
begin
update tblTestEmp set ename=@ename,sal=@sal,comm=@comm,totalsal=@totalsal,job=@job where id=@id;
end



No comments:

Post a Comment