Alter procedure sp_Grid(@Id int=null,
@Name varchar(50)=null,
@Dept varchar(50)=null,
@sal int=null,
@type varchar(50)=null
)
as
begin
if(@type='Select')
select * from Test
if(@type='Search')
IF(@Name IS NULL)
IF(@Dept IS NULL)
IF( @sal IS NULL)
SELECT * from Test
ELSE
SELECT * from Test where sal=@sal
ELSE
IF(@sal IS NULL)
SELECT * from Test where Dept=@Dept
ELSE
SELECT * from Test where Dept=@Dept and sal=@sal
ELSE
IF(@Dept IS NULL)
IF( @sal IS NULL)
SELECT * from Test where Name=@Name
ELSE
SELECT * from Test where Name=@Name AND sal=@sal
ELSE
IF( @sal IS NULL)
SELECT * from Test where Dept=@Dept AND Name=@Name
ELSE
SELECT * from Test where Dept=@Dept AND Name=@Name AND sal=@sal
end
if(txtName.Text=="")
dm.Name = null;
else dm.Name = txtName.Text;
if (txtDept.Text == "")
dm.Dept = null;
else dm.Dept = txtDept.Text;
if (txtSal.Text == "")
dm.Sal = null;
else dm.Sal = txtSal.Text;
@Name varchar(50)=null,
@Dept varchar(50)=null,
@sal int=null,
@type varchar(50)=null
)
as
begin
if(@type='Select')
select * from Test
if(@type='Search')
IF(@Name IS NULL)
IF(@Dept IS NULL)
IF( @sal IS NULL)
SELECT * from Test
ELSE
SELECT * from Test where sal=@sal
ELSE
IF(@sal IS NULL)
SELECT * from Test where Dept=@Dept
ELSE
SELECT * from Test where Dept=@Dept and sal=@sal
ELSE
IF(@Dept IS NULL)
IF( @sal IS NULL)
SELECT * from Test where Name=@Name
ELSE
SELECT * from Test where Name=@Name AND sal=@sal
ELSE
IF( @sal IS NULL)
SELECT * from Test where Dept=@Dept AND Name=@Name
ELSE
SELECT * from Test where Dept=@Dept AND Name=@Name AND sal=@sal
end
if(txtName.Text=="")
dm.Name = null;
else dm.Name = txtName.Text;
if (txtDept.Text == "")
dm.Dept = null;
else dm.Dept = txtDept.Text;
if (txtSal.Text == "")
dm.Sal = null;
else dm.Sal = txtSal.Text;
No comments:
Post a Comment