Monday 30 December 2013

Find Odd and Even using Console Application in C#

Ans:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Logicals
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Number Only..");
            int num = int.Parse(Console.ReadLine());
            if (num % 2 == 0)
            {
                Console.WriteLine("It's a Even No..");
            }
            else
            {
                Console.WriteLine("Its a Odd No..");
            }
            Console.ReadLine();
        }
    }
}

Triangle Pattern Example using Console Application in C#

Ans:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Logicals
{
    class TrianglePattern
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Number of Rows u want Only..");
            int num = int.Parse(Console.ReadLine());
            for (int i = 1; i <= num; i++)
            {
                for (int space = 1; space <= num - i; space++)
                {
                    Console.Write(" ");
                }
                for (int j = 1; j <= 2 * i - 1; j++)
                {
                    Console.Write(j);
                }
                Console.WriteLine();
            }

                Console.ReadLine();
        }
    }
}

Pallindrom Number using Console Application in C#

Ans:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Logicals
{
    class Pallindromnumber
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Number nOly..");
            int num = int.Parse(Console.ReadLine());
            int reminder, pallindrom = 0;
            int store = num;
            while (num > 0)
            {
                reminder = num % 10;
                pallindrom = pallindrom * 10 + reminder;
                num = num / 10;

               
            }
            if (pallindrom == store)
            {
                Console.WriteLine("It's a Pallindrom No..");
            }
            else
            {
                Console.WriteLine("It's Not a Pallindrom No..");
            }

            Console.ReadLine();
        }
    }
}

Armstrong Number using Console Application in C#

Ans:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Logicals
{
    class Armstrongnumber
    {
        static void main(string[] args)
        {
            Console.WriteLine("Enter Number Only..");
            int num = int.Parse(Console.ReadLine());
            int reminder,armstrong=0;
            int store = num;
            while (num > 0)
            {
                reminder = num % 10;
                armstrong = armstrong + reminder * reminder * reminder;
                num = num / 10;

            }
            if (armstrong == store)
            {
                Console.WriteLine("It's an Armstrong No..");
            }
            else
            {
                Console.WriteLine("It's Not an Armstrong No..");
            }
           
            Console.ReadLine();
        }
    }
}

Prime Number using Console Application in C#

Ans:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Logicals
{
    class Primenumber
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Number Only..");
            int num = int.Parse(Console.ReadLine());
            int count=0;
            for (int i = 2; i <= num;i++ )
            {
                if (num % i == 0)
                {
                    count++;
                }
                }
            if (count == 1)
            {
                Console.WriteLine("It's a Prime No..");
            }
            else
            {
                Console.WriteLine("It's Not a Prime No..");
            }
                    Console.ReadLine();
        }
    }
}

Fibonassi Series using Console Application in C#

Ans:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Logicals
{
    class FibonassiSeries
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Number Only..");
            int num = int.Parse(Console.ReadLine());
            int temp,a=0,b=1;
            int[] arr = new int[10];
            arr[0] = 0;
            arr[1] = 1;
            for (int i = 2; i <= num-1; i++)
            {
                temp = a + b;
                a = b;
                b = temp;
                arr[i] = temp;
            }
            for (int j = 0; j <= num - 1; j++)
            {
                Console.WriteLine(arr[j]);
            }

                Console.ReadLine();
        }
    }
}

Thursday 12 December 2013

Pattern Logical Question And Answer in Java Script

Like:-

      1
    232
  45654
78910987

<!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>
    <title></title>
    <script>
        function f1() {
            var num = (document.getElementById("txtNum").value).trim();
            var regx = /^[0-9]*$/;
            var chkNum = regx.test(num);
            if (chkNum != true) {
                alert("Enter Number only..");
            }
            var inc = 1, temp;
              for (var i = 1; i <= num - 1; i++) {
               
                for (var sp = 1; sp <= num - i; sp++) {
                   document.write("&nbsp;");
                }
                for (var j = 1; j <= i; j++) {
                    document.write(inc );
                    inc++;
                }
                temp = inc - 1;
                for (var j = 1; j < i; j++) {
                    document.write(temp - j );
                }
                document.write("<br/>");
            }
         
           
        }
   
    </script>
 
</head>
<body>

    <input id="txtNum" type="text" />
    <input id="Button" type="button" value="button" onclick="f1()"/>
<div id="div1">

</div>

</body>
</html>

Monday 2 December 2013

