我的登录页面中有两个实例,具体取决于作为增值税返回的内容(从下面的存储过程中返回变量),当我在服务器上执行存储过程时,结果是INTERNAL
,但是条件else
被执行而不是INTERNAL
登录页。
string usertype = u.ViewUserType((int)Session["Id"]);
string vattype = u.ViewUserVat((string)Session["Code"]);
if (usertype == "Client")
{
if (vattype == "INTERNAL")
{
Response.Redirect("~/NonIFAClient/");
}
else
{
Response.Redirect("~/Client/");
}
}
public string ViewUserVat(string code)
{
CamOnlineAccess.Utilities u = new CamOnlineAccess.Utilities();
SqlCommand c = u.GetCommandSP("dbo.ViewUserVat");
c.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
new System.Data.SqlClient.SqlParameter("@code",System.Data.SqlDbType.VarChar,50),
new System.Data.SqlClient.SqlParameter("@vat",SqlDbType.VarChar, 50, System.Data.ParameterDirection.Output, false, ((byte)(0)), ((byte)(0)), "", System.Data.DataRowVersion.Current, null)});
c.Parameters["@code"].Value = code;
c.Connection.Open();
c.ExecuteScalar(); // because we have output parameters
c.Connection.Close();
return (string)c.Parameters["@vat"].Value;
}
存储过程:
ALTER PROCEDURE [dbo].[ViewUserVat]
-- Add the parameters for the stored procedure here
@code varchar,
@vat varchar(50) output
AS
SELECT
TOP 1 @vat = vattable
FROM
dbo.portfolio
WHERE
owner = @code