Esempio n. 1
0
        private void button_save_Click(object sender, EventArgs e)
        {
            string      userName          = richTextBox_userName.Text;
            string      password          = richTextBox_password.Text;
            UserAccount newUserAccount    = new UserAccount(userName, password);
            Boolean     isAddedToAccounts = UserAccountsData.addUserAccount(newUserAccount);

            if (isAddedToAccounts)
            {
                MessageBox.Show("User Account successfully added");
            }
            else
            {
                MessageBox.Show("User Account existed");
                return;
            }

            Form            mainForm        = Application.OpenForms["UserAccountForm"];
            UserAccountForm userAccountForm = (UserAccountForm)mainForm;


            userAccountForm.userAccountUserControl.reloadList();

            this.Close();
        }
Esempio n. 2
0
        private void button_save_Click(object sender, EventArgs e)
        {
            string username = richTextBox_userName.Text;
            string password = richTextBox_password.Text;

            UserAccount editedUserAccount = new UserAccount(username, password);

            UserAccountsData.updateInformation(editedUserAccount);
            this.Close();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            List <UserAccount> currentUserAccounts = new List <UserAccount>();

            currentUserAccounts = UserAccountsData.initializeAccount();
            List <Customer> currentListOfCustomers = new List <Customer>();

            currentListOfCustomers = CustomersData.initializeData();
            List <Sales> currentListOfSales = new List <Sales>();

            currentListOfSales = SalesData.initializeData();
        }
        private void button_login_Click(object sender, EventArgs e)
        {
            string username = txt_UserID.Text;
            string password = txt_Password.Text;

            Boolean isAllowed = UserAccountsData.checkAuthorization(new UserAccount(username, password));

            if (isAllowed)
            {
                MainMenu mainMenu = new MainMenu();
                mainMenu.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Invalid user account or password", "please retry");
            }
        }
        private void button_deleteUserAccount_Click(object sender, EventArgs e)
        {
            if (UserAccountsData.userAccounts.Count <= 1)
            {
                MessageBox.Show("There is only one account left");
            }
            else
            {
                UserAccount currentUserAccount = (UserAccount)dataGridView_userAccount.CurrentRow.DataBoundItem;

                var confirmResult = MessageBox.Show("Are you sure to delete user account: " + currentUserAccount.UserName + " ?",
                                                    "Delete Confirmation",
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    UserAccountsData.deleteUserAccount(currentUserAccount);
                }
                else
                {
                    // If 'No', do something here.
                }
                reloadList();
            }
        }