protected void EditProfileBtn_Click(object sender, EventArgs e) { int rows = 0; UserDaoImpl dao = new UserDaoImpl(); u = new User(); u.Email = email.Text; u.Address = address.Text; u.City = city.Text; u.LastName = lastName.Text; u.Phone = MobilePhone.Text; u.FirstName = firstName.Text; u.State = DropDownList1.SelectedValue; u.Zip = Convert.ToInt32(zipCode.Text); u.Text = checkToText.Checked; u.Carrier = CarrierList.SelectedValue; //Verifies correct password was input to modify profile info if (userControl.authenticate(email.Text, password1.Text)) { rows = dao.updateUser(u); } else { ResultLabel.Text = "Password was incorrect. Please try again."; return; } //Upon successful update of profile user is redirected back to Auction.asp if (rows == 1) ResultLabel.Text = "Changes Successfully Saved!"; else { ResultLabel.Text = "Unable to update your profile at this time."; } }
public bool addUser(User user) { bool addSuccess = false; addSuccess = userDao.checkDB(user.Email); if(addSuccess) addSuccess = userDao.addNewUser(user); return addSuccess; }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { UserDaoImpl dao = new UserDaoImpl(); //ItemDaoImpl dao = new ItemDaoImpl(); //Credentials creds = dao.getCredentialsByEmail(TextBox1.Text.ToString()); //User user = dao.getUserByEmail(TextBox1.Text.ToString()); //List<Item> list = dao.getItemsByCategory(TextBox1.Text.ToString()); //Item item = dao.getItemByNumber(TextBox1.Text.ToString()); //Response.Write(list.Count); //list.ForEach(printItem ); //Response.Write(item.ToString()); //Item i = new Item() //{ // CategoryID = "CP", // UserID = 100, // ItemName = "TestItem", // ItemValue = 100, // AngelPrice = 75, // MinBid = 50, // Paid = false //}; User u = new User() { Email = "*****@*****.**", FirstName = "Tim", LastName = "Lenahan", Address = "123 Easy st", City = "Normal", State = "IL", Zip = 61761, Admin = true, Committee = false, Donor = false, Phone = "6303106285", Text = true }; dao.createUser(u); //int newID = dao.createItem(i); //Response.Write(i.ItemID); } }
public bool signUp(User u, Credentials c) { bool valid = false; userDao = new UserDaoImpl(); if (userDao.createUser(u)) { User = u; if (userDao.createCredentials(c)) { Credentials = c; valid = true; } } return valid; }
protected void Page_Load(object sender, EventArgs e) { userController = new SearchUserController(); itemCtrl = new ItemController(); if (Request.QueryString["userId"] != null) { singleUser = userController.getSingleUser(Request.QueryString["userId"]); if (singleUser != null) { LblUserName.Text = singleUser.FirstName + " " + singleUser.LastName; LblAddress.Text = singleUser.Address; LblCity.Text = singleUser.City; LblState.Text = singleUser.State; LblHomePhone.Text = singleUser.Phone; LblMobilePhone.Text = formatPhoneNum(singleUser.Phone); lblZip.Text = singleUser.Zip.ToString(); LblEmail.Text = singleUser.Email; if (!singleUser.Text) { BtnText.Visible = false; SMSMessage.Visible = false; } } } if (!Page.IsPostBack) { MessageSent.Visible = false; EmailSentMsg.Visible = false; } InvoiceView.DataBind(); InvoiceView.Rows[InvoiceView.Rows.Count-1].Cells[6].Controls[0].Visible = false; InvoiceView.Rows[InvoiceView.Rows.Count-2].Cells[6].Controls[0].Visible = false; InvoiceView.Rows[InvoiceView.Rows.Count-3].Cells[6].Controls[0].Visible = false; }
//Added this method to process sign ups specifically putting data in dob.USERINFO public bool addNewUser(User user) { bool added = false; int admin = 0, comm = 0, donor = 0; SqlConnection conn = DBHelper.loadDB(); String query = "INSERT INTO USERINFO OUTPUT INSERTED.USERID VALUES (@EMAIL, @FNAME, @LNAME, @ADDRESS, @CITY, @STATE, @ZIP, @ADMIN, @COMMITTEE, @PHONE, @TEXT, @DONOR, @CARRIER)"; try { SqlCommand command = new SqlCommand(query, conn); command.Parameters.Add(new SqlParameter("@EMAIL", user.Email)); command.Parameters.Add(new SqlParameter("@FNAME", user.FirstName)); command.Parameters.Add(new SqlParameter("@LNAME", user.LastName)); command.Parameters.Add(new SqlParameter("@ADDRESS", user.Address)); command.Parameters.Add(new SqlParameter("@CITY", user.City)); command.Parameters.Add(new SqlParameter("@STATE", user.State)); command.Parameters.Add(new SqlParameter("@ZIP", user.Zip)); command.Parameters.Add(new SqlParameter("@ADMIN", admin)); command.Parameters.Add(new SqlParameter("@COMMITTEE", comm)); command.Parameters.Add(new SqlParameter("@PHONE", user.Phone)); command.Parameters.Add(new SqlParameter("@TEXT", user.Text)); command.Parameters.Add(new SqlParameter("@DONOR", donor)); command.Parameters.Add(new SqlParameter("@CARRIER", user.Carrier)); int result = (int)command.ExecuteScalar(); if (result != 0) { added = true; user.UserID = result; } else added = false; } catch(SqlException ex) { //error handling } return added; }
public bool signUp(User u, Credentials c) { bool valid = false; UserDaoImpl userDao = new UserDaoImpl(); userDao.createUser(u); if (true) { userDao.createCredentials(c); if (true) { Credentials creds = c; valid = true; Session["StartTime"] = DateTime.UtcNow; Session["Name"] = userEmailTxt.Text; Session["Admin"] = "No"; Response.Redirect("Profile.aspx"); } } return valid; }
public bool createUser(User user) { int admin = 0, committee = 0, donor = 0, text = 0; if (user.Admin) admin = 1; if (user.Committee) committee = 1; if (user.Donor) donor = 1; if (user.Text) text = 1; bool added = true; SqlConnection conn = DBHelper.loadDB(); String query = "INSERT INTO USERINFO VALUES (@EMAIL, @FNAME, @LNAME, @ADDRESS, @CITY, @STATE, @ZIP, @ADMIN, @COMMITTEE, @PHONE, @TEXT, @DONOR)"; SqlCommand command = new SqlCommand(query, conn); command.Parameters.Add(new SqlParameter("@EMAIL", user.Email)); command.Parameters.Add(new SqlParameter("@FNAME", user.FirstName)); command.Parameters.Add(new SqlParameter("@LNAME", user.LastName)); command.Parameters.Add(new SqlParameter("@ADDRESS", user.Address)); command.Parameters.Add(new SqlParameter("@CITY", user.City)); command.Parameters.Add(new SqlParameter("@STATE", user.State)); command.Parameters.Add(new SqlParameter("@ZIP", user.Zip)); command.Parameters.Add(new SqlParameter("@ADMIN", admin)); command.Parameters.Add(new SqlParameter("@COMMITTEE", committee)); command.Parameters.Add(new SqlParameter("@PHONE", user.Phone)); command.Parameters.Add(new SqlParameter("@TEXT", text)); command.Parameters.Add(new SqlParameter("@DONOR", donor)); try { user.UserID = (int)command.ExecuteScalar(); } catch (SqlException e) { added = false; } return added; }
public List<TableRow> getUserRows(string lastName, string phoneNum) { // this method is created by Satoko in order to check ui design. Delete the following codes // when you implement data retrieval from user table. List<TableRow> rows = new List<TableRow>(); User auctionUser = null; List<User> auctionUserlastName = new List<User>(); if (!phoneNum.Equals("")) { auctionUser = userDaoImpl.getUserByPhone(phoneNum); } if (!lastName.Equals("")) { auctionUserlastName = userDaoImpl.getUserByLastName(lastName); } TableHeaderRow userHeader = new TableHeaderRow(); string[] headerStrs = { "Email", "Name", "Location", "PHONE", "" }; foreach (string headerTitle in headerStrs) { TableHeaderCell titleCell = new TableHeaderCell(); titleCell.Text = headerTitle; userHeader.Cells.Add(titleCell); } rows.Add(userHeader); if (auctionUser != null) { TableCell emailCell = new TableCell(); TableCell fullNameCell = new TableCell(); TableCell locCell = new TableCell(); TableCell phoneCell = new TableCell(); TableCell btnCell = new TableCell(); emailCell.Text = auctionUser.Email.ToString(); fullNameCell.Text = auctionUser.LastName.ToString() + ", " + auctionUser.FirstName.ToString(); locCell.Text = auctionUser.City.ToString() + ", "+ auctionUser.State.ToString(); phoneCell.Text = auctionUser.Phone.ToString(); btnCell.Text = "<a class='ui button' href='SingleView.aspx?userId=" + auctionUser.UserID +"'>View</a>"; TableRow newRow = new TableRow(); newRow.Cells.Add(emailCell); newRow.Cells.Add(fullNameCell); newRow.Cells.Add(locCell); newRow.Cells.Add(phoneCell); newRow.Cells.Add(btnCell); rows.Add(newRow); } else { auctionUser = new User(); } if (auctionUserlastName != null) { foreach(User u in auctionUserlastName) { if (!u.UserID.Equals(auctionUser.UserID)) { TableCell emailCell = new TableCell(); TableCell fullNameCell = new TableCell(); TableCell locCell = new TableCell(); TableCell phoneCell = new TableCell(); TableCell btnCell = new TableCell(); emailCell.Text = u.Email.ToString(); fullNameCell.Text = u.LastName.ToString() + ", " + u.FirstName.ToString(); locCell.Text = u.City.ToString() + ", " + u.State.ToString(); phoneCell.Text = u.Phone.ToString(); btnCell.Text = "<a class='ui button' href='SingleView.aspx?userId=" + u.UserID + "'>View</a>"; TableRow newRow = new TableRow(); newRow.Cells.Add(emailCell); newRow.Cells.Add(fullNameCell); newRow.Cells.Add(locCell); newRow.Cells.Add(phoneCell); newRow.Cells.Add(btnCell); rows.Add(newRow); } } } return rows; }
protected void Page_Load(object sender, EventArgs e) { signUp = new SignUpController(); userControl = new UserCtrl(); if (IsPostBack) { ResultLabel.Visible = true; } if (!IsPostBack) { EditProfileTitle.Visible = false; //if (Session["name"]!= null) if (Page.PreviousPage == null && Session["name"]!= null) { //Manage title and button visibility for Edit Profile EditProfileBtn.Visible = true; SignUpBtn.Visible = false; BackButton.Visible = true; SignUpTitle.Visible = false; EditProfileTitle.Visible = true; ResultLabel.Visible = false; email.ReadOnly = true; confEmail.ReadOnly = true; string emailString = Session["name"].ToString(); u = userControl.getProfileInfo(emailString); email.Text = u.Email; confEmail.Text = u.Email; firstName.Text = u.FirstName; lastName.Text = u.LastName; address.Text = u.Address; city.Text = u.City; DropDownList1.SelectedValue = u.State; zipCode.Text = u.Zip.ToString(); //Phone.Text = u.Phone; MobilePhone.Text = u.Phone; checkToText.Checked = u.Text; } } ServiceReference1.SUSMSClient isuService = new ServiceReference1.SUSMSClient(); string[] carriers = isuService.getCarriers(); if (carriers.Length > 0 && CarrierList.Items.Count <= 1) { foreach (string carrier in carriers) { CarrierList.Items.Add(new ListItem(carrier, carrier)); } } }
public List<User> getDesignersByItemId(string itemId) { List<User> uList = new List<User>(); int firstDigit = itemId.IndexOfAny("0123456789".ToCharArray()); string categoryID = itemId.Substring(0, firstDigit); string itemNumber = itemId.Substring(firstDigit); SqlConnection conn = DBHelper.loadDB(); String query = "SELECT * FROM USERINFO WHERE EMAIL IN (SELECT EMAIL FROM USERITEM WHERE ITEMID = @ITEMID)"; SqlCommand command = new SqlCommand(query, conn); command.Parameters.Add(new SqlParameter("@ITEMID", itemId)); try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { User u = new User() { UserID = Convert.ToInt32(reader["userid"]), Email = Convert.ToString(reader["email"]), FirstName = Convert.ToString(reader["firstname"]), LastName = Convert.ToString(reader["lastname"]), Address = Convert.ToString(reader["streetaddress"]), City = Convert.ToString(reader["city"]), State = Convert.ToString(reader["userstate"]), Zip = Convert.ToInt32(reader["zip"]), Admin = Convert.ToBoolean(reader["admin"]), Committee = Convert.ToBoolean(reader["committee"]), Phone = Convert.ToString(reader["phone"]), Text = Convert.ToBoolean(reader["text"]), Donor = Convert.ToBoolean(reader["donor"]), Carrier = Convert.ToString(reader["carrier"]) }; uList.Add(u); } } } catch (SqlException ex) { } return uList; }
private User readerToUser(SqlDataReader reader) { reader.Read(); User u = new User { UserID = Convert.ToInt32(reader["userid"]), Email = Convert.ToString(reader["email"]), FirstName = Convert.ToString(reader["firstname"]), LastName = Convert.ToString(reader["lastname"]), Address = Convert.ToString(reader["streetaddress"]), City = Convert.ToString(reader["city"]), State = Convert.ToString(reader["userstate"]), Zip = Convert.ToInt32(reader["zip"]), Admin = Convert.ToBoolean(reader["admin"]), Committee = Convert.ToBoolean(reader["committee"]), Donor = Convert.ToBoolean(reader["donor"]), Phone = Convert.ToString(reader["phone"]), Text = Convert.ToBoolean(reader["text"]), Carrier = Convert.ToString(reader["carrier"]) }; return u; }
private List<User> getArrayUser(SqlCommand command) { List<User> array = new List<User>(); try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { User u = new User { UserID = Convert.ToInt32(reader["userid"]), Email = Convert.ToString(reader["email"]), FirstName = Convert.ToString(reader["firstname"]), LastName = Convert.ToString(reader["lastname"]), Address = Convert.ToString(reader["streetaddress"]), City = Convert.ToString(reader["city"]), State = Convert.ToString(reader["userstate"]), Zip = Convert.ToInt32(reader["zip"]), Admin = Convert.ToBoolean(reader["admin"]), Committee = Convert.ToBoolean(reader["committee"]), Donor = Convert.ToBoolean(reader["donor"]), Phone = Convert.ToString(reader["phone"]), Text = Convert.ToBoolean(reader["text"]), Carrier = Convert.ToString(reader["carrier"]) }; array.Add(u); } } } catch (SqlException ex) { // error handling } return array; }
public int updateUser(User u) { SqlConnection conn = DBHelper.loadDB(); String query = "UPDATE USERINFO SET " + "FIRSTNAME = '" + u.FirstName + "', LASTNAME = '" + u.LastName + "', STREETADDRESS = '" + u.Address + "', CITY = '" + u.City + "', USERSTATE = '" + u.State + "', ZIP = '" + u.Zip + "', PHONE = '" + u.Phone + "', TEXT = '" + Convert.ToInt32(u.Text) + "', CARRIER = '" + u.Carrier + "' WHERE EMAIL = '" + u.Email + "';"; SqlCommand command = new SqlCommand(query, conn); int rows = command.ExecuteNonQuery(); return rows; }
public void createUser(User user) { SqlConnection conn = DBHelper.loadDB(); string query = "INSERT INTO USERINFO OUTPUT INSERTED.USERID VALUES (" + "'" + user.Email + "', '" + user.FirstName + "', '" + user.LastName + "', '" + user.Address + "', '" + user.City + "', '" + user.State + "', " + user.Zip + ", 0" + ", 0" + ", '" + user.Phone + "', " + user.Text + ", 0" + "," + user.Carrier + ")"; SqlCommand command = new SqlCommand(query, conn); user.UserID = (int)command.ExecuteScalar(); }
protected void SignUpBtn_Click(object sender, EventArgs e) { string role = Request.QueryString["role"]; bool ADMIN = false; bool COMMITTEE = false; bool DONOR = false; string EMAIL = email.Text; string FNAME = firstName.Text; string LNAME = lastName.Text; string ADDRESS = address.Text; string CITY = city.Text; string STATE = DropDownList1.SelectedValue; int ZIP = Convert.ToInt32(zipCode.Text); if (role.Equals("a")) { ADMIN = true; COMMITTEE = false; } if (role.Equals("s")) { ADMIN = false; COMMITTEE = true; } if (role.Equals("d")) { DONOR = true; } string HPHONE = Phone.Text; string MPHONE = MobilePhone.Text; bool TEXT = checkToText.Checked; string CARRIER = CarrierList.SelectedValue; //ID is produced in database toAdd = new User(-1, EMAIL, FNAME, LNAME, ADDRESS, CITY, STATE, ZIP, ADMIN, COMMITTEE, DONOR, MPHONE, TEXT, CARRIER); if (signUp.addUser(toAdd)) { signUp.addUserCredentials(email.Text, password1.Text); if (role.Equals("a")) { Request r = new Request() { RequestEmail = EMAIL, Admin = true, Committee = false, Donor = false }; UserCtrl uCtrl = new UserCtrl(); uCtrl.createRequest(r); } //Do we wnat to add a message here letting user know request was submitted successfully? Response.Redirect("Default.aspx?signup=1"); } else { //Is this the preferred action if a user is already signed up or sign up fails? Response.Redirect("Default.aspx"); } //This adds usercredentials right away ... needs to be modified if there is an approval action signUp.addUserCredentials(email.Text, password1.Text); }
protected void SignUpBtn_Click(object sender, EventArgs e) { string role = Request.QueryString["role"]; bool ADMIN = false; bool COMMITTEE = false; bool DONOR = false; string EMAIL = email.Text; string FNAME = firstName.Text; string LNAME = lastName.Text; string ADDRESS = address1.Text; string CITY = address2.Text; string STATE = DropDownList1.SelectedValue; int ZIP = Convert.ToInt32(zipCode.Text); if (role.Equals("a")) { ADMIN = true; COMMITTEE = false; } if (role.Equals("s")) { ADMIN = false; COMMITTEE = true; } if (role.Equals("d")) { DONOR = true; } string HPHONE = phone.Text; string MPHONE = TextBox1.Text; bool TEXT = checkToText.Checked; toAdd = new User() { Email = EMAIL, FirstName = FNAME, LastName = LNAME, Address = ADDRESS, City = CITY, State = STATE, Zip = ZIP, Admin = ADMIN, Committee = COMMITTEE, Donor = DONOR, Phone = MPHONE, Text = TEXT }; if (signUp.addUser(toAdd)) { //Do we wnat to add a message here letting user know request was submitted successfully? } else { //Is this the preferred action if a user is already signed up or sign up fails? Response.Redirect("Login.aspx"); } //This adds usercredentials right away ... needs to be modified if there is an approval action Credentials creds = new Credentials() { Email = EMAIL, Password = password1.Text.ToString() }; signUp.addUserCredentials(creds); }
public int updateUser(User user) { int admin = 0, committee = 0, donor = 0, text = 0; if (user.Admin) admin = 1; if (user.Committee) committee = 1; if (user.Donor) donor = 1; if (user.Text) text = 1; SqlConnection conn = DBHelper.loadDB(); String query = "UPDATE USERINFO SET " + "FIRSTNAME = '" + user.FirstName + "', LASTNAME = '" + user.LastName + "', STREETADDRESS = '" + user.Address + "', CITY = " + user.City + "', USERSTATE = '" + user.State + "', ZIP = " + user.Zip + ", PHONE = '" + user.Phone + "', ADMIN = '" + admin + ", COMMITTEE = '" + committee + ", DONOR = '" + donor + ", TEXT = '" + text + " WHERE EMAIL = '" + user.Email + "';"; SqlCommand command = new SqlCommand(query, conn); int rows = command.ExecuteNonQuery(); return rows; }