示例#1
0
        public void Edit(Task task)
        {
            String prefikslog = "Nastąpił problem podczas modyfikowanie rekordu w bazie danych o Id = ";

             reconnectDB(connectionDB);

             try
             {
                String sqlquery = "UPDATE TASK SET " +
                                  "Ttle = @Title, Category = @CategoryId, UserId = @UserId, "+
                                  "Finished = @Finished, InserTime = @InserTime," +
                                  "LasteEdit = @LastEdit, ScheduledTime = @ScheduledTime, " +
                                  "Description = @Description, Priority = @Priority"+
                                  "WHERE Id = @Id";

                SqlCommand SqlCommand = new SqlCommand(sqlquery, connectionDB);
                fillCommonSqlCommand(SqlCommand, task);
                SqlCommand.Parameters.Add("@Id",task.Id);
                SqlCommand.ExecuteNonQuery();
            }
            catch(Exception e)
            {
                saveLog(filepath, prefikslog, e);
            }
        }
示例#2
0
        public void Delete(Task task)
        {
            String prefikslog = "Nastąpił problem podczas kasowania rekordu o Id = ";

            reconnectDB(connectionDB);

            try
            {
                String sqlquery = " DELETE * FROM TASK WHERE Id = @Id";
                SqlCommand SqlCommand = new SqlCommand(sqlquery, connectionDB);
                SqlCommand.Parameters.Add("@Id",task.Id);
                SqlCommand.ExecuteNonQuery();
            }
            catch(Exception e)
            {
                saveLog(filepath, prefikslog, e);
            }
        }
示例#3
0
        public void Create(Task task)
        {
            String prefikslog = "Nastąpił problem podczas zapisywania rekordu do bazy danych ";

            reconnectDB(connectionDB);

            try
            {
                String sqlquery = "INSERT INTO TASK VALUE " +
                                  "(@Title, @CategoryId, @UserId, @Finished, @InserTime,"+
                                  "@LastEdit, @ScheduledTime, @Description, @Priority)";

                SqlCommand SqlCommand = new SqlCommand(sqlquery, connectionDB);
                fillCommonSqlCommand(SqlCommand, task);
                SqlCommand.ExecuteNonQuery();
            }
            catch(Exception e)
            {
                saveLog(filepath, prefikslog, e);
            }
        }
示例#4
0
        public List<Task> GetItAll()
        {
            String prefikslog = "Nastąpił problem podczas pobierania rekordów z bazy danych ";

            reconnectDB(connectionDB);

            List<Task> ListTask = new List<Task>();

            try
            {
                String sqlquery = "SELECT * FROM TASK";
                SqlCommand SqlCommand = new SqlCommand(sqlquery, connectionDB);
                SqlDataReader CollectionData = SqlCommand.ExecuteReader();

                while(CollectionData.Read())
                {
                    Task task = new Task();
                    fillTask(CollectionData, task);
                    ListTask.Add(task);
                }

            }
            catch(Exception e)
            {
                saveLog(filepath, prefikslog, e);
            }

            return ListTask;
        }
示例#5
0
 private void fillTask(SqlDataReader CollectionData, Task task)
 {
     while (CollectionData.Read())
     {
         task.Ttle = CollectionData["Ttle"].ToString();
         task.Description = CollectionData["Descritpion"].ToString();
         task.SheduledTime = (DateTime)CollectionData["SheduledTime"];
         task.Priority = (Int16)CollectionData["Priority"];
     }
 }
示例#6
0
 private void fillCommonSqlCommand(SqlCommand SqlCommand, Task task)
 {
     SqlCommand.Parameters.Add("@Title", task.Ttle);
     SqlCommand.Parameters.Add("@CategoryId", task.CategoryId);
     SqlCommand.Parameters.Add("@UserId", task.UserId);
     SqlCommand.Parameters.Add("@Finished", task.Finished);
     SqlCommand.Parameters.Add("@InserTime", task.InsertTime);
     SqlCommand.Parameters.Add("@LastEdit", task.LastEdit);
     SqlCommand.Parameters.Add("@ScheduledTime", task.SheduledTime);
     SqlCommand.Parameters.Add("@Description", task.Description);
     SqlCommand.Parameters.Add("@Priority", task.Priority);
 }
示例#7
0
        public Task GetOne(int Id)
        {
            String prefikslog = "Nastąpił problem podczas pobierania rekordu z bazy danych ";

            reconnectDB(connectionDB);

            Task task = new Task();

            try
            {
                String sqlquery = "SELECT * FROM TASK WHERE Id = @Id";
                SqlCommand SqlCommand = new SqlCommand(sqlquery, connectionDB);
                SqlCommand.Parameters.Add("Id",Id);
                SqlDataReader CollectionData = SqlCommand.ExecuteReader();
                fillTask(CollectionData, task);
            }
            catch(Exception e)
            {
                saveLog(filepath, prefikslog, e);
            }
            return task;
        }