Пример #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Program.logEvent("User selected to add a new user");
            try
            {
                YesNoForm doAnotherDlg = new YesNoForm(LanguageTranslation.ADD_ANOTHER_USER);
                do
                {
                    string IDNumber = "";

                    //need to add swipe feature  TBD

                    LongNameEntryForm IDForm = new LongNameEntryForm(Program.USER_ID_LENGTH, false, false);
                    IDForm.UseSpaceBar = true;
                    IDForm.DialogTitle = LanguageTranslation.ENTER_ID;
                    IDForm.ShowDialog();

                    if (IDForm.Ok)
                    {
                        IDNumber = IDForm.Description;
                        Program.logEvent("User entered new user ID: " + IDNumber);

                        if (!Program.userMgr.IsUnique(IDNumber))
                        {
                            Program.logEvent("The user ID Number entered is not unique. User not added");
                            Program.ShowErrorMessage(LanguageTranslation.ID_NUM_NOT_UNIQUE, 3000);
                            return;
                        }
                    }
                    else
                    {
                        Program.logEvent("User cancelled addition");
                        return;
                    }

                    User user = new User(IDNumber);
                    AddUser(user);
                    Program.ShowErrorMessage(LanguageTranslation.USER_ADDED, 2500);

                    ModifyUsersForm ModifyNewUser = new ModifyUsersForm(user);
                    ModifyNewUser.ShowDialog();

                    doAnotherDlg.ShowDialog();
                } while (doAnotherDlg.YesResult);

                Program.userMgr.SaveFile();

                threeDArrayCreateAndSort();
            }
            catch (Exception ex)
            {
                throw new Exception("AddUsersForm:AddUser exception: " + ex.Message);
            }
        }
Пример #2
0
        private void buttonChange_Click(object sender, EventArgs e)
        {
            try
            {
                Program.logEvent("User selected to modify a user");
                LongNameEntryForm IDEntry = new LongNameEntryForm(Program.USER_ID_LENGTH, false, false);
                IDEntry.InitialString = "";
                IDEntry.DialogTitle   = LanguageTranslation.ENTER_USER_ID_MODIFY;
                IDEntry.ShowDialog();
                Program.logEvent("User selected for modification ID Number: " + IDEntry.Description);

                User moduser = Program.userMgr.GetUser(IDEntry.Description);
                if (moduser != null)
                {
                    ModifyUsersForm ModForm = new ModifyUsersForm(moduser);
                    ModForm.ShowDialog();
                    if (!ModForm.Cancelled)
                    {
                        Program.logEvent("User modified with ID Number: " + IDEntry.Description);
                        threeDArrayCreateAndSort();
                    }
                    else
                    {
                        Program.logEvent("User modification cancelled");
                    }
                }
                else
                {
                    if (!IDEntry.Ok)
                    {
                        Program.ShowErrorMessage(LanguageTranslation.USER_NOT_EXIST, 4000);
                    }
                    Program.logEvent("User with ID Number " + IDEntry.Description + " does not exist");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("AddUsersForm:AddUser exception: " + ex.Message);
            }
        }