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
        public ActionResult CrudeAircraftEdit(
            System.Guid aircraftId
            )
        {
            CrudeAircraftContract contract = new CrudeAircraftServiceClient().FetchByAircraftId(aircraftId);

            ViewBag.AircraftTypeRcd =
                new SelectList(new CrudeAircraftTypeRefServiceClient().FetchAll(),
                               "AircraftTypeRcd",
                               "AircraftTypeName",
                               contract.AircraftTypeRcd
                               );

            ViewBag.AircraftConfigurationRcd =
                new SelectList(new CrudeAircraftConfigurationRefServiceClient().FetchAll(),
                               "AircraftConfigurationRcd",
                               "AircraftConfigurationName",
                               contract.AircraftConfigurationRcd
                               );

            ViewBag.AircraftBodyRcd =
                new SelectList(new CrudeAircraftBodyRefServiceClient().FetchAll(),
                               "AircraftBodyRcd",
                               "AircraftBodyName",
                               contract.AircraftBodyRcd
                               );

            ViewBag.ProductId =
                new SelectList(new CrudeProductServiceClient().FetchAll(),
                               "ProductId",
                               "ProductName",
                               contract.ProductId
                               );

            ViewBag.DefaultUserName =
                new CrudeDefaultUserServiceClient().FetchByDefaultUserId(contract.UserId).DefaultUserName;


            return(View(
                       "~/Views/Crude/Aircraft/CrudeAircraft/CrudeAircraftEdit.cshtml",
                       contract
                       ));
        }
        public ActionResult AircraftMeasurementEdit(
            System.Guid aircraftId
            )
        {
            ViewBag.AircraftId = aircraftId;

            // get right-side primary key from left-side entity
            System.Guid aircraftMeasurementId = new CrudeAircraftServiceClient().FetchByAircraftId(aircraftId).AircraftMeasurementId;

            // get right-side entity
            CrudeAircraftMeasurementContract contract = new CrudeAircraftMeasurementServiceClient().FetchByAircraftMeasurementId(aircraftMeasurementId);

            ViewBag.DefaultUserName =
                new CrudeDefaultUserServiceClient().FetchByDefaultUserId(contract.UserId).DefaultUserName;


            return(View(
                       "~/Views/Templates/Aircraft/AircraftMeasurement/AircraftMeasurementEdit.cshtml",
                       contract
                       ));
        }
Ejemplo n.º 5
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();
            }
        }
        public ActionResult AircraftMeasurementEdit(
            [Bind()] CrudeAircraftMeasurementContract contract,
            System.Guid aircraftId
            )
        {
            ViewBag.AircraftId = aircraftId;

            if (ModelState.IsValid)
            {
                contract.DateTime = DateTime.UtcNow;

                if (contract.AircraftMeasurementId == Guid.Empty)
                {
                    // insert right-side entity
                    contract.AircraftMeasurementId = Guid.NewGuid();
                    contract.UserId = new System.Guid("{FFFFFFFF-5555-5555-5555-FFFFFFFFFFFF}");
                    new CrudeAircraftMeasurementServiceClient().Insert(contract);

                    // update left-side with right-side id
                    CrudeAircraftContract aircraftContract = new CrudeAircraftServiceClient().FetchByAircraftId(aircraftId);
                    aircraftContract.AircraftMeasurementId = contract.AircraftMeasurementId;
                    aircraftContract.DateTime = DateTime.UtcNow;
                    aircraftContract.UserId   = new System.Guid("{FFFFFFFF-5555-5555-5555-FFFFFFFFFFFF}");
                    new CrudeAircraftServiceClient().Update(aircraftContract);
                }
                else
                {
                    // update right-side entity
                    new CrudeAircraftMeasurementServiceClient().Update(contract);
                }
            }

            return(View(
                       "~/Views/Templates/Aircraft/AircraftMeasurement/AircraftMeasurementEdit.cshtml",
                       contract
                       ));
        }