public static List <EmployeeExpenseType> GetEmployeeExpenseTypeListByEmployeeId(int employeeId) { List <EmployeeExpenseType> list = new List <EmployeeExpenseType>(); Database db = DatabaseFactory.CreateDatabase("Spar-StoreRep"); string sqlCommand = "GetEmployeeExpenseTypeListByEmployeeId"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "@EmployeeId", DbType.Int32, employeeId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { EmployeeExpenseType employeeExpenseType = new EmployeeExpenseType(); employeeExpenseType.EmployeeId = employeeId; employeeExpenseType.EmployeeExpenseTypeLinkId = Convert.ToInt32(dataReader["EmployeeExpenseTypeLinkId"]); employeeExpenseType.EmployeeExpenseTypeId = Convert.ToInt32(dataReader["EmployeeExpenseTypeId"]); employeeExpenseType.Description = dataReader["Description"].ToString(); employeeExpenseType.GlCode = dataReader["GlCode"].ToString(); employeeExpenseType.ExpenseDate = Convert.ToDateTime(dataReader["ExpenseDate"]); employeeExpenseType.Detail = dataReader["Detail"].ToString(); employeeExpenseType.Comment = dataReader["Comment"].ToString(); employeeExpenseType.Amount = Convert.ToDecimal(dataReader["Amount"]); employeeExpenseType.Budget = Convert.ToDecimal(dataReader["Budget"]); list.Add(employeeExpenseType); } } return(list); }
public static EmployeeExpenseType GetEmployeeExpenseTypeLinkByEmployeeExpenseTypeLinkId(int employeeExpenseTypeLinkId) { Database db = DatabaseFactory.CreateDatabase("Spar-StoreRep"); string sqlCommand = "GetEmployeeExpenseTypeLinkByEmployeeExpenseTypeLinkId"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "@EmployeeExpenseTypeLinkId", DbType.Int32, employeeExpenseTypeLinkId); db.AddOutParameter(dbCommand, "@EmployeeExpenseTypeId", DbType.Int32, 4); db.AddOutParameter(dbCommand, "@EmployeeId", DbType.Int32, 4); db.AddOutParameter(dbCommand, "@ExpenseDate", DbType.DateTime, 8); db.AddOutParameter(dbCommand, "@Detail", DbType.String, 200); db.AddOutParameter(dbCommand, "@Comment", DbType.String, 8000); db.AddOutParameter(dbCommand, "@Amount", DbType.Double, 4); db.AddOutParameter(dbCommand, "@Budget", DbType.Double, 4); db.ExecuteNonQuery(dbCommand); EmployeeExpenseType employeeExpenseTypeLink = new EmployeeExpenseType(); employeeExpenseTypeLink.EmployeeExpenseTypeLinkId = employeeExpenseTypeLinkId; employeeExpenseTypeLink.EmployeeExpenseTypeId = Convert.ToInt32(db.GetParameterValue(dbCommand, "EmployeeExpenseTypeId")); employeeExpenseTypeLink.EmployeeId = Convert.ToInt32(db.GetParameterValue(dbCommand, "EmployeeId")); employeeExpenseTypeLink.ExpenseDate = Convert.ToDateTime(db.GetParameterValue(dbCommand, "ExpenseDate")); employeeExpenseTypeLink.Detail = db.GetParameterValue(dbCommand, "Detail").ToString(); employeeExpenseTypeLink.Comment = db.GetParameterValue(dbCommand, "Comment").ToString(); employeeExpenseTypeLink.Amount = Convert.ToDecimal(db.GetParameterValue(dbCommand, "Amount")); employeeExpenseTypeLink.Budget = Convert.ToDecimal(db.GetParameterValue(dbCommand, "Budget")); return(employeeExpenseTypeLink); }
public static List <EmployeeExpenseType> GetEmployeeExpenseTypeListByCompanyId(int companyId) { List <EmployeeExpenseType> list = new List <EmployeeExpenseType>(); Database db = DatabaseFactory.CreateDatabase("Spar-StoreRep"); string sqlCommand = "GetEmployeeExpenseTypeListByCompanyId"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "@CompanyId", DbType.Int32, companyId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { EmployeeExpenseType employeeExpenseType = new EmployeeExpenseType(); employeeExpenseType.EmployeeExpenseTypeId = Convert.ToInt32(dataReader["EmployeeExpenseTypeId"]); employeeExpenseType.Description = dataReader["Description"].ToString(); employeeExpenseType.GlCode = dataReader["GlCode"].ToString(); list.Add(employeeExpenseType); } } return(list); }