表中有两个与相同部分的Desgination [英] Two Desgination with same departmens in Table

查看:108
本文介绍了表中有两个与相同部分的Desgination的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SCANERI,他们是默认管理员,并且这个管理员添加了更多的监督,经理和高级管理人员,然后在管理员第一次登录并创建主管,经理,董事的账户时



和这里是桌子



I HAVE A SCANERI THAT THER IS DEFAULT ADMIN IN TABLE AND THIS ADMIN ADD FURHTER SUPERVIOSR,MANAGERS AND SENIOR MANAGERS THEN WHEN ADMIN FIRST TIME LOGIN AND CREATE ACCOUNTS OF SUPERVISOR,MANAGER,DIRECTOR

AND HERE IS THE TABLE

UserID	UserName Password UserTypeID	DepID	FullName CreateDate	DocID	Email	                  PhoneNumber	DesigID
51	Noreen	Fatima	    2	       NULL	NULL	2014-02-04 	NULL	noreen.fatimaa@gmail.com    324234234	4
52	Admin	Docum	    1	       NULL	NULL	NULL	NULL	NULL		                                3
53	Sundus   Khan	    1	        2	NULL	2014-02-04 	NULL	Sunduskhan@hotmail.com	031545646456	1
54	Hira	Mansoor	    1	        2	NULL	2014-02-04 	NULL	hiramansoor@gmail.com	0315546464	2
55	Sana	Khan	    1	        2	NULL	2014-02-04 	NULL	sanakhan@gmail.com	2043829429304	3
56	sundus	sundus	    1	        2	NULL	2014-02-04 	NULL	Sunduskhan@hotmail.com	87687678678	1





这里depid 2是计算机科学与设计id 1 = supervsior 2 =经理3 =高级经理4 =基本用户



所以当管理员登录并想再次创建supervsior帐户时,他们的部门就是计算机sciecne。 。现在这里不是一个逻辑



beacuse supervsior账户与部门计算机科学已经存在所以为什么管理员创建另一个与同一部门的supervsior



i使用此sp





here depid 2 is computer science and design id 1=supervsior 2=manager 3=senior manager 4=basic user

so when admin login and want to create again account of supervsior and their department is computer sciecne . . now there this is not a logic

beacuse supervsior account with department omputer science already exist so why admin create another supervsior with same department

i use this sp

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
insert into [Userss](UserName,Password,UserTypeID,DepID,CreateDate,DesigID,Email ,PhoneNumber)
values
(@UserName,@Password,@UserTypeID,@DepID,GETDATE(),@DesigID,@emailaddress,@PhoneNumber)





它适用于我



但是当我填写文本框并选择相同的部门时,例如deisgnation 2和同一部门2



然后这个记录没有添加到表中,但是在.aspx形式它显示我



帐户添加成功



,我想在标签


这是代码





and it works for me

but when i fill textboxes and select same deisgnation with same department like deisgnation 2 and same department 2

then this record not add in table but in .aspx form it show me

"account add succesfully"

and i want to show failed in label

this is code

 protected void Btn_SignUp_Click(object sender, EventArgs e)
        {
            try
            {

                c1.SignUp(nametxt.Value, passtxt.Value, Convert.ToInt32(DropDownList1.SelectedValue), Convert.ToInt32(DropDownList2.SelectedValue),Convert.ToInt32(DropDownList3.SelectedValue),mailtxt.Value,numbtxt.Value);
                //GridView1.DataSource=ca.viewadmin();
                Lbe6.Visible = true;
                 Lbe6.Text = ("Account Successfully Created");
                //  GridView1.DataBind();
            }
            catch
            {
                lbe5.Visible = true;

               lbe5.Text = ("SIGNUP FAILED.PLEASE TRY AGAIN");

            }
            nametxt.Value = "";
            passtxt.Value = "";
            
            mailtxt.Value = "";
            numbtxt.Value = "";

        }
    }

public void SignUp(string Username, string Password, int UserTypeID, int DepID, int desigid,string emailaddress , string PhoneNumber )
        {
            db.ExecuteNonQuery("spadminreg", new object[] { Username,Password, UserTypeID, DepID,desigid,  emailaddress,PhoneNumber });
        }







请帮助我,我会非常感谢




please help meee i will very thankful

推荐答案

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(select 2 from Designation where DesigID==@DesigID)
begin
select @DesigID as 'Manager'
end
else if(select 3 from Designation where DesigID==@DesigID)
begin
select @DesigID as 'Senior Manager'
end
else 
insert into [Userss](UserName,Password,UserTypeID,DepID,CreateDate,DesigID,Email ,PhoneNumber)
values
(@UserName,@Password,@UserTypeID,@DepID,GETDATE(),@DesigID,@emailaddress,@PhoneNumber)





编辑:添加了格式化和可读性的代码块。



Added Code Block for Formatting and Readability.


这篇关于表中有两个与相同部分的Desgination的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