Exemple #1
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;
            }
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
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;
        }
Exemple #4
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;
            }
        }
Exemple #5
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;
            }
        }
Exemple #6
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;
            }
        }
Exemple #7
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;
        }