Ejemplo n.º 1
0
 public Employee(UserName newName, Address newAddress, ContactInformation contact, float newWage, DateTime newStart, string newSIN, Position newPosition)
 {
     Address          = newAddress;
     Name             = newName;
     EmployeePosition = newPosition;
     Wage             = newWage;
     StartDate        = newStart;
     SIN = newSIN;
     ContactInformation = contact;
 }
Ejemplo n.º 2
0
        private Customer CreateCustomer()
        {
            String postal = CheckBlankBoxes(PostalBox);
            String email  = CheckBlankBoxes(EmailBox);
            String phone  = CheckBlankBoxes(PhoneBox);

            Customer.AccountType type      = GetAccountType();
            UserName             user      = new UserName(FirstNameBox.Text, LastNameBox.Text);
            Address            userAddress = new Address(SuiteBox.Text, StreetBox.Text, HouseBox.Text, CityBox.Text, ProvinceBox.Text, postal);
            ContactInformation userInfo    = new ContactInformation(email, phone);
            Credentials        credentials = new Credentials(UsernameTextBox.Text, PasswordTextBox.Text);
            Customer           newCustomer = new Customer(user, userAddress, userInfo, type);

            newCustomer.Credentials = credentials;

            return(newCustomer);
        }
Ejemplo n.º 3
0
        private bool checkFormInputs()
        {
            if (!inputHandler.checkNames(FirstNameBox.Text))
            {
                return(false);
            }

            if (!inputHandler.checkNames(LastNameBox.Text))
            {
                return(false);
            }

            try {
                PossitionBox.SelectedItem.ToString();
            }
            catch (Exception e)
            {
                MessageBox.Show("Need to select a possition");
                return(false);
            }

            if (!inputHandler.checkSIN(SINBox.Text))
            {
                return(false);
            }

            try
            {
                ContactInformation userInfo    = new ContactInformation(null, PhoneBox.Text);
                UserName           user        = new UserName(FirstNameBox.Text, LastNameBox.Text);
                Address            userAddress = new Address(SuiteBox.Text, StreetBox.Text, HouseBox.Text, CityBox.Text, ProvinceBox.Text, PostalBox.Text);
                Employee           newEmployee = new Employee(user, userAddress, userInfo, float.Parse(WageBox.Text, CultureInfo.InvariantCulture.NumberFormat), DateTime.Now, SINBox.Text, Employee.Position.Employee);
            }
            catch (Exception ex)
            {
                inputHandler.HandleException(ex);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        private Employee CreateEmployee()
        {
            UserName           user        = new UserName(FirstNameBox.Text, LastNameBox.Text);
            Address            userAddress = new Address(SuiteBox.Text, StreetBox.Text, HouseBox.Text, CityBox.Text, ProvinceBox.Text, PostalBox.Text);
            ContactInformation userInfo    = new ContactInformation(null, PhoneBox.Text);
            Credentials        credentials = new Credentials(UsernameTextBox.Text, PasswordTextBox.Text);

            Employee.Position position;
            if (PossitionBox.Text == "Manager")
            {
                position = Employee.Position.Manager;
            }
            else
            {
                position = Employee.Position.Employee;
            }

            Employee newEmployee = new Employee(user, userAddress, userInfo, float.Parse(WageBox.Text, CultureInfo.InvariantCulture.NumberFormat), DateTime.Now, SINBox.Text, position)
            {
                Credentials = credentials
            };

            return(newEmployee);
        }
Ejemplo n.º 5
0
 public CustomerInsertionParameters(UserName UserName, Address userAddress, ContactInformation userInfo)
 {
     user    = UserName;
     address = userAddress;
     info    = userInfo;
 }
Ejemplo n.º 6
0
        private static Customer CreateCustomerFromRow(DataRow row)
        {
            string firstName;

            if (row.IsNull("first_name"))
            {
                return(null);
            }
            firstName = row["first_name"].ToString();

            string lastName;

            if (row.IsNull("last_name"))
            {
                return(null);
            }
            lastName = row["last_name"].ToString();

            string suite = "";

            if (!row.IsNull("suite_number"))
            {
                suite = row["suite_number"].ToString();
            }

            string street = "";

            if (!row.IsNull("street_number"))
            {
                street = row["street_number"].ToString();
            }

            string house = "";

            if (!row.IsNull("house_number"))
            {
                house = row["house_number"].ToString();
            }

            string city = "";

            if (!row.IsNull("city"))
            {
                city = row["city"].ToString();
            }

            string province = "";

            if (!row.IsNull("province"))
            {
                province = row["province"].ToString();
            }

            string postalCode = "";

            if (!row.IsNull("postalcode"))
            {
                postalCode = row["postalcode"].ToString();
            }

            string email = "";

            if (!row.IsNull("email"))
            {
                email = row["email"].ToString();
            }

            string phone = "";

            if (!row.IsNull("phone_number"))
            {
                phone = row["phone_number"].ToString();
            }

            DateTime creationDate;

            if (row.IsNull("creation_date"))
            {
                return(null);
            }
            creationDate = (DateTime)row["creation_date"];

            string creditCard = "";

            if (!row.IsNull("credit_card"))
            {
                creditCard = row["credit_card"].ToString();
            }

            Customer.AccountType account = Customer.AccountType.Limited;
            switch (row["account_type"].ToString())
            {
            case "Disabled":
                account = Customer.AccountType.Disabled;
                break;

            case "Limited":
                account = Customer.AccountType.Limited;
                break;

            case "Bronze":
                account = Customer.AccountType.Bronze;
                break;

            case "Silver":
                account = Customer.AccountType.Silver;
                break;

            case "Gold":
                account = Customer.AccountType.Gold;
                break;

            default:
                return(null);
            }

            UserName name    = new UserName(firstName, lastName);
            Address  address = new Address(suite, street, house, city, province, postalCode);

            ContactInformation newContact = new ContactInformation(email, phone);

            Credentials credentials = new Credentials(row["username"].ToString(), row["passhash"].ToString());

            Customer customer = new Customer(name, address, newContact, account)
            {
                CreationDate = creationDate,
                CreditCard   = creditCard,
                Id           = (int)row["cid"],
                Rating       = (int)row["rating"],
                Credentials  = credentials,
            };

            return(customer);
        }
Ejemplo n.º 7
0
        private static Employee CreateEmployeeFromRow(DataRow row)
        {
            string firstName;

            if (row.IsNull("first_name"))
            {
                return(null);
            }
            firstName = row["first_name"].ToString();

            string lastName;

            if (row.IsNull("last_name"))
            {
                return(null);
            }
            lastName = row["last_name"].ToString();

            string suite = "";

            if (!row.IsNull("suite_number"))
            {
                suite = row["suite_number"].ToString();
            }

            string street = "";

            if (!row.IsNull("street_number"))
            {
                street = row["street_number"].ToString();
            }

            string house = "";

            if (!row.IsNull("house_number"))
            {
                house = row["house_number"].ToString();
            }

            string city = "";

            if (!row.IsNull("city"))
            {
                city = row["city"].ToString();
            }

            string province = "";

            if (!row.IsNull("province"))
            {
                province = row["province"].ToString();
            }

            string postalCode = "";

            if (!row.IsNull("postalcode"))
            {
                postalCode = row["postalcode"].ToString();
            }

            string phone = "";

            if (!row.IsNull("phone_number"))
            {
                phone = row["phone_number"].ToString();
            }

            Employee.Position position;
            if (row.IsNull("position"))
            {
                return(null);
            }
            position = Employee.Position.Employee;
            if (row["position"].ToString() == "manager")
            {
                position = Employee.Position.Manager;
            }

            float wage;

            if (row.IsNull("wage"))
            {
                return(null);
            }
            wage = float.Parse(row["wage"].ToString(), CultureInfo.InvariantCulture.NumberFormat);

            DateTime startDate;

            if (row.IsNull("start"))
            {
                return(null);
            }
            startDate = (DateTime)row["start"];

            string sin = "";

            if (row.IsNull("social_insurance_num"))
            {
                sin = row["social_insurance_num"].ToString();
            }

            UserName           name        = new UserName(firstName, lastName);
            Address            address     = new Address(suite, street, house, city, province, postalCode);
            ContactInformation contactInfo = new ContactInformation("", phone);
            Credentials        credentials = new Credentials(row["username"].ToString(), row["passhash"].ToString());
            Employee           employee    = new Employee(name, address, contactInfo, wage, startDate, sin, position)
            {
                Id          = (int)row["eid"],
                Credentials = credentials
            };

            return(employee);
        }