Пример #1
0
        public void TestChangeSalaryTransaction()
        {
            int empId = 4;
            AddCommissionedEmployee t =
                new AddCommissionedEmployee(
                    empId, "Lance", "Home", 2500, 3.2, database);

            t.Execute();
            ChangeSalariedTransaction cst =
                new ChangeSalariedTransaction(empId, 3000.00, database);

            cst.Execute();
            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            PaymentClassification pc = e.Classification;

            Assert.IsNotNull(pc);
            Assert.IsTrue(pc is SalariedClassification);
            SalariedClassification sc = pc as SalariedClassification;

            Assert.AreEqual(3000.00, sc.Salary, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is MonthlySchedule);
        }
Пример #2
0
        public void TestAddSalariedEmployee()
        {
            int empId             = 1;
            AddSalariedEmployee t =
                new AddSalariedEmployee(empId, "Bob", "Home", 1000.00, database);

            t.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.AreEqual("Bob", e.Name);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is SalariedClassification);
            SalariedClassification sc = pc as SalariedClassification;

            Assert.AreEqual(1000.00, sc.Salary, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is MonthlySchedule);

            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
Пример #3
0
        private void PrepareToSavePaymentClassification()
        {
            PaymentClassification classification = employee.Classification;

            if (classification is SalariedClassification)
            {
                classificationCode = "salaried";
                SalariedClassification salariedClassification =
                    classification as SalariedClassification;
                insertClassificationCommand =
                    CreateInsertSalariedClassificationCommand(
                        salariedClassification);
            }
            else if (classification is HourlyClassification)
            {
                classificationCode = "hourly";
            }
            else if (classification is CommissionedClassification)
            {
                classificationCode = "commissioned";
            }
            else
            {
                classificationCode = "unknown";
            }
        }
Пример #4
0
        private SqlCommand CreateInsertSalariedClassificationCommand(
            SalariedClassification salariedClassification)
        {
            string SQL = "INSERT INTO SalariedClassification " +
                         "VALUES (@Salary, @EmpId)";
            SqlCommand command = new SqlCommand(SQL);

            command.Parameters.AddWithValue("@Salary", salariedClassification.Salary);
            command.Parameters.AddWithValue("@EmpId", employee.Id);

            return(command);
        }