protected void searchDataBtn_Click(object sender, EventArgs e) { this.errorLabel.Visible = false; string tableName = this.TableSelector.Text; string searchParam = this.SerchBySelector.Text; string valueToSearch = this.SearchBarTB.Text; localhost.GigaGalleryWS ws = new localhost.GigaGalleryWS(); DataTable dt = ws.SelectEntireTable(tableName); DataTable searchResults = new DataTable("searchResultsTable"); if (dt.Columns.Contains(searchParam)) { foreach (DataRow dr in dt.Rows) { if (dr[searchParam].ToString().ToLower() == valueToSearch.ToLower().Trim()) { searchResults.ImportRow(dr); } } // Update grid view and make visible. if (searchResults.Rows.Count > 0) { this.searchResultsDL.DataSource = searchResults; this.searchResultsDL.DataBind(); // Debug gridview not displaying data. } else { this.errorLabel.Text = "Search did not yield any results!"; this.errorLabel.Visible = true; } } }
protected void addUserBtn_Click(object sender, EventArgs e) { this.errorLabel.Visible = false; string username = this.usernameTB.Text; string email = this.emailTB.Text; string password = this.passwordTB.Text; bool isAdmin = this.isAdminCB.Checked; DateTime birthday = default(DateTime); try { birthday = DateTime.Parse(this.birthdayTB.Text); } catch { this.errorLabel.Text = "Error!"; this.errorLabel.Visible = true; return; } // Validate Data: localhost.UserValidationWS validationWS = new localhost.UserValidationWS(); if (!validationWS.isUsernameValid(username)) { this.errorLabel.Text = validationWS.usernameLengthInvalidMessage(); this.errorLabel.Visible = true; return; } if (!validationWS.isEmailLengthValid(email)) { this.errorLabel.Text = validationWS.emailLengthInvalidMessage(); this.errorLabel.Visible = true; return; } if (!validationWS.isPasswordValid(password)) { this.errorLabel.Text = validationWS.passwordLengthInvalidMessage(); this.errorLabel.Visible = true; return; } localhost.GigaGalleryWS dbWS = new localhost.GigaGalleryWS(); try { dbWS.AdminAddUser(username, email, password, birthday, isAdmin); } catch { this.errorLabel.Text = "Error!"; this.errorLabel.Visible = true; return; } Response.Redirect(Page.Request.Url.ToString(), true); }
protected void submitBtn_Click(object sender, EventArgs e) { if (emailTB.Text == "") { RequiredEmailLabel.Visible = true; return; } else { RequiredEmailLabel.Visible = false; } if (passwordTB.Text == "") { RequiredPasswordLabel.Visible = true; return; } else { RequiredPasswordLabel.Visible = false; } localhost.GigaGalleryWS ws = new localhost.GigaGalleryWS(); try { if (ws.Login(emailTB.Text, passwordTB.Text)) { localhost.User userObj = ws.GetUserObj(emailTB.Text); Session["pUser"] = userObj; Session["pUserId"] = userObj.UserId; if (userObj.IsAdmin) { Response.Redirect("AdminPage.aspx"); } else { Response.Redirect("HomePage.aspx"); } } else { ErrorLabel.Text = "Login Failed! Email or Password are incorrect."; } } catch { ErrorLabel.Text = "Login Failed! Email or Password are incorrect."; } }
protected void updateDropDownParams(object sender, EventArgs e) { this.errorLabel.Visible = false; string tableName = this.TableSelector.Text; localhost.GigaGalleryWS ws = new localhost.GigaGalleryWS(); this.SerchBySelector.Items.Clear(); DataTable schema = ws.GetTableSchema(tableName); if (schema != null) { foreach (DataRow dr in schema.Rows) { this.SerchBySelector.Items.Insert(0, dr["COLUMN_NAME"].ToString()); } } else { this.errorLabel.Text = "Error!"; this.errorLabel.Visible = true; } }
protected void submitBtnClick(object sender, EventArgs e) { string username = this.usernameTB.Text; string email = this.emailTB.Text; string password = this.passwordTB.Text; string confirmPassword = this.passwordConfirmTB.Text; DateTime birthday = default(DateTime); try { birthday = DateTime.Parse(this.birthdayTB.Text); } catch { this.birthdayErrorLabel.Text = "Invalid birthday!"; this.birthdayErrorLabel.Visible = true; return; } // Validate Data: localhost.UserValidationWS validationWS = new localhost.UserValidationWS(); if (!validationWS.isUsernameValid(username)) { this.usernameErrorLabel.Text = validationWS.usernameLengthInvalidMessage(); this.usernameErrorLabel.Visible = true; return; } if (!validationWS.isEmailLengthValid(email)) { this.emailErrorLabel.Text = validationWS.emailLengthInvalidMessage(); this.emailErrorLabel.Visible = true; return; } if (!validationWS.isPasswordValid(password)) { this.passwordErrorLabel.Text = validationWS.passwordLengthInvalidMessage(); this.passwordErrorLabel.Visible = true; return; } if (password != confirmPassword) { this.passwordErrorLabel.Text = "Passwords do not match!"; this.passwordErrorLabel.Visible = true; return; } localhost.GigaGalleryWS dbWS = new localhost.GigaGalleryWS(); bool result = false; try { result = dbWS.Signup(username, email, password, birthday); } catch { this.errorLabel.Text = "Error!"; this.errorLabel.Visible = true; return; } if (result) { Response.Redirect("Login.aspx"); } else { this.errorLabel.Text = "Error!"; this.errorLabel.Visible = true; return; } }