예제 #1
0
 // Create a new (empty) customer 
 // and put the form into Adding mode
 private void Add()
 {    
     Customer newCustomer = new Customer { CustomerID = 0 };    
     this.customers.Insert(currentCustomer, newCustomer);    
     this.IsAdding = true;    
     this.OnPropertyChanged("Current");
 }
예제 #2
0
 protected Account(Customer customer, decimal monthlyInterestRate, DateTime accountStartDate = default(DateTime))
 {
     this.AccountStartDate = accountStartDate == default(DateTime) ? DateTime.Today : accountStartDate;
     this.MonthlyInterestRate = monthlyInterestRate;
     this.Customer = customer;
     this.Balance = 0.0m;
 }
        public MainPage()
        {
            this.InitializeComponent();
            Window.Current.SizeChanged += WindowSizeChanged;

            List<string> titles = new List<string>
            {
                "Mr", "Mrs", "Ms"
            };

            this.title.ItemsSource = titles;
            this.cTitle.ItemsSource = titles;

            Customer customer = new Customer
            {
                CustomerID = 1,
                Title = "Mr",
                FirstName = "John",
                LastName = "Sharp",
                EmailAddress = "*****@*****.**",
                Phone = "111-1111"
            };

            this.DataContext = customer;
        }
        public CustomerDetailViewModel(Customer customer = null)
        {
            _CapabilityService = DependencyService.Get<ICapabilityService>();

            _Geocoder = new Geocoder();

            if (customer == null)
            {
                _IsNewCustomer = true;
                Customer = new Customer();
            }
            else
            {
                _IsNewCustomer = false;
                Customer = customer;
            }

            Title = _IsNewCustomer ? "New Customer" : _Customer.DisplayLastNameFirst;

            _AddressString = Customer.AddressString;

            SubscribeToSaveCustomerMessages();

            SubscribeToCustomerLocationUpdatedMessages();
        }
예제 #5
0
 public void GoTo(Customer customer) 
 { 
     this.currentCustomer = this.customers.IndexOf(customer); 
     this.OnPropertyChanged("Current");
     this.IsAtStart = (this.currentCustomer == 0);
     this.IsAtEnd = (this.customers.Count - 1 == this.currentCustomer); 
 }
예제 #6
0
        // Helper method to validate customer details
        private bool ValidateCustomer(Customer customer)
        {
            string validationErrors = string.Empty;
            bool hasErrors = false;

            if (string.IsNullOrWhiteSpace(customer.FirstName))
            {
                hasErrors = true;
                validationErrors = "First Name must not be empty\n";
            }

            if (string.IsNullOrWhiteSpace(customer.LastName))
            {
                hasErrors = true;
                validationErrors += "Last Name must not be empty\n";
            }

            // Email address is a series of characters that do not include a space or @
            // followed by @
            // followed by a series of characters that do not include a space or @
            // followed by .
            // followed by a series of characters that do not include a space or @
            Regex emailRegex = new Regex(@"^[^@ ]+@[^@ ]+\.[^@ ]+$");
            if (string.IsNullOrWhiteSpace(customer.EmailAddress) ||
                !emailRegex.IsMatch(customer.EmailAddress))
            {
                hasErrors = true;
                validationErrors += "Invalid Email Address\n";
            }

            // Phone number is a series of digits, brackets, spaces, +, and - characters
            Regex phoneRegex = new Regex(@"^[0-9\(\)\/+ \-]+$");
            if (string.IsNullOrWhiteSpace(customer.Phone) ||
                !phoneRegex.IsMatch(customer.Phone))
            {
                hasErrors = true;
                validationErrors += "Invalid Phone Number\n";
            }

            return !hasErrors;
        }
 public DepositAccount(Customer customer, decimal balance, double interestRate)
     : base(customer, balance, interestRate)
 {
 }
