public override string GetSqlText(DataAccessor accessor, DbManager dbManager)
				{
					return SqlText + 1
#if FIREBIRD
						+ " from dual"
#endif
						;
				}
Example #2
0
        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;
            }
        }
Example #3
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);
        }
Example #4
0
        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));
        }
Example #5
0
		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));
		}
Example #6
0
        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);
                }
            }
        }
Example #7
0
 public override string GetSqlText(DataAccessor accessor, DbManager dbManager)
 {
     return(SqlText + 1);
 }
Example #8
0
        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;
        }
Example #9
0
        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;
            }
        }
Example #10
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;
            }
        }
Example #11
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;
            }
        }
Example #12
0
 private void ScalarDestinationException()
 {
     // ExecuteScalar destination must be an out or a ref parameter
     //
     DataAccessor.CreateInstance(typeof(ScalarDestinationAccessor));
 }
Example #13
0
        public void NullableScalarTest()
        {
            int?[] @outputIntArray = ((TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor))).NullableScalarArray();

            Assert.AreEqual(new int?[] { 1, 2, 3, 4, 5 }, @outputIntArray);
        }
Example #14
0
				public override string GetSqlText(DataAccessor accessor, DbManager dbManager)
				{
					return SqlText + 1;
				}
Example #15
0
 private void MultiDestinationException()
 {
     // More then one parameter is marked as destination.
     //
     DataAccessor.CreateInstance(typeof(MultiDestinationAccessor));
 }
Example #16
0
 private void Typeless2()
 {
     // Can not determine object type for the method 'TypelessAccessor2.Typeless'
     //
     DataAccessor.CreateInstance(typeof(TypelessAccessor2));
 }
Example #17
0
 private void IllegalDataSetTable()
 {
     // DataSetTable attribute may not be an index
     //
     DataAccessor.CreateInstance(typeof(IllegalDataSetTableAccessor));
 }
Example #18
0
 private void VoidDestinationException()
 {
     // ExecuteNonQuery does not support the Destination attribute
     //
     DataAccessor.CreateInstance(typeof(VoidDestinationAccessor));
 }
Example #19
0
        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;
        }
Example #20
0
 public static EntityAccessor CreateInstance(DbManager dbManager)
 {
     return(DataAccessor.CreateInstance <EntityAccessor>(dbManager));
 }
Example #21
0
 public DictionaryTest()
 {
     _da = (TestAccessor)DataAccessor.CreateInstance(typeof(TestAccessor));
 }