asp:Wizard
在我使用登录的第一步DirectoryServices
名来进行身份验证。但后来我想把UserID
,Date
和 theSCOPE_IDENTITY()
插入表格中。这是我尝试过的。当我点击下一步时,没有插入信息,但正确检查了 AD 功能。我不确定我做错了什么
protected void OnActiveStepChanged(object sender, EventArgs e)
{
//check for the employee in AD
string Domain = "mydomain.local";
string EmployeeID = txtEmpID.Text;
string Password = txtPassword.Text;
string ADStatus = null;
// If the ActiveStep is changing to Step2, check to see whether the
// user authenticated the AD Login Process. If it is, skip to the Step2 step.
if (Wizard1.ActiveStepIndex == Wizard1.WizardSteps.IndexOf(this.WizardStep2))
{
if (AuthenticateActiveDirectory(Domain, EmployeeID, Password) == true)
{
//If success ...
ADStatus = "Success";
Session["SessionADStatus"] = ADStatus;
string strDepartment = ddlDepartment.SelectedValue;
SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString);
SqlCommand cmd1 = new SqlCommand("INSERT INTO [pharm_OrderID](UserID, RequestType, CreateDate) values (@UserID, @RequestType, @CreateDate);", conn1);
cmd1.CommandType = CommandType.Text;
conn1.Open();
string strUserID = txtEmpID.Text;
cmd1.Parameters.Add("@UserID", SqlDbType.NVarChar, 50);
cmd1.Parameters["@UserID"].Value = strUserID;
string strRequestType = ddlReturnType.SelectedValue;
cmd1.Parameters.Add("@ReturnType", SqlDbType.NVarChar, 50);
cmd1.Parameters["@ReturnType"].Value = strRequestType;
string strCreateDate = lblOrderAttemptTime.Text;
cmd1.Parameters.Add("@CreateDate", SqlDbType.NVarChar, 50);
cmd1.Parameters["@CreateDate"].Value = strCreateDate;
conn1.Dispose();
cmd1.Dispose();
Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(this.WizardStep2);
}
else
{
ADStatus = "Failure";
Session["SessionADStatus"] = ADStatus;
lblADError.Visible = true;
lblADError.Text = "Unable to authenticate Employee ID or Password.";
Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(this.WizardStep1);
}
}
}