示例#1
0
        //called when user tries to log in
        private void button1_Click(object sender, EventArgs e)
        {
            accountNumber = accountNumberBox.Text.ToString();
            if (String.IsNullOrEmpty(accountNumber))
            {
                errorLabel.Text = "Enter your account number!";
            }

            int recordCount = 0;         //the number of accounts found

            List <string>[] loyaltyData; //the loyalty account data to be found

            //connect to DB if it is not connected
            if (!db.Connected())
            {
                db.OpenConnection();
            }

            //Get the loyalty account data from the database and save amount found in record count
            recordCount = db.getLoyaltyAccountInfo(out loyaltyData, accountNumber);

            if (recordCount <= 0) //if 0 or less are found, loyalty account was not found or function failed
            {
                errorLabel.Text = "Loyalty account not found!";
            }

            else
            {
                NSAKidsMeal mainForm = new NSAKidsMeal(ci, loyaltyData);
                mainForm.FormClosed += new FormClosedEventHandler(LogIn_FormClosed);
                mainForm.Show();
                Hide();
            }
        }
示例#2
0
        //called when user tries to create an account
        private void createLoyaltyBut_Click(object sender, EventArgs e)
        {
            //get text box text
            name  = nameTextBox.Text.ToString();
            email = emailTextBox.Text;
            if (String.IsNullOrEmpty(name))
            {
                errorLabel.Text = "Enter your name!";
            }

            else if (String.IsNullOrEmpty(email))
            {
                errorLabel.Text = "Enter your email!";
            }

            else
            {
                if (!db.Connected())
                {
                    db.OpenConnection();
                }

                //create the loyalty account and save the account number
                string accountNumber = db.createLoyaltyAccount(name, email);

                if (accountNumber != "FAIL")
                {
                    List <string>[] accountInfo = new List <string> [4];
                    accountInfo[0] = new List <string>();
                    accountInfo[1] = new List <string>();
                    accountInfo[2] = new List <string>();
                    accountInfo[3] = new List <string>();

                    accountInfo[0].Add(name);
                    accountInfo[1].Add(email);
                    accountInfo[2].Add("0");
                    accountInfo[3].Add(accountNumber);
                    NSAKidsMeal form = new NSAKidsMeal(ci, accountInfo); //send info to KioskWindow
                    form.Show();
                    form.FormClosed += new FormClosedEventHandler(CreateLoyalty_FormClosed);
                    Hide();
                }

                else
                {
                    errorLabel.Text = "SYSTEM IS DOWN";
                }
            }
        }
示例#3
0
        private void btnDeleteLoyaltyAccount_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(rm.GetString("askdelete1", ci) + Environment.NewLine + rm.GetString("askdelete2", ci), rm.GetString("askdeletecaption", ci), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (result == DialogResult.Yes)
            {
                if (db.Connected() && account != null)
                {
                    string query = "DELETE FROM loyaltyaccounts WHERE loyaltyid = " + account.getAccountNumber().ToString() +
                                   " and storeid = " + db.StoreNumber1.ToString() + ";";

                    //Create MySQL Command object.
                    MySqlCommand cmd = new MySqlCommand(query, db.Connection1);

                    //Create a MySQL reader and Execute the query
                    cmd.ExecuteNonQuery();

                    this.Close();
                }
            }
        }