protected override void OnPageOpened()
        {
            if (Viewmodel.ModelMode == OrderViewmodel.ModeKind.Edit)
            {
                _rs.ExecSql(Viewmodel.OrderID);

                if (_rs.RecordCount == 0)
                {
                    throw new Exception("wrong");
                }

                Viewmodel.CustomerID      = _rs.CustomerID;
                Viewmodel.DeliveredDate   = Sqlite.TEXTToDateTimeNullable(_rs.DeliveredDate);
                Viewmodel.LastModifiedOn  = Sqlite.TEXTToDateTime(_rs.LastModifiedOn);
                Viewmodel.OrderDate       = Sqlite.TEXTToDateTime(_rs.OrderDate);
                Viewmodel.PaymentType     = _rs.PaymentType;
                Viewmodel.SearchTerms     = _rs.SearchTerms;
                Viewmodel.ShipAddress     = _rs.ShipAddress;
                Viewmodel.ShipCity        = _rs.ShipCity;
                Viewmodel.ShipCountryCode = _rs.ShipCountryCode;
                Viewmodel.ShipPhone       = _rs.ShipPhone;
                Viewmodel.ShipPostalCode  = _rs.ShipPostalCode;
                Viewmodel.ShipRegion      = _rs.ShipRegion;
                Viewmodel.ShipVia         = _rs.ShipVia;
                Viewmodel.ShippedDate     = Sqlite.TEXTToDateTimeNullable(_rs.ShippedDate);
                Viewmodel.Status          = _rs.Status;
                Viewmodel.TrackingNumber  = _rs.TrackingNumber;
            }
            else if (Viewmodel.ModelMode == OrderViewmodel.ModeKind.New)
            {
                Viewmodel.OrderID         = 0;
                Viewmodel.CustomerID      = 0;
                Viewmodel.DeliveredDate   = null;
                Viewmodel.LastModifiedOn  = null;
                Viewmodel.OrderDate       = DateTime.UtcNow;
                Viewmodel.PaymentType     = null;
                Viewmodel.SearchTerms     = null;
                Viewmodel.ShipAddress     = null;
                Viewmodel.ShipCity        = null;
                Viewmodel.ShipCountryCode = "US";
                Viewmodel.ShipPhone       = null;
                Viewmodel.ShipPostalCode  = null;
                Viewmodel.ShipRegion      = null;
                Viewmodel.ShipVia         = null;
                Viewmodel.ShippedDate     = null;
                Viewmodel.Status          = 0;
                Viewmodel.TrackingNumber  = null;
            }

            Viewmodel.ResetModelModified();

            _validator = CreateValidator(Viewmodel);
            _validator.ValidateEvent += ValidateEvent;
            _validator.AddItem(vm => vm.CustomerID, inputCustomerID);
            _validator.AddItem(vm => vm.ShipCountryCode, inputShipCountryCode);
            _validator.AddItem(vm => vm.ShippedDate, inputShippedDate);

            _validator.ValidateAll();
        }
Exemplo n.º 2
0
        protected override void OnPageOpened()
        {
            if (Viewmodel.ModelMode == CustomerViewmodel.ModeKind.Edit)
            {
                _rs.ExecSql(Viewmodel.CustomerID);

                if (_rs.RecordCount == 0)
                {
                    throw new Exception("wrong");
                }

                Viewmodel.AddressLine1    = _rs.AddressLine1;
                Viewmodel.AddressLine2    = _rs.AddressLine2;
                Viewmodel.BirthDate       = _rs.BirthDate;
                Viewmodel.ChildrenAtHome  = _rs.ChildrenAtHome;
                Viewmodel.City            = _rs.City;
                Viewmodel.CountryCode     = _rs.CountryCode;
                Viewmodel.CreatedOn       = _rs.CreatedOn;
                Viewmodel.Education       = _rs.Education;
                Viewmodel.EmailAddress    = _rs.EmailAddress;
                Viewmodel.FirstName       = _rs.FirstName;
                Viewmodel.Gender          = _rs.Gender;
                Viewmodel.IsHouseOwner    = _rs.IsHouseOwner;
                Viewmodel.LastModifiedOn  = _rs.LastModifiedOn;
                Viewmodel.LastName        = _rs.LastName;
                Viewmodel.MaritalStatus   = _rs.MaritalStatus;
                Viewmodel.MiddleName      = _rs.MiddleName;
                Viewmodel.NumberCarsOwned = _rs.NumberCarsOwned;
                Viewmodel.Occupation      = _rs.Occupation;
                Viewmodel.Phone           = _rs.Phone;
                Viewmodel.Picture         = _rs.Picture;
                Viewmodel.PostalCode      = _rs.PostalCode;
                Viewmodel.Region          = _rs.Region;
                Viewmodel.SearchTerms     = _rs.SearchTerms;
                Viewmodel.Suffix          = _rs.Suffix;
                Viewmodel.Thumbnail       = _rs.Thumbnail;
                Viewmodel.Title           = _rs.Title;
                Viewmodel.TotalChildren   = _rs.TotalChildren;
                Viewmodel.YearlyIncome    = _rs.YearlyIncome;
            }
            else if (Viewmodel.ModelMode == CustomerViewmodel.ModeKind.New)
            {
                Viewmodel.AddressLine1    = "";
                Viewmodel.AddressLine2    = null;
                Viewmodel.BirthDate       = null;
                Viewmodel.ChildrenAtHome  = null;
                Viewmodel.City            = "";
                Viewmodel.CountryCode     = "";
                Viewmodel.CreatedOn       = "";
                Viewmodel.Education       = null;
                Viewmodel.EmailAddress    = "";
                Viewmodel.FirstName       = "";
                Viewmodel.Gender          = null;
                Viewmodel.IsHouseOwner    = null;
                Viewmodel.LastModifiedOn  = "";
                Viewmodel.LastName        = "";
                Viewmodel.MaritalStatus   = null;
                Viewmodel.MiddleName      = null;
                Viewmodel.NumberCarsOwned = null;
                Viewmodel.Occupation      = null;
                Viewmodel.Phone           = null;
                Viewmodel.Picture         = null;
                Viewmodel.PostalCode      = "";
                Viewmodel.Region          = "";
                Viewmodel.SearchTerms     = null;
                Viewmodel.Suffix          = null;
                Viewmodel.Thumbnail       = null;
                Viewmodel.Title           = null;
                Viewmodel.TotalChildren   = null;
                Viewmodel.YearlyIncome    = null;
            }

            Viewmodel.ResetModelModified();

            _validator = CreateValidator(Viewmodel);
            _validator.ValidateEvent += ValidateEvent;
            _validator.AddItem(vm => vm.CountryCode, inputCountryCode);

            _validator.ValidateAll();
        }