예제 #8
0
 protected Account(Customer customer, decimal balance, double interestRate)
 {
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
예제 #9
0
 public Mortgage(Customer customer, decimal balance, decimal iRate)
     : base(customer,balance,iRate)
 {
 }
예제 #10
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (this.txtCusID.Text.Equals(""))
            {
                MessageBox.Show("You must select a Customer first");
                return;
            }

            try
            {
                Customer updateData = new Customer();
                updateData.CustomerID = int.Parse(this.txtCusID.Text.Trim());
                updateData.CompanyName = this.txtCompName.Text;
                updateData.Contactname = this.txtContName.Text;
                updateData.ContactTitle = this.txtContTitle.Text;
                updateData.Address = this.txtAddr.Text;
                updateData.City = this.txtCity.Text;
                updateData.Region = this.txtRegion.Text;
                updateData.Postalcode = this.txtPos.Text;
                updateData.Country = this.cbCountry.Text;
                updateData.Phone = this.txtPhone.Text;
                updateData.Fax = this.txtFax.Text;

                this.dataModel.updateRow(updateData);
                MessageBox.Show("Updated");
                clearAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #11
0
 public MortgageAccount(Customer customer, decimal monthlyInterestRate, decimal mortageAmount, DateTime accountStartDate = default(DateTime))
     : base(customer, monthlyInterestRate, accountStartDate)
 {
     this.MortageAmount = mortageAmount;
     this.Balance = this.MortageAmount;
 }
예제 #12
0
 public DepositAccount(Customer customer, decimal monthlyInterestRate, decimal initialAmount, DateTime accountStartDate = default(DateTime))
     : base(customer, monthlyInterestRate, accountStartDate)
 {
     this.Deposit(initialAmount);
 }
예제 #13
0
 public Account(Customer customer, decimal balance, decimal iRate)
 {
     this.customer = customer;
     this.Balance = balance;
     this.IRate = iRate;
 }
예제 #14
0
 private void Edit ()
 {
     this.oldCustomer = new Customer();    
     this.CopyCustomer(this.Current, this.oldCustomer);    
     this.IsEditing = true;
 }
예제 #15
0
 public DepositAccount(Customer customer, double interestRate)
     : base(customer, interestRate)
 {
 }
예제 #16
0
 public LoanAccount(Customer customer, double interestRate)
     : base(customer, interestRate)
 {
 }
예제 #17
0
 public LoanAccount(Customer customer, decimal monthlyInterestRate, decimal loanAmount, DateTime accountStartDate = default(DateTime))
     : base(customer, monthlyInterestRate, accountStartDate)
 {
     this.LoanAmount = loanAmount;
     this.Balance = this.LoanAmount;
 }
예제 #18
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Customer newCus = new Customer();
            newCus.CustomerID = -1;
            newCus.CompanyName = this.txtCompName.Text;
            newCus.Contactname = this.txtContName.Text;
            newCus.ContactTitle = this.txtContTitle.Text;
            newCus.Address = this.txtAddr.Text;
            newCus.City = this.txtCity.Text;
            newCus.Region = this.txtRegion.Text;
            newCus.Postalcode = this.txtPos.Text;
            newCus.Country = this.cbCountry.Text;
            newCus.Phone = this.txtPhone.Text;
            newCus.Fax = this.txtFax.Text;

            int check = newCus.isValid();
            if (check < 0)
            {
                MessageBox.Show(newCus.getErrorMessage(check));
            }
            else
            {
                this.dataModel.insertNewRow(newCus);
                MessageBox.Show("Completed");
                clearAll();
            }
        }
예제 #19
0
 public MortgageAccount(Customer customer, double interestRate)
     : base(customer, interestRate)
 {
 }
예제 #20
0
        private void gvCustomers_SelectionChanged(object sender, EventArgs e)
        {
            if (this.gvCustomers.SelectedRows.Count > 0)
            {
                Customer get = new Customer();
                get.CustomerID = int.Parse(this.gvCustomers.SelectedRows[0].Cells[0].Value.ToString());
                Customer selectedItem = this.dataModel.Data[dataModel.Data.IndexOf(get)];
                this.txtCusID.Text = selectedItem.CustomerID.ToString();
                this.txtCompName.Text = selectedItem.CompanyName;
                this.txtContName.Text = selectedItem.Contactname;
                this.txtContTitle.Text = selectedItem.ContactTitle;
                this.txtAddr.Text = selectedItem.Address;
                this.txtCity.Text = selectedItem.City;
                this.txtRegion.Text = selectedItem.Region;
                this.txtPos.Text = selectedItem.Postalcode;
                this.cbCountry.Text = selectedItem.Country;
                this.txtPhone.Text = selectedItem.Phone;
                this.txtFax.Text = selectedItem.Fax;

            }
            else
            {
                this.txtCusID.Text = "";
            }
        }
예제 #21
0
 // Utility method for copying the details of a customer
 private void CopyCustomer(Customer source, Customer destination)
 {
     destination.CustomerID = source.CustomerID;
     destination.EmailAddress = source.EmailAddress;
     destination.FirstName = source.FirstName;
     destination.LastName = source.LastName;
     destination.Phone = source.Phone;
     destination.Title = source.Title;
     destination.rowguid = source.rowguid;
     destination.ModifiedDate = source.ModifiedDate;
 }
예제 #22
0
 public Deposit(Customer customer, decimal balance, decimal iRate)
     : base(customer, balance, iRate)
 {
     this.Balance = balance;
 }
예제 #23
0
 public Loan(Customer customer, decimal balance, decimal iRate)
     : base(customer, balance, iRate)
 {
 }