Exemplo n.º 1
0
        private EmployeeMiscellaneous createEmployeeMiscellaneous(Employee employee, Miscellaneous miscellenaous)
        {
            EmployeeMiscellaneous employeeMiscellaneous = new EmployeeMiscellaneous();

            sqlCon.Open();
            sqlCmd.CommandText = "INSERT INTO EmployeeMiscellaneous (employeeId, miscellaneousId) "
                                 + "VALUES (@employeeId, @miscellaneousId);SELECT CAST(scope_identity() AS int)";
            sqlCmd.Parameters.AddWithValue("@employeeId", employee.id);
            sqlCmd.Parameters.AddWithValue("@miscellaneousId", miscellenaous.id);
            employeeMiscellaneous.id = (int)sqlCmd.ExecuteScalar();
            sqlCon.Close();

            return(employeeMiscellaneous);
        }
Exemplo n.º 2
0
        public Miscellaneous createMiscellaenousByEmployee(Miscellaneous miscellaneous, Employee employee)
        {
            sqlCon.Open();
            sqlCmd.CommandText = "INSERT INTO [Miscellaneous] (name, description, amount, type) VALUES (@name, @description, @amount, @type);SELECT CAST(scope_identity() AS int)";
            sqlCmd.Parameters.AddWithValue("@name", miscellaneous.name);
            sqlCmd.Parameters.AddWithValue("@description", miscellaneous.description);
            sqlCmd.Parameters.AddWithValue("@amount", miscellaneous.amount);
            sqlCmd.Parameters.AddWithValue("@type", miscellaneous.type == MiscType.Benefits ? "Benefit" : "Deduction");
            miscellaneous.id = (int)sqlCmd.ExecuteScalar();
            sqlCmd.Parameters.Clear();
            sqlCon.Close();

            EmployeeMiscellaneous transportationBenefit = createEmployeeMiscellaneous(employee, miscellaneous);

            return(miscellaneous);
        }
Exemplo n.º 3
0
        public Miscellaneous createTransportationBenefit(Employee employee)
        {
            Miscellaneous transportationAllowance = new Miscellaneous();

            sqlCon.Open();
            sqlCmd.CommandText = "INSERT INTO Miscellaneous (name, description, amount, type) "
                                 + "VALUES (@name,@description,@amount,@type);SELECT CAST(scope_identity() AS int)";
            sqlCmd.Parameters.AddWithValue("@name", "TransportationAllowance");
            sqlCmd.Parameters.AddWithValue("@description", "Transportation Allowance");
            sqlCmd.Parameters.AddWithValue("@amount", "0.00");
            sqlCmd.Parameters.AddWithValue("@type", "Benefit");
            transportationAllowance.id = (int)sqlCmd.ExecuteScalar();
            sqlCon.Close();

            EmployeeMiscellaneous transportationBenefit = createEmployeeMiscellaneous(employee, transportationAllowance);

            return(transportationAllowance);
        }
Exemplo n.º 4
0
        public Miscellaneous createThirteenMonthBenefit(Employee employee)
        {
            Miscellaneous thirteenMonthPay = new Miscellaneous();

            sqlCon.Open();
            sqlCmd.CommandText = "INSERT INTO Miscellaneous (name, description, amount, type) "
                                 + "VALUES (@name,@description,@amount,@type);SELECT CAST(scope_identity() AS int)";
            sqlCmd.Parameters.AddWithValue("@name", "ThirteenMonthAllowance");
            sqlCmd.Parameters.AddWithValue("@description", "Thirteen Month Allowance starts @" + Convert.ToDateTime(employee.dateEmployed).ToString("MM/dd/yyyy"));
            sqlCmd.Parameters.AddWithValue("@amount", "0.00");
            sqlCmd.Parameters.AddWithValue("@type", "Benefit");
            thirteenMonthPay.id = (int)sqlCmd.ExecuteScalar();
            sqlCon.Close();

            EmployeeMiscellaneous thirteenMonthBenefit = createEmployeeMiscellaneous(employee, thirteenMonthPay);

            return(thirteenMonthPay);
        }