Example #1
0
 public void ChangeValues(TasksModel task)
 {
     taskValue.Text     = task.Task;
     commentValue.Text  = task.Comment;
     PriorityValue.Text = task.Priority.ToString();
     dateValue.Text     = task.TimeToDo;
 }
Example #2
0
 public static void DeleteTask(TasksModel task)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
     {
         cnn.Execute("Delete From Tasks WHERE ID = @ID", task);
     }
 }
Example #3
0
 public static void SaveTask(TasksModel task)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
     {
         cnn.Execute("insert into Tasks (ID, Task, Comment, Priority, TimeToDo) values (@ID, @Task, @Comment, @Priority, @TimeToDo);", task);
     }
 }
Example #4
0
 public static TasksModel LoadATask(TasksModel task)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
     {
         return(cnn.Query <TasksModel>("select * from Tasks WHERE ID = @ID", task).First());
     }
 }
Example #5
0
        private void DeleteTask(object sender, EventArgs e)
        {
            CheckBox   theBox = (CheckBox)sender;
            int        id     = Int32.Parse(theBox.Name.Substring(7));
            TasksModel task   = new TasksModel();

            task.ID = id;
            SqliteDataAccess.DeleteTask(task);
            MainFLP.Controls.Remove(theBox.Parent);
        }
Example #6
0
        private void ShowFullTask(object sender, EventArgs e)
        {
            Button     btn       = (Button)sender;
            int        id        = Int32.Parse(btn.Name.Substring(4));
            TasksModel emptyTask = new TasksModel();

            emptyTask.ID = id;
            TasksModel task     = SqliteDataAccess.LoadATask(emptyTask);
            FullTask   fullTask = new FullTask();

            fullTask.ChangeValues(task);
            fullTask.Show();
        }
Example #7
0
        private void AddTaskToThePanel(TasksModel task)
        {
            FlowLayoutPanel box = new FlowLayoutPanel();

            box.FlowDirection = FlowDirection.LeftToRight;
            box.Size          = new Size(385, 30);
            box.BorderStyle   = BorderStyle.FixedSingle;

            Label labelTask = new Label();

            labelTask.Text     = task.Task;
            labelTask.AutoSize = true;
            labelTask.Margin   = new Padding(7);
            box.Controls.Add(labelTask);

            Button comment = new Button();

            comment.BackColor = SystemColors.ActiveCaption;
            comment.Name      = "btn#" + task.ID.ToString();
            comment.Size      = new Size(20, 20);
            comment.Click    += new EventHandler(ShowFullTask);
            box.Controls.Add(comment);

            Label priority = new Label();

            priority.AutoSize = true;
            priority.Text     = task.Priority.ToString();
            priority.Margin   = new Padding(7);
            box.Controls.Add(priority);

            if (String.IsNullOrEmpty(task.TimeToDo) != true)
            {
                Label date = new Label();
                date.Text     = task.TimeToDo;
                date.AutoSize = true;
                date.Margin   = new Padding(7);
                box.Controls.Add(date);
            }


            CheckBox IsDone = new CheckBox();

            IsDone.Name            = "checkB#" + task.ID.ToString();
            IsDone.CheckedChanged += new EventHandler(DeleteTask);
            box.Controls.Add(IsDone);

            MainFLP.Controls.Add(box);
        }
Example #8
0
 private void btnAddTask_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrWhiteSpace(TaskTextBox.Text) != true)
     {
         TasksModel task;
         lastID++;
         if (checkBoxTime.CheckState == CheckState.Checked)
         {
             task = new TasksModel(lastID, TaskTextBox.Text, CommentTextBox.Text, Convert.ToInt32(numUDPriority.Value), dateTimePicker.Value.ToShortDateString());
         }
         else
         {
             task = new TasksModel(lastID, TaskTextBox.Text, CommentTextBox.Text, Convert.ToInt32(numUDPriority.Value));
         }
         SqliteDataAccess.SaveTask(task);
         AddTaskToThePanel(task);
     }
     else
     {
         MessageBox.Show("Write a task!", "Add task", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }