i have a adim users.. when once adim supervisor added by admin and set designation supervisor and department as computer science .. then when again admin add account and try to add admin and set his designation supervisor and department computer science then here i want to show error " degiantion already exist" ..beacuse every department has one supervsior , one manager and also one senior manager ....not multilpe supervsiors ,managers i try this sp and code.. sp
ALTER procedure [dbo].[spadmindesig]
@DesigID int
as
if exists(select * from Designation where DesigID=@DesigID)
return -1
else
return 1
and for admin signup
ALTER procedure [dbo].[spadminreg]
@UserName nvarchar(50),
@Password nvarchar(50),
@UserTypeID int,
@DepID int,
@DesigID int,
@emailaddress nvarchar(50),
@PhoneNumber nvarchar(50)
as
if EXISTS(SELECT 1 from Designation where DesigID=@DepID)
begin
select @DesigID as 'SuperVisor'
end
else if EXISTS (select 2 from Designation where DesigID=@DesigID)
begin
select @DesigID as 'Manager'
end
else if EXISTS (select 3 from Designation where DesigID=@DesigID)
begin
select @DesigID as 'Senior Manager'
end
else
if exists(select * from Designation where DesigID=@DesigID)
return -1
else
return 1
insert into [Userss](UserName,Password,UserTypeID,DepID,CreateDate,DesigID,Email ,PhoneNumber)
values
(@UserName,@Password,@UserTypeID,@DepID,GETDATE(),@DesigID,@emailaddress,@PhoneNumber)
code
public void AdminSignUp(string Username, string Password, int UserTypeID, int DepID, int desigid, string emailaddress, string PhoneNumber)
{
db.ExecuteScalar("spadminreg", new object[] { Username, Password, UserTypeID, DepID, desigid, emailaddress, PhoneNumber });
}
public string Admindes( int desigid)
{
string val=db.ExecuteScalar("spadmindesig", new object[] { desigid }).ToString();
return val;
}
button code
protected void Btn_SignUp_Click(object sender, EventArgs e)
{
try
{
string val= adminsignup.Admindes(Convert.ToInt32(DropDownList2.SelectedValue));
if(val=="1")
{
adminsignup.AdminSignUp(nametxt.Value, passtxt.Value, Convert.ToInt32(DropDownList1.SelectedValue), Convert.ToInt32(DropDownList2.SelectedValue), Convert.ToInt32(DropDownList3.SelectedValue), mailtxt.Value, numbtxt.Value);
Lbe6.Visible = true;
Lbe6.Text = ("Designation Already Exists.");
}
else
{
lbe5.Visible = true;
lbe5.Text = ("");
}
}
catch
{
lbe5.Visible = true;
lbe5.Text = ("SIGNUP FAILED.PLEASE TRY AGAIN");
}
nametxt.Value = "";
passtxt.Value = "";
mailtxt.Value = "";
numbtxt.Value = "";
}
supervsior account exist in table and when i add supevsior account and set same desginaation and deprtment then it show me error "signup failed " and i want to display error " desgination already exist" and when i delete existing supervsior account from table and then again i add supervsior account then it shows me error ..
object reference not set to an instance of an object