Gridview with CheckBox Operations(Both Header and Child)and also provide Paging in Asp.Net

UI Design:-(Default.aspx)

Select Challengers
subs
subs1
sub21
sub21
sub21
12

Source Code:-(Default.aspx.cs)

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

<!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></title>
     <script type="text/javascript">
        $("[id*=chkhdr]").live("click", function () {
            var chkHeader = $(this);
            var grid = $(this).closest("table");
            $("input[type=checkbox]", grid).each(function () {
                if (chkhdr.is(":checked")) {
                    $(this).attr("checked", "checked");
                    $("td", $(this).closest("tr")).addClass("selected");
                } else {
                    $(this).removeAttr("checked");
                    $("td", $(this).closest("tr")).removeClass("selected");
                }
            });
        });
        $("[id*=chkChild1]").live("click", function () {
            var grid = $(this).closest("table");
            var chkhdr = $("[id*=chkhdr]", grid);
            if (!$(this).is(":checked")) {
                $("td", $(this).closest("tr")).removeClass("selected");
                chkhdr.removeAttr("checked");
            } else {
                $("td", $(this).closest("tr")).addClass("selected");
                if ($("[id*=chkChild1]", grid).length == $("[id*=chkChild1]:checked", grid).length) {
                    chkhdr.attr("checked", "checked");
                }
            }
        });
        </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:GridView ID="grdvSelectChallengers" runat="server" 
                                                    AutoGenerateColumns="False"
                                                    Height="16px" Width="300px"
                                                    PageSize="5" AllowPaging="True" 
                                                    onpageindexchanging="grdvSelectChallengers_PageIndexChanging">
                                                    <Columns>
                                                        <asp:TemplateField>
                                                            <HeaderTemplate>
                                                                <asp:CheckBox ID="chkhdr" runat="server" AutoPostBack="true" OnCheckedChanged="chkhdr_CheckedChanged" />
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <asp:CheckBox ID="chkChild1" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField>
                                                            <HeaderTemplate>
                                                                Select Challengers
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <asp:Label ID="lblchallengename" runat="server" Text='<%# Eval("challengename") %>'></asp:Label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>

                                                    </Columns>
                                                </asp:GridView>
    
    </div>
    </form>
</body>
</html>

Default.aspx.cs:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
    static SqlConnection cn;
    static SqlDataAdapter da;
    //static DataSet ds;
    static DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bindchallengers();
        }

    }
     protected void bindchallengers()
        {
            string strQuery = "select challengename from challenge";
            cn = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString);
            da = new SqlDataAdapter(strQuery,cn);
            dt = new DataTable();
            //ds = new DataSet();

            da.Fill(dt);

            grdvSelectChallengers.DataSource = dt;
            grdvSelectChallengers.DataBind();
        }
       
    protected void chkhdr_CheckedChanged(object sender, EventArgs e)
    {
       
            CheckBox ChkBoxHeader = (CheckBox)grdvSelectChallengers.HeaderRow.FindControl("chkhdr");
            foreach (GridViewRow row in grdvSelectChallengers.Rows)
            {
                CheckBox ChkBoxRows = (CheckBox)row.FindControl("chkChild1");
                if (ChkBoxHeader.Checked == true)
                {
                    ChkBoxRows.Checked = true;
                }
                else
                {
                    ChkBoxRows.Checked = false;
                }
            }
       
        
    }
    protected void grdvSelectChallengers_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        {
            grdvSelectChallengers.PageIndex = e.NewPageIndex;
            bindchallengers();
        }
    }

}

Web.Config File:-

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="conStr" connectionString="user id=Sa;password=123;Database=master;server=localhost"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
</configuration>

Create Table in DB:-

create table challenge(challengeid int constraint prkey primary key identity(100,1),challengename varchar(30),challengeowner varchar(30))

Insert Data in Table in DB:-

insert into challenge(challengename,challengeowner)values('sub21','ssyss')

3-Tier Operation of Insert,Update,Delete and show Data from DB in Asp.Net

First create 1 Website and then 2 Library project in same application

Step wise:-
1-File->New Website---website will be create
2-Right click of Solution Explorer ->New Project->Class Library->give name as BAL
                                                               ->Create 2 folder->give name as BE and BL
                                                               ->In BE folder create one Class(.cs) file
                                                                   named as-BE_tbl_Employee.cs
                                                               ->In BL folder create one Class(.cs) file
                                                                   named as-BL_Employee_Logics.cs
