本文整理汇总了C#中Data.WhatHappensOnUserLogin方法的典型用法代码示例。如果您正苦于以下问题:C# Data.WhatHappensOnUserLogin方法的具体用法?C# Data.WhatHappensOnUserLogin怎么用?C# Data.WhatHappensOnUserLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data
的用法示例。
在下文中一共展示了Data.WhatHappensOnUserLogin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeItSo
protected void MakeItSo(object sender, System.EventArgs e)
{
HttpCookie cookie = Request.Cookies["BrowserDate"];
if (cookie == null)
{
cookie = new HttpCookie("BrowserDate");
cookie.Value = DateTime.Now.ToString();
cookie.Expires = DateTime.Now.AddDays(22);
Response.Cookies.Add(cookie);
}
try
{
Encryption encrypt = new Encryption();
DateTime isn = DateTime.Now;
if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
isn = DateTime.Now;
DateTime isNow = isn;
Data dat = new Data(isn); if (Page.IsValid)
{
if (DBConnection(UserNameTextBox.Text.Trim(), encrypt.encrypt(PasswordTextBox.Text.Trim())))
{
string groups = "";
SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());
myConn.Open();
SqlCommand myCmd = new SqlCommand("SELECT U.Password, U.User_ID, UP.CatCountry, UP.CatState, UP.CatCity, U.UserName FROM Users U, UserPreferences UP WHERE U.User_ID=UP.UserID AND [email protected]", myConn);
myCmd.CommandType = CommandType.Text;
myCmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = UserNameTextBox.Text.Trim();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(myCmd);
da.Fill(ds);
myConn.Close();
if (ds.Tables[0].Rows.Count > 0)
{
dat.WhatHappensOnUserLogin(ds);
string redirectTo = "my-account";
if (Session["RedirectTo"] != null)
redirectTo = Session["RedirectTo"].ToString();
Response.Redirect(redirectTo, false);
}
else
{
StatusLabel.Text = "Invalid Login, please try again!";
}
}
else
{
StatusLabel.Text = "Invalid Login, please try again!";
}
}
}
catch (Exception ex)
{
StatusLabel.Text = ex.ToString();
}
}
示例2: MakeItSo
//.........这里部分代码省略.........
ds = dat.GetData("SELECT U.Password, U.User_ID, UP.CatCountry, UP.CatState, UP.CatCity, U.UserName FROM Users U, UserPreferences UP WHERE U.User_ID=UP.UserID AND U.UserName='"+UserNameTextBox.THE_TEXT+"'");
Session["UserName"] = UserNameTextBox.THE_TEXT.Trim();
Session["User"] = ID;
//insert all ad categories
DataView dvCats = dat.GetDataDV("SELECT * FROM AdCategories WHERE isParent = 'True'");
for (int i = 0; i < dvCats.Count; i++)
{
dat.Execute("INSERT INTO UserCategories (UserID, CategoryID) VALUES(" + ID + ", " + dvCats[i]["ID"].ToString() + ")");
}
string radius = "";
if (RadiusPanel.Visible)
{
radius = ", Radius=" + RadiusDropDown.SelectedValue;
}
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());
if (conn.State != ConnectionState.Open)
conn.Open();
SqlCommand cmd = new SqlCommand("UPDATE UserPreferences SET " +
" [email protected], [email protected], [email protected], [email protected]" +
radius +
" WHERE [email protected] ", conn);
cmd.Parameters.Add("@id", SqlDbType.Int).Value = ID;
cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = CityTextBox.THE_TEXT;
if (CatZipTextBox.THE_TEXT.Trim() != "")
cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value =
dat.GetAllZipsInRadius(RadiusDropDown.SelectedValue,
CatZipTextBox.THE_TEXT.Trim(), true);
else
cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = DBNull.Value;
cmd.Parameters.Add("@catCountry", SqlDbType.Int).Value = CountryDropDown.SelectedValue;
Session["UserCountry"] = CountryDropDown.SelectedValue;
string state = "";
if (StateDropDownPanel.Visible)
state = StateDropDown.SelectedItem.Text;
else
state = StateTextBox.THE_TEXT;
cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = state;
Session["UserState"] = state;
Session["UserCity"] = CityTextBox;
Session["UserCity"] = CatZipTextBox.THE_TEXT.Trim();
cmd.ExecuteNonQuery();
conn.Close();
string groups = "User, Admin";
//FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
FormsAuthenticationTicket authTicket =
new FormsAuthenticationTicket(1, ds.Tables[0].Rows[0]["User_ID"].ToString(),
DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")),
DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).AddMinutes(60),
false, groups);
// Now encrypt the ticket.
string encryptedTicket =
FormsAuthentication.Encrypt(authTicket);
// Create a cookie and add the encrypted ticket to the
// cookie as data.
HttpCookie authCookie =
new HttpCookie(FormsAuthentication.FormsCookieName,
encryptedTicket);
// Add the cookie to the outgoing cookies collection.
Response.Cookies.Add(authCookie);
dat.WhatHappensOnUserLogin(ds);
//Send out welcome email
dat.SendWelcome();
Response.Redirect("User.aspx");
}
}
}
}
else
{
MessageLabel.Text = message;
}
}
else
MessageLabel.Text = "User Name can only contain letter and numbers.";
}
else
MessageLabel.Text = "All fields with * must be filled in. If you include First and Last name, these cannot have any special keys, only letters. If you include one of the names, you must include the other.";
}
catch (Exception ex)
{
MessageLabel.Text = ex.ToString();
}
}