Exemplo n.º 1
0
        public AccountCredentials getAccountById(int id)
        {
            AccountCredentials acc = new AccountCredentials();
            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 = "Select * from Accounts where id = '" + id + "';";
            myCommand.Connection  = myConnection;
            SqlDataReader reader = myCommand.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    acc.setID(reader.GetInt32(reader.GetOrdinal("id")));
                    acc.setPhoneNumber(Convert.ToString(reader[1]));
                    acc.setEmail(Convert.ToString(reader[2]));
                    acc.setPassword(Convert.ToString(reader[3]));
                    acc.setFName(Convert.ToString(reader[4]));
                    acc.setLName(Convert.ToString(reader[5]));
                }
            }

            reader.Close();
            myConnection.Close();

            return(acc);
        }
Exemplo n.º 2
0
        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>");
            }
        }