3-Right click of Solution Explorer ->New Project->Class Library->give name as DAL
                                                               ->Create one Class(.cs) file
                                                                   named as-ConnectionFactory.cs
Default.aspx:-(design part)

EmpID
Ename
Job
Sal
2
ewe
yyy
6545
5
subs
fhhh
67865
6
dhg
fghg
677
12
sss
jjj
555
13
gfdd
cxvcb
45354
33
ghfh
sgh
34356


Insert Employee Data:-
Employee ID
:
Employee Name
:
Job
:
Sal
:
:

Default.aspx:-(Source part)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="grdvOperations" runat="server" AutoGenerateColumns="False" 
            AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" OnRowCancelingEdit="grdvOperations_RowCancelingEdit" OnRowDeleting="grdvOperations_RowDeleting" OnRowEditing="grdvOperations_RowEditing" OnRowUpdating="grdvOperations_RowUpdating" >
            <Columns>
                <asp:TemplateField HeaderText="EmpID" SortExpression="EmpID" Visible="True">
                    <ItemTemplate>
                        <asp:Label ID="lblEmpId" runat="server" Text='<%#Eval("EmpID") %>'></asp:Label>
                    </ItemTemplate>
                                     
                </asp:TemplateField>
               
                <asp:TemplateField HeaderText="Ename" SortExpression="Ename">
                    <ItemTemplate>
                        <asp:Label ID="lblEname" runat="server" Text='<%# Eval("Ename") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtEname" runat="server" Text='<%# Eval("Ename") %>'></asp:TextBox>
                    </EditItemTemplate>
                    
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Job" SortExpression="Job">
                    <ItemTemplate>
                        <asp:Label ID="lblJob" runat="server" Text='<%# Eval("Job") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtJob" runat="server" Text='<%# Eval("Job") %>'></asp:TextBox>
                    </EditItemTemplate>
                    
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Sal" SortExpression="Sal">
                    <ItemTemplate>
                        <asp:Label ID="lblSal" runat="server" Text='<%# Eval("Sal") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtSal" runat="server" Text='<%# Eval("Sal") %>'></asp:TextBox>
                    </EditItemTemplate>
                    
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
  
    
    </div>
        <div>
            <table>
                <tr><td>Insert Employee Data:-</td></tr>
                 <tr>
                    <td> <asp:Label ID="lblEid" CssClass="lblsize" Text="Employee ID" runat="server"></asp:Label>  </td>
                    <td>:</td>
                    <td> <asp:TextBox ID="txtEid" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td> <asp:Label ID="lblEname" CssClass="lblsize" Text="Employee Name" runat="server"></asp:Label>  </td>
                    <td>:</td>
                    <td> <asp:TextBox ID="txtEname" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td><asp:Label ID="lblJob" CssClass="lblsize" Text="Job" runat="server"></asp:Label></td>
                    <td>:</td>
                    <td><asp:TextBox ID="txtJob" runat="server"></asp:TextBox></td>
                </tr>
                  <tr>
                    <td><asp:Label ID="lblSal" CssClass="lblsize" Text="Sal" runat="server"></asp:Label></td>
                    <td>:</td>
                    <td><asp:TextBox ID="txtSal" runat="server"></asp:TextBox>
                        
                    </td>

                </tr>
                <tr>
                    <td></td>
                    <td>:</td>
                    <td> <asp:Button ID="btnInsertEmpData" Text="Submit" runat="server" OnClick="btnInsertEmpData_Click"></asp:Button></td>
                </tr>
    </table>
        </div>
    </form>
</body>
</html>

Default.aspx.cs:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using BAL.BE;
using BAL.BL;
using DAL;

