예제 #1
0
        public TaskAssign updateTask(TaskAssign task)
        {
            task.idStatus = getStatusID(task.Status);
            try
            {
                string description = task.Description == null ? "" : task.Description.ToString().Trim();
                //                string status = task.Status == null ? "" : task.Status.ToString().Trim();

                string updateQuery = @"update [INF6150].[dbo].[Task] set description = '" + description + "', "
                                     + "idProjet = " + task.idProjet + ", "
                                     + "idEtat = " + task.idStatus + ", "
                                     + "nbrHeuresEstime = " + task.nbHeuresEstime + " "
                                     + "where idTache = " + task.IdTask;

                using (SqlConnection conn = new SqlConnection())
                {
                    conn.ConnectionString = SqlDatabaseConnection.CONNECTIONSTRING;

                    conn.Open();

                    SqlCommand command = new SqlCommand(updateQuery, conn);

                    command.ExecuteNonQuery();

                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(task);
        }
예제 #2
0
        public TaskAssign createTask(TaskAssign task)
        {
            // test if task does not exist

            task.idStatus = getStatusID(task.Status);

            string createQuery = @"INSERT INTO [INF6150].[dbo].[Task] (idTache, description, idProjet, nbrHeuresEstime, idEtat) "
                                 + "VALUES (" + getNextTaskID() + ",'" + task.Description + "', " + task.idProjet + ", " + task.nbHeuresEstime + ", " + task.idStatus + ")";

            try
            {
                using (SqlConnection conn = new SqlConnection())
                {
                    conn.ConnectionString = SqlDatabaseConnection.CONNECTIONSTRING;

                    conn.Open();

                    SqlCommand command = new SqlCommand(createQuery, conn);

                    command.ExecuteNonQuery();

                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(task);
        }
예제 #3
0
        // pour assigner un une tâches à un user
        public void addTaskUser(TaskAssign task)
        {
            try
            {
                string addQuery = @"insert into [INF6150].[dbo].[TaskUser](idTache,matricule)"
                                  + "VALUES(" + task.IdTask + ", '" + task.utilisateur + "')";

                using (SqlConnection conn = new SqlConnection())
                {
                    conn.ConnectionString = SqlDatabaseConnection.CONNECTIONSTRING;

                    conn.Open();

                    SqlCommand command = new SqlCommand(addQuery, conn);

                    command.ExecuteNonQuery();

                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }