Пример #1
0
        // shows the form in edit modus
        // links:
        //  docLink: http://sql2x.org/documentationLink/49afd26c-4f21-4992-967b-be190eacef77
        public void ShowAsEdit(System.Guid cityId)
        {
            var service = new CrudeCityServiceClient();

            _isNew = false;
            try {
                _contract = service.FetchByCityId(cityId);
                countryPicker.SelectedValue = _contract.CountryId;
                textBoxCityCode.Text        = _contract.CityCode;
                textBoxCityName.Text        = _contract.CityName;
                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();
            }
        }
Пример #2
0
        // shows the form with default values for comboboxes and pickers
        // links:
        //  docLink: http://sql2x.org/documentationLink/f5685d96-a0bb-4f7b-beaa-b3d578c7cf28
        public void ShowAsAdd(System.Guid countryId, string cityCode, string cityName, System.Guid productId, System.Guid userId)
        {
            try {
                _contract                   = new CrudeCityContract();
                _isNew                      = true;
                _contract.CountryId         = countryId;
                countryPicker.SelectedValue = _contract.CountryId;
                _contract.CityCode          = cityCode;
                textBoxCityCode.Text        = _contract.CityCode;
                _contract.CityName          = cityName;
                textBoxCityName.Text        = _contract.CityName;
                _contract.ProductId         = productId;
                _contract.UserId            = userId;
                userPicker.SelectedValue    = userId;
                _contract.DateTime          = DateTime.UtcNow;
                dateTimePickerDateTime.Text = _contract.DateTime.ToString();

                Show();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            }
        }
Пример #3
0
        public ActionResult CrudeCityCreate([Bind()] CrudeCityContract contract)
        {
            if (ModelState.IsValid)
            {
                new CrudeCityServiceClient().Insert(contract);

                return(RedirectToAction("CrudeCityIndex"));
            }

            return(View(
                       "~/Views/Crude/City/CrudeCity/CrudeCityCreate.cshtml",
                       contract
                       ));
        }
Пример #4
0
 // shows the form with default values for comboboxes and pickers
 // links:
 //  docLink: http://sql2x.org/documentationLink/e04d0806-55ef-41cc-8669-acf0ddd850c7
 public void ShowAsAdd()
 {
     try {
         _contract = new CrudeCityContract();
         _isNew    = true;
         Show();
     } catch (Exception ex) {
         if (ex == null)
         {
         }
         else
         {
             System.Diagnostics.Debugger.Break();
         }
     }
 }
Пример #5
0
        public ActionResult CrudeCityEdit([Bind()] CrudeCityContract contract)
        {
            if (ModelState.IsValid)
            {
                contract.DateTime = DateTime.UtcNow;

                new CrudeCityServiceClient().Update(contract);

                return(RedirectToAction("CrudeCityIndex"));
            }

            return(View(
                       "~/Views/Crude/City/CrudeCity/CrudeCityEdit.cshtml",
                       contract
                       ));
        }
Пример #6
0
        public ActionResult CrudeCityCreate(System.Guid?countryId, System.Guid?productId, System.Guid?userId)
        {
            var contract = new CrudeCityContract();

            if (countryId != null)
            {
                contract.CountryId = (System.Guid)countryId;
            }
            if (productId != null)
            {
                contract.ProductId = (System.Guid)productId;
            }
            if (userId != null)
            {
                contract.UserId = (System.Guid)userId;
            }

            ViewBag.CountryId =
                new SelectList(new CrudeCountryServiceClient().FetchAll(),
                               "CountryId",
                               "CountryName",
                               contract.CountryId
                               );

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

            if (userId == null)
            {
                contract.UserId = new System.Guid("{FFFFFFFF-5555-5555-5555-FFFFFFFFFFFF}");
            }

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

            contract.DateTime = DateTime.UtcNow;


            return(View(
                       "~/Views/Crude/City/CrudeCity/CrudeCityCreate.cshtml",
                       contract
                       ));
        }
Пример #7
0
        // shows by foreign keys
        // links:
        //  docLink: http://sql2x.org/documentationLink/f21e72c1-2d57-44c1-a9c1-1b80bad6a391
        public void ShowAsAddByCountry(System.Guid countryId)
        {
            try {
                _contract                   = new CrudeCityContract();
                _isNew                      = true;
                _contract.DateTime          = DateTime.UtcNow;
                dateTimePickerDateTime.Text = _contract.DateTime.ToString();
                _contract.CountryId         = countryId;
                countryPicker.SelectedValue = _contract.CountryId;

                Show();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            }
        }
Пример #8
0
        // populates the Picker with the first match from the SOAP service
        // links:
        //  docLink: http://sql2x.org/documentationLink/3e8b9e1a-39eb-444f-9632-ce3406db3534
        private void txtCityCode_Validating(object sender, CancelEventArgs e)
        {
            if (!DesignMode)
            {
                // empty picker on no code
                if (string.IsNullOrEmpty(txtCityCode.Text))
                {
                    _cityId          = Guid.Empty;
                    txtCityName.Text = string.Empty;
                    txtCityCode.Text = string.Empty;
                    return;
                }

                CrudeCityServiceClient city = null;

                try {
                    city = new CrudeCityServiceClient();
                    CrudeCityContract contract = city.FetchByCityCode(txtCityCode.Text);

                    if (contract != null)
                    {
                        txtCityCode.Text = contract.CityCode;
                        txtCityName.Text = contract.CityName;
                        _cityId          = contract.CityId;
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                } finally {
                    if (city != null)
                    {
                        city.Close();
                    }
                }

                if (this.Picked != null)
                {
                    this.Picked(new object(), new EventArgs());
                }
            }
        }