public partial class _Default : System.Web.UI.Page
{
    BL_Employee_Logics obj_BL_Employee_Logics = new BL_Employee_Logics();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
        BindData();
        }

    }
    protected void BindData()
    {
        grdvOperations.DataSource = obj_BL_Employee_Logics.GetEmpDatafromDB();
        grdvOperations.DataBind();
    }
    protected void grdvOperations_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        BE_tbl_Employee obj_BE_tbl_Employee = new BE_tbl_Employee();
        Label lblEid = (Label)grdvOperations.Rows[e.RowIndex].FindControl("lblEmpId");
        obj_BE_tbl_Employee.EmpID = Convert.ToInt32(lblEid.Text);
        int rowAffected =obj_BL_Employee_Logics.DeleteEmpRecord(obj_BE_tbl_Employee);
        grdvOperations.EditIndex = -1;
        BindData();
        if (rowAffected > 0)
        {
            Response.Write("Record Deleted Successfully");
        }
        else
        {
            Response.Write("Record Not Yet Deleted");
        }

    }
    protected void grdvOperations_RowEditing(object sender, GridViewEditEventArgs e)
    {
        grdvOperations.EditIndex = e.NewEditIndex;
        BindData();
    }
    protected void grdvOperations_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        
            BE_tbl_Employee obj_BE_tbl_Employee = new BE_tbl_Employee();

            //TextBox Eid = (TextBox)grdvOperations.Rows[e.RowIndex].FindControl("txtEmpId");
            //int empId = Convert.ToInt32(Eid.Text);
            //obj_BE_tbl_Employee.EmpID = empId;

            string eid =((Label)grdvOperations.Rows[e.RowIndex].FindControl("lblEmpId")).Text;
            obj_BE_tbl_Employee.EmpID = Convert.ToInt32(eid);

            string ename = ((TextBox)grdvOperations.Rows[e.RowIndex].FindControl("txtEname")).Text.Trim();
            //string eName = ename.Text;
            obj_BE_tbl_Employee.EName = ename;

            string job = ((TextBox)grdvOperations.Rows[e.RowIndex].FindControl("txtJob")).Text.Trim();
            //string Ejob = job.Text;
            obj_BE_tbl_Employee.Job = job;

            string sal = ((TextBox)grdvOperations.Rows[e.RowIndex].FindControl("txtSal")).Text.Trim();
            //int Esal = Convert.ToInt32(sal.Text);
            obj_BE_tbl_Employee.Sal =Convert.ToInt32(sal);

            int rowAffected =obj_BL_Employee_Logics.UpdateEmpRecord(obj_BE_tbl_Employee);
            grdvOperations.EditIndex = -1;
            BindData();

            if (rowAffected > 0)
            {
                
                Response.Write("updated successfully");
            }
            else
            {
                Response.Write("Not updated");
            }

            
        
    }
    protected void grdvOperations_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        grdvOperations.EditIndex = -1;
        BindData();
    }
    protected void btnInsertEmpData_Click(object sender, EventArgs e)
    {
        obj_BL_Employee_Logics = new BL_Employee_Logics();
        BE_tbl_Employee obj_BE_tbl_Employee = new BE_tbl_Employee();
        obj_BE_tbl_Employee.EmpID = Convert.ToInt32(txtEid.Text);
        obj_BE_tbl_Employee.EName = txtEname.Text;
        obj_BE_tbl_Employee.Job = txtJob.Text;
        obj_BE_tbl_Employee.Sal =Convert.ToInt32(txtSal.Text);
        int rowAffected = obj_BL_Employee_Logics.InsertEmpRecord(obj_BE_tbl_Employee);
        if (rowAffected > 0)
        {
            Response.Write("Record Inserted Successfully");
        }
        else
        {
            Response.Write("Record Inserted Unsuccessfully");
            txtEname.Text = txtJob.Text = txtSal.Text = "";
            txtEname.Focus();
        }
    }
}

In Web.Config File:-

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="conStr" connectionString="server=Subas-PC;database=SubasDB;user id=sa;password=123"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
</configuration>

In BAL:-(BE folder)

BE_tbl_Employee.cs:-


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using BAL.BE;
using BAL.BL;
using DAL;

namespace BAL.BE
{
    public class BE_tbl_Employee
    {
        private int empID;

        public int EmpID
        {
            get { return empID; }
            set { empID = value; }
        }
        private string eName;

        public string EName
        {
            get { return eName; }
            set { eName = value; }
        }
        private string job;

        public string Job
        {
            get { return job; }
            set { job = value; }
        }
        private int sal;

        public int Sal
        {
            get { return sal; }
            set { sal = value; }
        }

    }
}

In BAL:-(BL folder)

BL_Employee_Logics.cs:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using BAL.BE;
using BAL.BL;
using DAL;

