Exemplo n.º 1
0
        protected void btnlogin_Click(object sender, EventArgs e)
        {
            var db = new stjupDataContext();

            var login = from log in db.users select log;


            foreach (user u in login)
            {
                if ((txtusername.Value).Equals(u.Username) && (txtpass.Value).Equals(u.Passwor))
                {
                    Response.Redirect("product.aspx");
                }
                else
                {
                    report.InnerHtml = "Username or/and Password invalid.";
                }
            }
        }
Exemplo n.º 2
0
        protected void btncreate_Click(object sender, EventArgs e)
        {
            var     db  = new stjupDataContext();
            dynamic ifm = from st in db.users
                          select st;
            bool isReg = false;

            foreach (user u in ifm)
            {
                if ((txtusername.Value).Equals(u.Username) && (txtpass.Value).Equals(u.Passwor))
                {
                    isReg            = true;
                    report.InnerHtml = "<br/>" + "<br/>" + "<br/>" + "user already exist";
                }
            }

            if (isReg == false)
            {
                var regUser = new user
                {
                    Username = txtusername.Value,
                    Passwor  = txtpass.Value,
                };
                db.users.InsertOnSubmit(regUser);

                try
                {
                    db.SubmitChanges();
                    Response.Redirect("login.aspx");
                }
                catch (Exception ex)
                {
                    ex.GetBaseException();
                    report.InnerHtml = "Something went Wrong";
                }
            }
        }