public Department GetDepartmentProfile(int departmentId)
        {
            Department department = new Department();

            string query = String.Format("SELECT * FROM Department WHERE DepartmentId ={0}", departmentId);

            daFunctions.Command.CommandText = query;

            try
            {
                daFunctions.Connection.Open();

                SqlDataReader rdr = daFunctions.Command.ExecuteReader();

                while (rdr.Read())
                {
                    department.DepartmentId = rdr["DepartmentId"] as int? ?? default(int);
                    department.DepartmentName = (string)rdr["DepartmentName"];
                    department.MonthlyBudget = rdr["MonthlyBudget"] as decimal? ?? default(decimal);
                }

                daFunctions.Connection.Close();

            }
            catch (Exception ex)
            {
                throw new Exception("Unable to load department profile: " + ex.Message);
            }

            return department;
        }
 public ExpenseReport()
 {
     CreatedBy = new Employee();
     ApprovedBy = new Employee();
     ProcessedBy = new Employee();
     ExpenseToDept = new Department();
     ExpenseItems = new List<ExpenseItem>();
 }
Example #3
0
 public Employee()
 {
     UserId = new Guid();
     FirstName = "";
     Surname = "";
     Role = "";
     AmountApproved = 0;
     ExpenseApproved = 0;
     Dept = new Department();
 }
        /// <summary>
        /// Highlight the footer of expense report if the amount will result in the department budget being exceeded
        /// </summary>
        /// <param name="amount">Total amount of the expense report</param>
        /// <param name="dept">Department expensed to</param>
        /// <returns>background styling</returns>
        protected string HighlightOverBudget(decimal amount, Department dept)
        {
            BudgetTracker deptBudget = new BudgetTracker();
            deptBudget.DepartmentBudget(dept.MonthlyBudget, dept.DepartmentId);

            if (deptBudget.IsBudgetExceededAccounts(amount))
                return "background-color:#f2dede; color:red";
            else
                return "background-color:#dff0d8";
        }