protected void Button_FinCompra(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; if (check_caducidad()) { ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (user.ReadID()) { ENCart cart = new ENCart(0, user.userID, 0.0F, 0); DataTable table = cart.ReadCart(); ENOrder order = new ENOrder(user.userID, "Preparando", paga, DateTime.Now); if (order.CreateOrder()) { for (int i = 0; i < table.Rows.Count; i++) { ENProduct p = new ENProduct(Convert.ToInt32(table.Rows[i][0].ToString()), "", 0.0F, 0, "", "", "", ""); if (p.ReadProductFromCatalog()) { p.stock -= Convert.ToInt32(table.Rows[i][3].ToString()); } p.UpdateProduct(); } cart.DeleteCart(); } } Response.Redirect("Default.aspx"); } }
public void UserConnectingAndReadingAll() { var actual = new List <ENUser>(); var user = new ENUser(); actual = user.ReadAll(); }
}//end page load protected void AddCartButton_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { ENProduct producto = new ENProduct(0, "", 0.0F, 0, "", "", "", ""); ENUser usuario = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); producto.id = Convert.ToInt32(Request.QueryString["id"]); usuario.ReadID(); if (producto.ReadProductFromCatalog()) { ENCart carrito = new ENCart(producto.id, usuario.userID, producto.price, Convert.ToInt32(ProdAmount.Text)); if (carrito.CreateCart()) { ProductAddedLabel.Visible = true; } } } else { Response.Redirect("Login.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (user.ReadUserPerfil()) { name.Text = user.name; birth.Text = user.birth.ToString("dd-MM-yyyy"); mail.Text = user.email; address.Text = user.address; if (user.empresa != "") { company.Visible = true; company1.Text = user.empresa; productos.Visible = true; pedidios.Visible = false; } else { pedidios.Visible = true; } fotoPerfil.ImageUrl = user.url; edit_button.Visible = true; } } else { Response.Redirect("Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { cart_menu_button.Visible = false; HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { if (!Proveedor(cookie["username"])) { cart_menu_button.Visible = true; } login_menu_button.Visible = false; register_menu_button.Visible = false; menu_logoff.Visible = true; username_menu_button.Visible = true; username_menu_button.Text = cookie["username"]; ENUser u = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (u.ReadID()) { cart_menu_button.NavigateUrl = "Cart.aspx?userID=" + u.userID; } } else { login_menu_button.Visible = true; register_menu_button.Visible = true; menu_logoff.Visible = false; username_menu_button.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (user.ReadUserEDPerfil()) { nameText = user.name; name.Attributes.Add("placeholder", nameText); addressText = user.address; address.Attributes.Add("placeholder", addressText); img.ImageUrl = user.url; url = user.url; passw = user.pass; email = user.email; delete_account_label.Visible = true; delete_request_button.Visible = true; delete_account_button.Visible = false; delete_check_label.Visible = false; } } else { Response.Redirect("Default.aspx"); } }
protected void verPedidos(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (user.ReadID()) { Response.Redirect("Orders.aspx?userID=" + user.userID); } }
protected bool EmailExist() { ENUser user = new ENUser(); user.email = tb_email.Text; if (user.EmailExist()) { return(true); } return(false); }
protected void Unnamed_Click(object sender, EventArgs e) { HttpPostedFile file = pictureUpload.PostedFile; HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { if (file != null && file.ContentLength > 0) { string fname = Path.GetFileName(file.FileName); url = Path.Combine("~/Imagenes/Users/", fname); file.SaveAs(Server.MapPath(url)); } ENUser user = new ENUser(); if (name.Text == "") { user.name = nameText; } else { user.name = name.Text; } if (pass.Text == "") { user.pass = passw; } else { user.pass = pass.Text; } user.url = url; if (address.Text == "") { user.address = addressText; } else { user.address = address.Text; } user.email = cookie["username"]; if (user.UpdateUser()) { Response.Redirect("Perfil.aspx?ok=" + name.Text); } } }
protected void Delete_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { ENUser user = new ENUser(0, "", "", email, new DateTime(), "", "", ""); if (user.ReadUserEDPerfil()) { if (user.DeleteUser()) { Response.Cookies["damncookie"].Expires = DateTime.Now.AddDays(-1); Response.Redirect("Default.aspx"); } } } }
protected void SendRating_Click(object sender, EventArgs e) { int productID = Convert.ToInt32(Request.QueryString["id"]); HttpCookie cookie = Request.Cookies["damncookie"]; ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (user.ReadID()) { ENRatting rating = new ENRatting(productID, user.userID, CommentTextBox.Text, ratingStars.CurrentRating); if (rating.createRatting()) { RatingSavedLabel.Visible = true; } } }
protected void Send_email_Click(object sender, EventArgs e) { ClearBoxes(); // If email exists in DB, change password for that email and send it back to that email address. ENUser user = new ENUser(); user.email = recover_email.Text.ToString(); user.ReadUserPerfil(); if (user.email != "") { //Changes DB password for this user byte[] salt; new RNGCryptoServiceProvider().GetBytes(salt = new byte[16]); var pb = new Rfc2898DeriveBytes(user.pass, salt, 1000); byte[] random = pb.GetBytes(20); string newpass = Convert.ToBase64String(random); newpass = newpass.Substring(0, 10); user.pass = newpass; if (user.UpdateUser()) { //If info can be sent, then show success message if (SendMail(user.name, user.email, newpass)) { Label_Sending_Success.Visible = true; } else { Label_Main.Text = "Ocurrió un error inesperado al enviar su email, contacte con un administrador."; Label_Main.Visible = true; } } else { Label_Update_Error.Visible = true; } } else { Label_Finding_Error.Visible = true; } }
protected void login_button_Click(object sender, EventArgs e) { ENUser user = new ENUser(login_password.Text, login_email.Text); if (user.ReadUser()) { // 1st compare email and password and validate it. HttpCookie cookie = new HttpCookie("damncookie"); // 2nd create persistent cookie to store user information. cookie["username"] = login_email.Text; cookie["password"] = login_password.Text; cookie.Expires = DateTime.Now.AddHours(1); Response.Cookies.Add(cookie); Response.Redirect("Default.aspx"); } else { Label_Login_Error.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (user.ReadUserPerfil()) { Direccion.Text = user.address; } ENCart cart = new ENCart(0, 0, 0.0F, 0); DataTable table = cart.ReadCart(); for (int i = 0; i < table.Rows.Count; i++) { paga = float.Parse(table.Rows[i][3].ToString()) * float.Parse(table.Rows[i][4].ToString()) + paga; } TotalPrice.Text = Convert.ToString(paga) + "€"; } }
public ENResult login(string userName, string password) { try { using (erpStoreEntities db = new erpStoreEntities()) { List <uspSEUserLogin_Result> result = db.uspSEUserLogin(userName, password, PUser, PReturnCode, PReturnMessage).ToList(); if (result.Count > 0 && Convert.ToInt32(PReturnCode.Value) == 0) { ENUser user = new ENUser(); user.userName = result[0].userName; user.idProfile = result[0].idProfile; user.idStore = result[0].idStore; user.name = result[0].name; user.lastname = result[0].lastname; user.profileName = result[0].profileName; user.storeName = result[0].storeName; user.actions = new List <ENUserAction>(); List <uspSEUserProfileActionSearch_Result> actions = db.uspSEUserProfileActionSearch(userName, PUser, PReturnCode, PReturnMessage).ToList(); for (int i = 0; i < actions.Count; i++) { user.actions.Add(new ENUserAction(actions[i].code, actions[i].name)); } return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value), user)); } else { return(new ENResult(3, "Usuario o clave incorrecta")); } } } catch (Exception ex) { return(PUnexpectedError(ex)); } }
protected void Button_register_click(object sender, EventArgs e) { bool duplicate = EmailExist(); DateTime BirthDate = DateTime.ParseExact(tb_birth.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture); ClearBoxes(); if (check_age(BirthDate) && !duplicate) { HttpPostedFile file = pictureUpload.PostedFile; string url = ""; //check file was submitted if (file != null && file.ContentLength > 0) { string fname = Path.GetFileName(file.FileName); url = Path.Combine("~/Imagenes/Users/", fname); file.SaveAs(Server.MapPath(url)); } else { url = "~/Imagenes/fotoPerfil.jpg"; } byte[] salt; new RNGCryptoServiceProvider().GetBytes(salt = new byte[16]); var pb = new Rfc2898DeriveBytes(tb_password.Text, salt, 1000); byte[] hash = pb.GetBytes(20); byte[] hashBytes = new byte[36]; Array.Copy(salt, 0, hashBytes, 0, 16); Array.Copy(hash, 0, hashBytes, 16, 20); string passw = Convert.ToBase64String(hashBytes); //Create user with given info. if (tb_empresa.Text == "") { ENUser user = new ENUser(0, tb_name.Text, passw, tb_email.Text, BirthDate, url, tb_empresa.Text, tb_delivery_address.Text); if (user.CreateUser()) { Label_Sending_Success.Visible = true; } else { Label_Sending_Error.Visible = true; } } else { ENProvider prov = new ENProvider(tb_name.Text, passw, tb_email.Text, BirthDate, url, tb_empresa.Text, tb_delivery_address.Text); if (prov.CreateProvider()) { Label_Sending_Success.Visible = true; } else { Label_Sending_Error.Visible = true; } } } else if (duplicate) { Label_Duplicate_Error.Visible = true; } }