Beispiel #1
0
        //Call to Create a Payroll Item in the database
        public void CreatePayrollItem(PayrollDO payCreate)
        {
            //Try(catch) to open a connection and access the server database
            try
            {
                using (SqlConnection sqlConnect = new SqlConnection(connectionString))
                    using (SqlCommand sqlCommand = new SqlCommand("CREATE_PAYROLL_ITEM", sqlConnect))
                    {
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlConnect.Open();

                        sqlCommand.Parameters.AddWithValue("@JobTitle", payCreate.JobTitle);
                        sqlCommand.Parameters.AddWithValue("@JobDescription", payCreate.JobDescription);
                        sqlCommand.Parameters.AddWithValue("@HourlyRate", payCreate.HourlyRate);
                        sqlCommand.Parameters.AddWithValue("@Salary", payCreate.Salary);

                        sqlCommand.ExecuteNonQuery();
                    }
            }
            catch (Exception error)
            {
                Logger Error = new Logger();
                Error.logErrors(error);
            }
            finally { }
        }
Beispiel #2
0
        private void frmListPayrollItem_Load(object sender, System.EventArgs e)
        {
            payrollDO     = new PayrollDO();
            dsPayrollItem = payrollDO.GetPayrollItems();

            PopulatePayrollItemListView();
        }
Beispiel #3
0
        //Reading all the users in the database table "Users" into a List.
        public List <PayrollDO> PayrollList()
        {
            List <PayrollDO> payList = new List <PayrollDO>();

            //Try(catch) to open a connection and access the server database
            try
            {
                using (SqlConnection sqlConnect = new SqlConnection(connectionString))
                    using (SqlCommand sqlCommand = new SqlCommand("VIEW_PAYROLL", sqlConnect))
                    {
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlConnect.Open();

                        using (SqlDataReader dataReader = sqlCommand.ExecuteReader())
                        {
                            //Reading the data in each column by column name
                            while (dataReader.Read())
                            {
                                //Creates a New List to store the Users in.
                                PayrollDO listPay = new PayrollDO();
                                listPay.PayrollID      = (int)dataReader["PayrollID"];
                                listPay.JobTitle       = (string)dataReader["JobTitle"];
                                listPay.JobDescription = (string)dataReader["JobDescription"];
                                listPay.HourlyRate     = (decimal)dataReader["HourlyRate"];
                                listPay.Salary         = (decimal)dataReader["Salary"];

                                payList.Add(listPay);
                            }
                        }
                    }
            }
            catch (Exception error)
            {
                Logger Error = new Logger();
                Error.logErrors(error);
            }
            finally { }

            return(payList);
        }