private static List <ExpenseTypes> _GetExpenseTypes() { List <ExpenseTypes> ExpenseTypes = new List <ExpenseTypes>(); try { Command = "select * from tblExamTypes"; db.cmd.CommandText = Command; db.con.Open(); SqlDataReader rdr = db.cmd.ExecuteReader(); while (rdr.Read()) { ExpenseTypes singleExpenseTypes = new ExpenseTypes(); singleExpenseTypes.Id = (int)rdr[0]; singleExpenseTypes.ExpenseTypeName = rdr[1].ToString(); ExpenseTypes.Add(singleExpenseTypes); } } catch (SqlException sqlex) { SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling(); rh.GetError(sqlex); } finally { db.con.Close(); } return(ExpenseTypes); }
public static int Add(ExpenseTypes expensetypes) { int retvalue = -1; try { db.cmd.CommandType = CommandType.StoredProcedure; db.cmd.CommandText = "procExpenseTypes_ExpenseTypes"; db.cmd.Parameters.AddWithValue("@ExpenseTypeName", expensetypes.ExpenseTypeName); db.cmd.Parameters.Add("@Id", SqlDbType.Int); db.cmd.Parameters["@Id"].Direction = ParameterDirection.Output; db.con.Open(); db.cmd.ExecuteNonQuery(); retvalue = Convert.ToInt32(db.cmd.Parameters["@Id"].Value); } catch (SqlException sqlex) { SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling(); rh.GetError(sqlex); } finally { db.CloseDb(db.con, db.cmd); } return(retvalue); }
public static int Add(ExpenseRecords expenseRecords, ExpenseTypes expenseTypes) { int retvalue = -1; expenseRecords.ExpenseTypesId = ExpenseTypes.Add(expenseTypes); retvalue = ExpenseRecords.Add(expenseRecords); return(retvalue); }
private static List <ExpenseRecords> _GetExpenseRecords() { List <ExpenseRecords> ExpenseRecords = new List <ExpenseRecords>(); try { Command = "select * from tblExpenseRecords"; db.cmd.CommandText = Command; db.con.Open(); SqlDataReader rdr = db.cmd.ExecuteReader(); while (rdr.Read()) { ExpenseRecords singleExpenseRecords = new ExpenseRecords(); singleExpenseRecords.Id = (int)rdr[0]; singleExpenseRecords.DateTime = Convert.ToDateTime(rdr[1]); singleExpenseRecords.Paid = Convert.ToBoolean(rdr[2]); singleExpenseRecords.AddedByEmployeesId = (int)rdr[3]; singleExpenseRecords.ExpenseTypesId = (int)rdr[4]; var emp = new Employees(); singleExpenseRecords.AddedByEmployees = Employees.ListOfEmployees.SingleOrDefault(e => e.Id == singleExpenseRecords.AddedByEmployeesId); var exptype = new ExpenseTypes(); singleExpenseRecords.ExpenseTypes = ExpenseTypes.ListOfExpenseTypes.SingleOrDefault(et => et.Id == singleExpenseRecords.ExpenseTypesId); ExpenseRecords.Add(singleExpenseRecords); } } catch (SqlException sqlex) { SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling(); rh.GetError(sqlex); } finally { db.con.Close(); } return(ExpenseRecords); }
public static void Update(int id, ExpenseTypes expensetypes) { try { db.cmd.CommandText = "update tblExpenseTypes set ExpenseTypeName = @ExpenseTypeName where Id=@id"; db.cmd.Parameters.AddWithValue("@ExpenseTypename", expensetypes.ExpenseTypeName); db.cmd.Parameters.AddWithValue("@id", id); db.con.Open(); db.cmd.ExecuteNonQuery(); } catch (SqlException sqlex) { SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling(); rh.GetError(sqlex); } finally { db.CloseDb(db.con, db.cmd); } }
public ExpenseRecords() { ExpenseTypes = new ExpenseTypes(); AddedByEmployees = new Employees(); }
public static void Update(int Id, ExpenseRecords expenserecords, ExpenseTypes expensetypes) { expenserecords.ExpenseTypesId = ExpenseTypes.Add(expensetypes); ExpenseRecords.Update(Id, expenserecords); }