Esempio n. 1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
            {
                return;
            }

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // create new account
            Common.Account account = new Common.Account();

            // set account properties
            account.ID           = Guid.NewGuid();
            account.EmailAddress = this.txtEmailAddress.Text;
            account.Password     = Utilities.HashPassword(this.txtPassword.Text);
            account.Type         = 1;
            account.CreatedDate  = DateTime.UtcNow;

            // insert account to database
            db.Accounts.InsertOnSubmit(account);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to default page
            Response.Redirect("~/login.aspx?success=true");
        }
Esempio n. 2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
            {
                return;
            }

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current account
            Common.Account account = db.Accounts.SingleOrDefault(z => z.ID == (Session["CurrentAccount"] as Common.Account).ID);

            // set schedule properties
            account.EmailAddress = this.txtEmailAddress.Text;
            if (this.txtPassword.Text.Length > 0)
            {
                account.Password = Utilities.HashPassword(this.txtPassword.Text);
            }

            // update schedule in database
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // update schedule in session
            Session["CurrentAccount"] = account;

            // bind data to page
            this.BindData();
        }
Esempio n. 3
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // create new account
            Common.Account account = new Common.Account();

            // set account properties
            account.ID = Guid.NewGuid();
            account.EmailAddress = this.txtEmailAddress.Text;
            account.Password = Utilities.HashPassword(this.txtPassword.Text);
            account.Type = 1;
            account.CreatedDate = DateTime.UtcNow;

            // insert account to database
            db.Accounts.InsertOnSubmit(account);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to default page
            Response.Redirect("~/login.aspx?success=true");
        }
Esempio n. 4
0
        private void BindData()
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current account
            Common.Account account = db.Accounts.SingleOrDefault(z => z.ID == (Session["CurrentAccount"] as Common.Account).ID);

            // set form properties
            this.txtEmailAddress.Text = account.EmailAddress;

            // close connection
            db.Dispose();
        }
Esempio n. 5
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current account
            Common.Account account = db.Accounts.SingleOrDefault(z => z.ID == (Session["CurrentAccount"] as Common.Account).ID);

            // delete account from database
            db.Accounts.DeleteOnSubmit(account);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to logout page
            Response.Redirect("~/logout.aspx");
        }
 partial void DeleteAccount(Account instance);
 partial void UpdateAccount(Account instance);
 partial void InsertAccount(Account instance);