Ejemplo n.º 1
0
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            // Return error if no valid items in Combo Box Locker Type is selected
            if (comboBoxLockerType.SelectedIndex < 0)
            {
                MessageBox.Show("Input Error: Invalid input detected!" + Environment.NewLine +
                                "Please ensure that field 'Locker Type' was filled with provided items. ",
                                "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Get the Locker Type Id of the cabinet using the value of comboBoxLockerType, and parse to int
            int selectedLockerTypeId = Int32.Parse(comboBoxLockerType.SelectedValue.ToString());

            // Set the Cabinet Data and Save it
            CabinetLockerController cabinetController = new CabinetLockerController();

            cabinetController.SetCabinetData(textBoxCabinetCode.Text, selectedLockerTypeId,
                                             (int)numericUpDownRow.Value, (int)numericUpDownColumn.Value);
            cabinetController.SaveCabinetData();

            // Set the insert complete boolean as true
            _isInsertComplete = true;

            // Exit this form
            this.Close();
        }