Exemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SQL_Data data = new SQL_Data();
            string   result;


            if (ViewState["Register"].ToString() != "True")
            {
                result = data.VerifyUser(userTB.Text);
            }

            else if (passTB.Text == "" || conpassTB.Text == "")
            {
                Response.Write("Input your password first.");
            }

            //else if (userTB.Text != select.Parameters)
            //{
            //    Response.Write("User already exists.");
            //}


            else if (userTB.Text == "")
            {
                Response.Write("Input a username.");
            }

            else if (passTB.Text != conpassTB.Text)
            {
                Response.Write("Your passwords do not match.");
            }

            else if (passTB.Text == conpassTB.Text)
            {
                SqlCommand insert = new SqlCommand("insert into Users(Usernames, Passwords) values(@Usernames, @Passwords)", data.connection);
                insert.Parameters.AddWithValue("@Usernames", userTB.Text);
                insert.Parameters.AddWithValue("@Passwords", Hash.EncryptionString(passTB.Text));

                try
                {
                    data.connection.Open();
                    insert.ExecuteNonQuery();
                    Response.Write("Registration completed.");
                    Response.Redirect("Login.aspx");
                }
                catch (Exception ex)
                {
                    Response.Write("An error has occured: " + ex.Message);
                    data.connection.Close();
                }
            }
        }
Exemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string myStringVariable = string.Empty;

            string result = "";

            if (ViewState["Login"].ToString() != "True")
            {
                using (SQL_Data data = new SQL_Data())
                {
                    result = data.Verification(userTB.Text, passTB.Text);
                }

                myStringVariable = result;

                if (result == "Proceed")
                {
                    ViewState["Login"] = "******";
                    Session["User"]    = userTB.Text;
                    Response.Redirect("Default.aspx");
                }
            }
            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
        }
Exemplo n.º 3
0
        protected void Application_End(object sender, EventArgs e)
        {
            SQL_Data data = new SQL_Data();

            data.LogWrite("Application has ended");
        }
Exemplo n.º 4
0
        protected void Application_Error(object sender, EventArgs e)
        {
            SQL_Data data = new SQL_Data();

            data.LogWrite("An error has occured with the application");
        }
Exemplo n.º 5
0
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            SQL_Data data = new SQL_Data();

            data.LogWrite("Application has a new request");
        }
Exemplo n.º 6
0
        protected void Session_Start(object sender, EventArgs e)
        {
            SQL_Data data = new SQL_Data();

            data.LogWrite("Session has started");
        }
Exemplo n.º 7
0
        protected void Application_Init(object sender, EventArgs e)
        {
            SQL_Data data = new SQL_Data();

            data.LogWrite("Application has initialized");
        }