public void updateAccount(AccountCredentials acc) { string connectionString = @"Data Source=cdb.c1lbyzt9l8fn.us-west-2.rds.amazonaws.com,1433;" + "Initial Catalog=cis;" + "User id=sonaaaa;" + "Password=mo7senzzzz;"; SqlConnection myConnection = new SqlConnection(connectionString); myConnection.Open(); SqlCommand myCommand = new SqlCommand(); myCommand.CommandText = "UPDATE Accounts SET id =" + acc.getID().ToString() + ",PNumber ='" + acc.getPhoneNumber() + "',Email ='" + acc.getEmail() + "', Password ='******', FName = '" + acc.getFName() + "', LName = '" + acc.getLName() + "' WHERE id = " + acc.getID() + ";"; myCommand.Connection = myConnection; myCommand.ExecuteNonQuery(); myConnection.Close(); }
public void insertAccount(AccountCredentials acc) { string connectionString = @"Data Source=cdb.c1lbyzt9l8fn.us-west-2.rds.amazonaws.com,1433;" + "Initial Catalog=cis;" + "User id=sonaaaa;" + "Password=mo7senzzzz;"; SqlConnection myConnection = new SqlConnection(connectionString); myConnection.Open(); SqlCommand myCommand = new SqlCommand(); myCommand.CommandText = "insert into Accounts (Pnumber,Email,Password,Fname,Lname) Values ('" + acc.getPhoneNumber() + "','" + acc.getEmail() + "','" + acc.getPassword() + "','" + acc.getFName() + "','" + acc.getLName() + "') ; "; myCommand.Connection = myConnection; myCommand.ExecuteNonQuery(); myConnection.Close(); }
protected void ButtonSignupSubmit_Click(object sender, EventArgs e) { if (TextboxSignupPassword.Text == TextboxSignupConfirmPassword.Text) { string fName = this.TextboxSignupFirstname.Text; string lName = this.TextboxSignupLastname.Text; string email = this.TextboxSignupEmail.Text; string password = this.TextboxSignupPassword.Text; string phone = this.TextboxSignupMobile.Text; WebApplication1.scripts.AccountCredentials acc = new scripts.AccountCredentials(); acc.setFName(fName); acc.setLName(lName); acc.setEmail(email); acc.setPassword(password); acc.setPhoneNumber(phone); WebApplication1.scripts.AccountDAO dao = new scripts.AccountDAO(); if (dao.getIdByPhoneNumber(phone) == -1) { dao.insertAccount(acc); ClientScriptManager cs = Page.ClientScript; Type cstype = this.GetType(); String alert = "alert('registeration completed');"; cs.RegisterStartupScript(cstype, "PopupScript", alert, true); Response.Redirect(Page.ResolveClientUrl("login.aspx")); } else { ClientScriptManager cs = Page.ClientScript; Type cstype = this.GetType(); String alert = "alert('this phone number is already registered ');"; cs.RegisterStartupScript(cstype, "PopupScript", alert, true); } } else { Response.Write("<script language=javascript>alert('password and confirm password does not match');</script>"); } }
protected void ButtonLoginSubmit_Click(object sender, EventArgs e) { string phone = this.TextboxLoginMobile.Text; string password = this.TextboxLoginPassword.Text; WebApplication1.scripts.AccountDAO dao = new scripts.AccountDAO(); WebApplication1.scripts.AccountCredentials acc = new scripts.AccountCredentials(); int id = dao.getIdByPhoneNumber(phone); if (id == -1) { //not regestierd ClientScriptManager cs = Page.ClientScript; Type cstype = this.GetType(); String alert = "alert('this phone number is not registered');"; cs.RegisterStartupScript(cstype, "PopupScript", alert, true); } else { //phone number exist acc = dao.getAccountById(id); if (acc.getPassword() != password) { //wrong password ClientScriptManager cs = Page.ClientScript; Type cstype = this.GetType(); String alert = "alert('wrong password');"; cs.RegisterStartupScript(cstype, "PopupScript", alert, true); } else { //access granted Session["id"] = id; Response.Redirect(Page.ResolveClientUrl("../users/book/book.aspx")); } } }