コード例 #1
0
        public async Task Create()
        {
            EmployeesController eCtrl = new EmployeesController();

            employeesGUI        = EmployeesGUI.Instance;
            lblTitle.Text       = "Create Employee";
            BtnSaveChanges.Text = "Create";
            var venuesList = new List <Venue>();

            try {
                List <Venue> venues = await eCtrl.GetVenues(sCtrl.EmployeeId);

                foreach (Venue v in venues)
                {
                    venuesList.Add(v);
                }
                cbVenueID.DataSource = venuesList;
            }
            catch (Exception) {
                MessageBox.Show("No connection to service");
            }
            create          = true;
            tbName.Text     = "";
            tbPhone.Text    = "";
            tbEmail.Text    = "";
            tbPassword.Text = "";
            lblEmployeeNo.Hide();
            tbEmployeeNo.Hide();
            tbEmployeeTitle.Text = "";
        }
コード例 #2
0
        public async void Edit()
        {
            EmployeesController eCtrl = new EmployeesController();
            VenuesController    vCtrl = new VenuesController();

            employeesGUI = EmployeesGUI.Instance;

            try {
                editedEmployee = await eCtrl.Get(employeesGUI.IdFromTable);

                create              = false;
                lblTitle.Text       = "Edit Employee";
                BtnSaveChanges.Text = "Save changes";
                tbName.Text         = editedEmployee.Name;
                tbPhone.Text        = editedEmployee.Phone;
                tbEmail.Text        = editedEmployee.Email;
                tbPassword.Text     = editedEmployee.Password;
                lblEmployeeNo.Show();
                tbEmployeeNo.Show();
                tbEmployeeNo.Enabled = false;
                tbEmployeeNo.Text    = "" + editedEmployee.EmployeeNo;
                tbEmployeeTitle.Text = editedEmployee.Title;
                var venuesList = new List <Venue>();
                foreach (Venue v in editedEmployee.Venues)
                {
                    venuesList.Add(v);
                }
                // Finding venue from venueID on table and adding it to combobox.

                cbVenueID.DataSource = venuesList;
            }
            catch (Exception) {
                MessageBox.Show("No connection to service");
                this.Visible = false;
            }
            // Resetting idFromTable to remove possibility to show other employees tables
            employeesGUI.IdFromTable = -1;
        }