Exemple #1
0
        private void add_bSaveNewDevice_Click(object sender, EventArgs e)
        {
            var _controller = new DeviceController();

            bool enabled = add_rbTrue.Checked && !add_rbFalse.Checked;
            _selectedDevice = _controller.GetDeviceObject(Convert.ToInt32(add_tId.Text), add_tName.Text,
                add_tLocation.Text, add_tCustodian.Text, enabled);

            var newDevice = _controller.SaveDevice(_selectedDevice);
            _selectedDevice = newDevice;

            if (newDevice== null)
            {
                MessageBox.Show("There was an error saving the Device...");
            }
        }
Exemple #2
0
        private void modify_bSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Update the global object with any updates values.
                _selectedDevice.Name = modify_tDevName.Text;
                _selectedDevice.Custodian = modify_tCustodian.Text;
                _selectedDevice.Location = modify_tLocation.Text;
                _selectedDevice.Enabled = modify_rbTrue.Checked;

                //Create new Device Controller.
                var controller = new DeviceController();

                //Save the Device.
                var savedDevice = controller.SaveDevice(_selectedDevice);

                //If the updated device is null or has been corupted (i.e. wrong device info), error!
                if (savedDevice == null || savedDevice.Id != _selectedDevice.Id)
                {
                    MessageBox.Show("There was an error saving the Device...", _selectedDevice.ToString());
                }
                else
                {
                    //Updated the global variable with a database replica.
                    //(Should not change the object properties).
                    _selectedDevice = savedDevice;

                    //Inform the user
                    DebugOutput.Print("Device was updated successfully. ", _selectedDevice.ToString());
                }
            }
            catch (Exception ex)
            {
                DebugOutput.Print("Could not save data for selected object. ", ex.Message);
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     var cont = new DeviceController();
     cont.SaveDevice(localisedDevice);
 }