Пример #1
0
        public void confirmBtn(object sender, EventArgs e)
        {
            signupWarning.Visible = false;
            if (credsCheck())
            {
                //check for email in use
                DataTable DT_EMAILCHECK = SQL.SQLcommand(@"Select * from users");
                foreach (DataRow row in DT_EMAILCHECK.Rows)
                {
                    if (email.Text == row[1].ToString()) //already used email
                    {
                        signupWarning.Visible = true;
                        return;
                    }
                }

                //add user
                SQL.add_to_db(@"Select add_user('" + email.Text + "'," + "'" + password.Text + "'," +
                              storeOwner.Checked + ");");

                if (!storeOwner.Checked) //load user page
                {
                    UserPage up = new UserPage();
                    up.UserEmail     = email.Text;
                    up.Location      = this.Location;
                    up.StartPosition = FormStartPosition.CenterScreen;
                    this.Hide();
                    up.Show();
                    return;
                }
                else
                {
                    SQL.add_to_db(string.Format(@"insert into owner values (0.00,'{0}')", email.Text));
                    OwnerPage op = new OwnerPage(email.Text);
                    op.Location      = this.Location;
                    op.StartPosition = FormStartPosition.CenterScreen;
                    this.Hide();
                    op.Show();
                }
            }
            else
            {
                signupWarning.Visible = true;
                return;
            }
        }
Пример #2
0
        public void login(object sender, EventArgs e)
        {
            //clear bad login warning
            loginWarning.Visible = false;

            //get data
            DataTable dt = SQL.SQLcommand(@"Select * from logins");

            //check if there is data
            if (dt != null)
            {
                foreach (DataRow row in dt.Rows)
                {
                    if (email.Text == row[0].ToString() && password.Text == row[1].ToString()) //good login
                    {
                        if (!(bool)row[2])                                                     //user page
                        {
                            UserPage up = new UserPage();
                            up.UserEmail     = email.Text;
                            up.Location      = this.Location;
                            up.StartPosition = FormStartPosition.CenterScreen;
                            this.Hide();
                            up.Show();
                        }
                        else //owner page
                        {
                            //show owner page
                            OwnerPage op = new OwnerPage(email.Text);
                            op.Location      = this.Location;
                            op.StartPosition = FormStartPosition.CenterScreen;
                            this.Hide();
                            op.Show();
                        }
                        return;
                    }
                }
                loginWarning.Visible = true;
                return;
            }
        }