Ejemplo n.º 1
0
        // shows the form in edit modus
        // links:
        //  docLink: http://sql2x.org/documentationLink/49afd26c-4f21-4992-967b-be190eacef77
        public void ShowAsEdit(System.Guid aircraftId)
        {
            var service = new CrudeAircraftServiceClient();

            _isNew = false;
            try {
                _contract = service.FetchByAircraftId(aircraftId);
                textBoxAircraftName.Text                  = _contract.AircraftName;
                aircraftTypeRefCombo.Text                 = _contract.AircraftTypeRcd != null ? _contract.AircraftTypeRcd : String.Empty;
                aircraftConfigurationRefCombo.Text        = _contract.AircraftConfigurationRcd != null ? _contract.AircraftConfigurationRcd : String.Empty;
                aircraftBodyRefCombo.Text                 = _contract.AircraftBodyRcd != null ? _contract.AircraftBodyRcd : String.Empty;
                dateTimePickerOperationalDateTime.Value   = _contract.OperationalDateTime != DateTime.MinValue ? _contract.OperationalDateTime : dateTimePickerOperationalDateTime.MinDate;
                dateTimePickerOperationalDateTime.Checked = _contract.OperationalDateTime != DateTime.MinValue;
                dateTimePickerFirstFlightDateTime.Value   = _contract.FirstFlightDateTime != DateTime.MinValue ? _contract.FirstFlightDateTime : dateTimePickerFirstFlightDateTime.MinDate;
                dateTimePickerFirstFlightDateTime.Checked = _contract.FirstFlightDateTime != DateTime.MinValue;
                textBoxEngineType.Text = _contract.EngineType;
                maskedTextBoxPassengerCapacity.Text = _contract.PassengerCapacity.ToString();
                userPicker.SelectedValue            = _contract.UserId;
                _contract.DateTime          = DateTime.UtcNow;
                dateTimePickerDateTime.Text = _contract.DateTime.ToString();

                Show();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                service.Close();
            }
        }
Ejemplo n.º 2
0
        // save and close Aircraft
        // links:
        //  docLink: http://sql2x.org/documentationLink/d71519ff-fa27-4f64-9194-56886e4070ba
        private void buttonSave_Click(object sender, EventArgs e)
        {
            var service = new CrudeAircraftServiceClient();

            try {
                _contract.AircraftName             = textBoxAircraftName.Text;
                _contract.AircraftTypeRcd          = aircraftTypeRefCombo.Text;
                _contract.AircraftConfigurationRcd = aircraftConfigurationRefCombo.Text;
                _contract.AircraftBodyRcd          = aircraftBodyRefCombo.Text;
                _contract.OperationalDateTime      = dateTimePickerOperationalDateTime.Checked ? Convert.ToDateTime(dateTimePickerOperationalDateTime.Value): DateTime.MinValue;
                _contract.FirstFlightDateTime      = dateTimePickerFirstFlightDateTime.Checked ? Convert.ToDateTime(dateTimePickerFirstFlightDateTime.Value): DateTime.MinValue;
                _contract.EngineType        = textBoxEngineType.Text;
                _contract.PassengerCapacity = maskedTextBoxPassengerCapacity.Text == String.Empty ? 0 : Convert.ToInt32(maskedTextBoxPassengerCapacity.Text);
                _contract.UserId            = (Guid)userPicker.SelectedValue;

                if (_isNew)
                {
                    service.Insert(_contract);
                }
                else
                {
                    service.Update(_contract);
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            } finally {
                service.Close();
            }

            Close();
        }
Ejemplo n.º 3
0
        // refresh the grid
        // links:
        //  docLink: http://sql2x.org/documentationLink/a90065e7-8ace-4de7-9367-d4653a7c637f
        public void RefreshCrudeAircraft()
        {
            var aircraft = new CrudeAircraftServiceClient();

            try {
                var bindingSource = new BindingSource();
                bindingSource.DataSource = aircraft.FetchWithFilter(
                    Guid.Empty
                    , textBoxAircraftName.Text
                    , aircraftTypeRefCombo.Text
                    , aircraftConfigurationRefCombo.Text
                    , aircraftBodyRefCombo.Text
                    , Guid.Empty
                    , Guid.Empty
                    , dateTimePickerOperationalDateTime.Checked ? Convert.ToDateTime(dateTimePickerOperationalDateTime.Value): DateTime.MinValue
                    , dateTimePickerFirstFlightDateTime.Checked ? Convert.ToDateTime(dateTimePickerFirstFlightDateTime.Value): DateTime.MinValue
                    , textBoxEngineType.Text
                    , maskedTextBoxPassengerCapacity.Text == String.Empty ? 0 : Convert.ToInt32(maskedTextBoxPassengerCapacity.Text)
                    , Guid.Empty
                    , DateTime.MinValue
                    );
                dataGridViewCrudeAircraft.AutoGenerateColumns = false;
                dataGridViewCrudeAircraft.DataSource          = bindingSource;
                dataGridViewCrudeAircraft.AutoResizeColumns();
                dataGridViewCrudeAircraft.Refresh();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                aircraft.Close();
            }
        }