public NewTaskWin()
        {
            NewTask = new Task();

            InitializeComponent();
            init();
        }
        public NewTaskWin(Task task)
        {
            OldTask = task;
            NewTask = new Task(task);
            IsUpdateble = true;
            taskComments = Comment.UncheckIsNew(NewTask.GetCommentsInCollection());

            InitializeComponent();
            init();

            if(task.TimePlan > 0)
            {
                TimePlan.IsEnabled = false;
            }
        }
Beispiel #3
0
 public Task(Task task)
 {
     GUID = task.GUID;
     OrderDate = task.OrderDate;
     EndDate = task.EndDate;
     Performer = new User(task.Performer);
     Customer = new User(task.Customer);
     Topic = task.Topic;
     Description = task.Description;
     Priority = task.Priority;
     Project = new Project(task.Project);
     TimePlan = task.TimePlan;
     TimeAdjustment = task.TimeAdjustment;
     TimeFact = task.TimeFact;
     Percents = task.Percents;
     IsImportant = task.IsImportant;
     IsNew = task.IsNew;
     IsDelete = task.IsDelete;
 }
 public static string UpdateTask(Task task)
 {
     return ExecuteNonQuery(string.Format(
         "update TASKS set OrderDate='{0}',EndDate='{1}',Performer='{2}', Topic='{3}',Description='{4}',Priority={5},Project='{6}',TimePlan={7},TimeAdjustment={8},TimeFact={9},Percents={10},IsNew='{11}'\r\nwhere GUID='{12}'",
         DateTimeToSQLiteFormat(task.OrderDate.Date, false),
         DateTimeToSQLiteFormat(task.EndDate.Date, false),
         task.Performer.GUID,
         task.Topic,
         task.Description,
         task.Priority,
         task.Project.GUID,
         doubleToString(task.TimePlan),
         doubleToString(task.TimeAdjustment),
         doubleToString(task.TimeFact),
         doubleToString(task.Percents),
         task.IsNew,
         task.GUID),
                            null, true);
 }
        public static ObservableCollection<Task> GetTasksInCollection(QueryData query, bool all = false)
        {
            SQLiteConnection connection = new SQLiteConnection(ConnectionString);
            if(!all)
            {
                query.Where += query.Where == null ? " (TASKS.IsDelete='False' or TASKS.IsDelete='0')" : " and (TASKS.IsDelete='False' or TASKS.IsDelete='0')";
            }
            string command = string.Concat(
                "select distinct * \r\nfrom TASKS ",
                string.IsNullOrEmpty(query.Join) ? "" : "\r\njoin " + query.Join,
                string.IsNullOrEmpty(query.Where) ? "" : "\r\nwhere " + query.Where);
            ObservableCollection<Task> tasks = new ObservableCollection<Task>();

            try
            {
                connection.Open();
                SQLiteCommand cmd = new SQLiteCommand(command, connection);
                if (query.Parameters != null)
                {
                    foreach (SQLiteParameter p in query.Parameters)
                    {
                        cmd.Parameters.Add(p);
                    }
                }
                SQLiteDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    string guid = reader.GetString(reader.GetOrdinal("GUID"));
                    object isNew = reader["IsNew"];
                    object isDelete = reader["IsDelete"];

                    Task task = new Task(false)
                    {
                        GUID = guid,
                        OrderDate = Convert.ToDateTime(reader.GetString(reader.GetOrdinal("OrderDate"))),
                        EndDate = Convert.ToDateTime(reader.GetString(reader.GetOrdinal("EndDate"))),
                        Performer = GetUserFromGUID(reader.GetString(reader.GetOrdinal("Performer"))),
                        Customer = GetUserFromGUID(reader.GetString(reader.GetOrdinal("Customer"))),
                        Topic = reader.GetString(reader.GetOrdinal("Topic")),
                        Description = reader.GetString(reader.GetOrdinal("Description")),
                        Priority = reader.GetByte(reader.GetOrdinal("Priority")),
                        Project = new Project(false) { GUID = reader.GetString(reader.GetOrdinal("Project")) },
                        TimePlan = reader.GetDouble(reader.GetOrdinal("TimePlan")),
                        TimeAdjustment = reader.GetDouble(reader.GetOrdinal("TimeAdjustment")),
                        TimeFact = reader.GetDouble(reader.GetOrdinal("TimeFact")),
                        Percents = reader.GetDouble(reader.GetOrdinal("Percents")),
                        IsImportant = GetImportantFlagForTask(guid),
                        IsNew = Convert.ToBoolean(isNew),
                        IsDelete = Convert.ToBoolean(isDelete)
                    };
                    tasks.Add(task);
                }
            }
            catch (Exception exc)
            {
                MessageWindows.Show("GetTasksInCollection:Exception", exc.Message);
                return tasks;
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }

            foreach (Task task in tasks)
            {
                task.Project = GetParentProjectFromGUID(task.Project.GUID, all);
            }

            return tasks;
        }
 public static string AddTask(Task task)
 {
     return ExecuteNonQuery(string.Format(
         "insert into TASKS values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',{7},'{8}',{9},{10},{11},{12},'{13}','{14}','{15}')",
         task.GUID,
         DateTimeToSQLiteFormat(task.OrderDate.Date, false),
         DateTimeToSQLiteFormat(task.EndDate.Date, false),
         task.Performer.GUID,
         Settings.CurrentUser.GUID,
         task.Topic,
         task.Description,
         task.Priority,
         task.Project.GUID,
         doubleToString(task.TimePlan),
         doubleToString(task.TimeAdjustment),
         doubleToString(task.TimeFact),
         doubleToString(task.Percents),
         task.IsNew ? 1:0, 0, null),
                            null, true);
 }
Beispiel #7
0
 public static void SetBeginFlagForTask(Task task, bool add)
 {
     SQLiteWorker.SetBeginFlagForTask(task.GUID, add);
 }
Beispiel #8
0
        public static bool Equal(Task task1, Task task2)
        {
            if (task2 == null)
                return false;

            return task1.OrderDate == task2.OrderDate &&
                   task1.EndDate == task2.EndDate &&
                   task1.Performer.GUID == task2.Performer.GUID &&
                   task1.Topic == task2.Topic &&
                   task1.Description == task2.Description &&
                   task1.Priority == task2.Priority &&
                   task1.TimePlan == task2.TimePlan &&
                   task1.TimeAdjustment == task2.TimeAdjustment &&
                   task1.TimeFact == task2.TimeFact &&
                   task1.Percents == task2.Percents &&
                   task1.IsImportant == task2.IsImportant
                   ;
        }
Beispiel #9
0
 public static bool ContainsTask(ObservableCollection<Task> tasks, Task task)
 {
     return tasks.Any(t => t.GUID == task.GUID);
 }