namespace BAL.BL
{
    public class BL_Employee_Logics
    {
        public DataSet GetEmpDatafromDB()
        {
            DataSet ds = ConnectionFactory.ExecuteDataset(ConnectionFactory.GetConnection(), "SP_GetEmployeeAllData", CommandType.StoredProcedure);
            return ds;
        }
        public int DeleteEmpRecord(BE_tbl_Employee obj_BE_tbl_Employee)
        {
            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter("@EmpID", obj_BE_tbl_Employee.EmpID);
            int r = ConnectionFactory.ExecuteNonQuery1(ConnectionFactory.GetConnection(), "SP_DeleteEmpRecords", CommandType.StoredProcedure, p);
            return r;
        }
        public int UpdateEmpRecord(BE_tbl_Employee obj_BE_tbl_Employee)
        {
            SqlParameter[] p = new SqlParameter[4];
            p[0] = new SqlParameter("@empid", obj_BE_tbl_Employee.EmpID);
            p[1] = new SqlParameter("@ename", obj_BE_tbl_Employee.EName);
            p[2] = new SqlParameter("@job", obj_BE_tbl_Employee.Job);
            p[3] = new SqlParameter("@sal", obj_BE_tbl_Employee.Sal);
            int r = ConnectionFactory.ExecuteNonQuery1(ConnectionFactory.GetConnection(), "SP_UpdateEmpRecord", CommandType.StoredProcedure, p);
            return r;
        }
        public int InsertEmpRecord(BE_tbl_Employee obj_BE_tbl_Employee)
        {
            SqlParameter[] p = new SqlParameter[4];
            p[0] = new SqlParameter("@eid", obj_BE_tbl_Employee.EmpID);
            p[1] = new SqlParameter("@ename", obj_BE_tbl_Employee.EName);
            p[2] = new SqlParameter("@job", obj_BE_tbl_Employee.Job);

            p[3]=new SqlParameter("@sal",obj_BE_tbl_Employee.Sal);
          
            int r = ConnectionFactory.ExecuteNonQuery1(ConnectionFactory.GetConnection(), "SP_InsertEmpRecord", CommandType.StoredProcedure, p);
            return r;
        }
    }
}

In DAL:-

ConnectionFactory.cs:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace DAL
{
    public class ConnectionFactory
    {

        static SqlConnection scon;
        static SqlDataAdapter sda;
        static SqlCommand scmd;
        public static string GetConnection()
        {
            return ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
        }


        static void CreateConnection(string strConnection)
        {
            scon = new SqlConnection(strConnection);

        }

        public static DataSet ExecuteDataset(string strSqlConnection, string strCommandText, CommandType ct)
        {
            CreateConnection(strSqlConnection);
            sda = new SqlDataAdapter(strCommandText, scon);
            sda.SelectCommand.CommandType = ct;
            DataSet ds = new DataSet();
            sda.Fill(ds);
            return ds;
        }


        public static DataSet ExecuteDataset(string strSqlConnection, string strCommandText, CommandType ct, SqlParameter[] p)
        {
            CreateConnection(strSqlConnection);
            sda = new SqlDataAdapter(strCommandText, scon);
            sda.SelectCommand.CommandType = ct;
            scmd.Parameters.AddRange(p);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            return ds;
        }
       public static int ExecuteNonQuery1(string strSqlConnection, string strCommandText, CommandType ct, SqlParameter[] p)
        {
            CreateConnection(strSqlConnection);
            if (scon.State != ConnectionState.Open)
                scon.Open();
            scmd = new SqlCommand(strCommandText, scon);
            scmd.CommandType = ct;
            scmd.Parameters.AddRange(p);
            return scmd.ExecuteNonQuery();
        }

        public static SqlDataReader ExecuteReader(string strSqlConnection, string strCommandText, CommandType ct, SqlParameter[] p)
        {
            CreateConnection(strSqlConnection);
            if (scon.State != ConnectionState.Open)
                scon.Open();
            scmd = new SqlCommand(strCommandText, scon);
            scmd.CommandType = ct;
            scmd.Parameters.AddRange(p);
            return scmd.ExecuteReader();

        }
    }
}

Store Procedures:-

1. Create procedure SP_UpdateEmpRecord(@empid int,@ename varchar(30),@job varchar(30),@sal int)
as
Begin
update employee set Ename=@ename,Job=@job,Sal=@sal where EmpID=@empid
End

2. Create procedure SP_InsertEmpRecord(@eid int,@ename varchar(30),@job varchar(30),@sal int)
as
Begin
insert into Employee(EmpID,Ename,Job,Sal)values(@eid,@ename,@job,@sal);
end

3. Create procedure SP_GetAllEmpRecords
as
Begin
Select * from Employee;
End

4. Create procedure SP_DeleteEmpRecords(@EmpID int)
as
Begin
delete from Employee where EmpID=@EmpID;

End