Example #1
0
        //Submit button modifies worker
        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            String banner     = BannerBox.Text;
            String first      = FirstNameBox.Text;
            String last       = LastNameBox.Text;
            String phone      = PhoneBox.Text;
            String email      = EmailBox.Text;
            String credential = CredentialBox.Text;
            String password   = PasswordBox.Password;
            String status     = StatusBox.Text;
            String notes      = NotesBox.Text;

            w.BannerID          = banner;
            w.FirstName         = first;
            w.LastName          = last;
            w.PhoneNumber       = phone;
            w.EmailAddress      = email;
            w.Credential        = credential;
            w.WorkerPassword    = password;
            w.Status            = status;
            w.DateStatusUpdated = DateTime.Now.ToString("yyyy-MM-dd");
            w.Notes             = notes;
            w.update();
            MessageBox.Show("Modified Worker successfully.");
            this.Hide();
            myCaller.Show();
        }
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            if (FormAction.Equals("insert"))
            {
                string bannerID       = BannerIDBox.Text;
                string firstName      = FirstNameBox.Text;
                string lastName       = LastNameBox.Text;
                string phoneNumber    = PhoneNumberBox.Text;
                string email          = EmailBox.Text;
                string credential     = Convert.ToString(CredentialComboBox.SelectedItem);
                string workerPassword = WorkerPasswordBox.Text;
                string notes          = NotesBox.Text;
                string status         = Convert.ToString(StatusComboBox.SelectedItem);

                Worker newWorker = new Worker(bannerID, firstName, lastName, phoneNumber,
                                              email, credential, workerPassword, notes, status);
                newWorker.insert();

                System.Windows.Forms.MessageBox.Show("Worker insert successful!");

                this.Hide();
                myCaller.Show();
            }
            else if (FormAction.Equals("update"))
            {
                Worker existingWorker = new Worker();
                existingWorker.populateBannerID(id);

                existingWorker.BannerID       = BannerIDBox.Text;
                existingWorker.FirstName      = FirstNameBox.Text;
                existingWorker.LastName       = LastNameBox.Text;
                existingWorker.PhoneNumber    = PhoneNumberBox.Text;
                existingWorker.EmailAddress   = EmailBox.Text;
                existingWorker.Credential     = Convert.ToString(CredentialComboBox.SelectedItem);
                existingWorker.WorkerPassword = WorkerPasswordBox.Text;
                existingWorker.Notes          = NotesBox.Text;
                existingWorker.Status         = Convert.ToString(StatusComboBox.SelectedItem);

                existingWorker.update();

                System.Windows.Forms.MessageBox.Show("Worker update successful!");

                this.Hide();
                mainMenu.Show();
            }
            else if (FormAction.Equals("delete"))
            {
                Worker existingWorker = new Worker();
                existingWorker.populateBannerID(id);

                existingWorker.delete();

                System.Windows.Forms.MessageBox.Show("Worker deletion successful!");

                this.Hide();
                mainMenu.Show();
            }
        }