public override string GetSqlText(DataAccessor accessor, DbManager dbManager) { return SqlText + 1 #if FIREBIRD + " from dual" #endif ; }
public bool Save() { var dataAcc = new DataAccessor(); using (var command = new SQLiteCommand(dataAcc.GetConnection())) { command.CommandText = string.Format(@"UPDATE usersettings SET name = '{0}', hoursIfVacation = '{1}', hourlyrate = '{2}' ", Name, FormatFloatToString(VacancyHours), FormatFloatToString(HourlyRate)); var reader = command.ExecuteNonQuery(); return reader > 0; } }
public void MultiPKTestReturnVoid() { TestAccessor da = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor)); Hashtable persons = new Hashtable(); da.MultiPKReturnVoid(persons); Assert.IsNotNull(persons); Assert.IsTrue(persons.Count > 0); Assert.IsNull(persons[new CompoundValue(-1, "NoSuchPerson")]); PersonMultiPK actualValue = (PersonMultiPK)persons[new CompoundValue(1, "Pupkin")]; Assert.IsNotNull(actualValue); Assert.AreEqual("John", actualValue.FirstName); }
public override string GetSqlText(DataAccessor accessor, BLToolkit.Data.DbManager dbManager) { switch (dbManager.DataProvider.Name) { case ProviderName.MsSql: case ProviderName.SqlCe: return(SqlText); case ProviderName.Access: return(AccessText ?? SqlText); case "Oracle": case ProviderName.Oracle: return(OracleText ?? SqlText); case ProviderName.Firebird: return(FbText ?? SqlText); case ProviderName.SQLite: return(SQLiteText ?? SqlText); } throw new ApplicationException(string.Format("Unknown data provider '{0}'", dbManager.DataProvider.Name)); }
public override string GetSqlText(DataAccessor accessor, BLToolkit.Data.DbManager dbManager) { switch (dbManager.DataProvider.Name) { case ProviderName.MsSql : case ProviderName.SqlCe : return SqlText; case ProviderName.Access : return AccessText ?? SqlText; case "Oracle": case ProviderName.Oracle : return OracleText ?? SqlText; case ProviderName.Firebird: return FbText ?? SqlText; case ProviderName.SQLite : return SQLiteText ?? SqlText; } throw new ApplicationException(string.Format("Unknown data provider '{0}'", dbManager.DataProvider.Name)); }
public User() { var dataAcc = new DataAccessor(); using (var command = new SQLiteCommand(dataAcc.GetConnection())) { command.CommandText = "SELECT * FROM usersettings"; var reader = command.ExecuteReader(); while (reader.Read()) { Name = reader.GetString(0); HolidayHours = reader.GetFloat(1); VacancyHours = reader.GetFloat(1); HourlyRate = reader.GetFloat(2); } } }
public override string GetSqlText(DataAccessor accessor, DbManager dbManager) { return(SqlText + 1); }
public static float GetHoursForMonth(string month, string year) { var dataAcc = new DataAccessor(); var retFloat = 0.0f; using (var command = new SQLiteCommand(dataAcc.GetConnection())) { command.CommandText = string.Format("SELECT * FROM worktime WHERE month= '{0}' AND year = '{1}'", month, year); var reader = command.ExecuteReader(); while (reader.Read()) { retFloat += reader.GetFloat(3); } } return retFloat; }
public bool Save() { var dataAcc = new DataAccessor(); using (var command = new SQLiteCommand(dataAcc.GetConnection())) { command.CommandText = string.Format(@"INSERT INTO worktime (workedHours, dayType, day, month, year) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}')", FormatFloatToString(this.Hours), (int)DayType, this.Day, this.Month, this.Year); var reader = command.ExecuteNonQuery(); return reader > 0; } }
public bool Edit() { var dataAcc = new DataAccessor(); using (var command = new SQLiteCommand(dataAcc.GetConnection())) { command.CommandText = string.Format(@"UPDATE worktime SET workedHours = '{0}', dayType = '{1}' WHERE day = '{2}' AND month = '{3}' AND year = '{4}'", FormatFloatToString(this.Hours), (int)DayType, this.Day, this.Month, this.Year); var reader = command.ExecuteNonQuery(); return reader > 0; } }
public bool Delete() { var dataAcc = new DataAccessor(); using (var command = new SQLiteCommand(dataAcc.GetConnection())) { command.CommandText = string.Format(@"DELETE FROM worktime WHERE day = '{0}' AND month = '{1}' AND year = '{2}'", this.Day, this.Month, this.Year); var reader = command.ExecuteNonQuery(); return reader > 0; } }
private void ScalarDestinationException() { // ExecuteScalar destination must be an out or a ref parameter // DataAccessor.CreateInstance(typeof(ScalarDestinationAccessor)); }
public void NullableScalarTest() { int?[] @outputIntArray = ((TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor))).NullableScalarArray(); Assert.AreEqual(new int?[] { 1, 2, 3, 4, 5 }, @outputIntArray); }
public override string GetSqlText(DataAccessor accessor, DbManager dbManager) { return SqlText + 1; }
private void MultiDestinationException() { // More then one parameter is marked as destination. // DataAccessor.CreateInstance(typeof(MultiDestinationAccessor)); }
private void Typeless2() { // Can not determine object type for the method 'TypelessAccessor2.Typeless' // DataAccessor.CreateInstance(typeof(TypelessAccessor2)); }
private void IllegalDataSetTable() { // DataSetTable attribute may not be an index // DataAccessor.CreateInstance(typeof(IllegalDataSetTableAccessor)); }
private void VoidDestinationException() { // ExecuteNonQuery does not support the Destination attribute // DataAccessor.CreateInstance(typeof(VoidDestinationAccessor)); }
public static List<WorkDay> GetWorkingDaysByMonthAndYear(string month, string year) { var dataAcc = new DataAccessor(); var retList = new List<WorkDay>(); using (var command = new SQLiteCommand(dataAcc.GetConnection())) { command.CommandText = string.Format("SELECT * FROM worktime WHERE month= '{0}' AND year = '{1}'", month, year); var reader = command.ExecuteReader(); while (reader.Read()) { var wDay = new WorkDay(); wDay.Day = (string)reader.GetString(0); wDay.Month = (string)reader.GetString(1); wDay.Year = (string)reader.GetString(2); wDay.Hours = reader.GetFloat(3); switch (reader.GetInt32(4)) { case 0: wDay.DayType = DayTypes.Workday; break; case 1: wDay.DayType = DayTypes.Holiday; break; case 2: wDay.DayType = DayTypes.Vacancy; break; } retList.Add(wDay); } } return retList; }
public static EntityAccessor CreateInstance(DbManager dbManager) { return(DataAccessor.CreateInstance <EntityAccessor>(dbManager)); }
public DictionaryTest() { _da = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor)); }