Ejemplo n.º 1
0
        /// <summary>
        /// Create a new TODO object.
        /// </summary>
        /// <param name="id">Initial value of the id property.</param>
        /// <param name="title">Initial value of the Title property.</param>
        /// <param name="content">Initial value of the Content property.</param>
        /// <param name="deadline">Initial value of the Deadline property.</param>
        /// <param name="finished">Initial value of the finished property.</param>
        public static TODO CreateTODO(global::System.DateTime id, global::System.String title, global::System.String content, global::System.DateTime deadline, global::System.Boolean finished)
        {
            TODO tODO = new TODO();

            tODO.id       = id;
            tODO.Title    = title;
            tODO.Content  = content;
            tODO.Deadline = deadline;
            tODO.finished = finished;
            return(tODO);
        }
Ejemplo n.º 2
0
 void deleteButtonClick(object sender, EventArgs e)
 {
     if (lstToDo.SelectedRows.Count == 1)                        // if select only one student
     {
         var      row     = lstToDo.SelectedRows[0];             // get the selected row
         var      cell    = row.Cells["id"];                     // get the cell contain id information
         DateTime id      = (DateTime)cell.Value;                // get the id value of selected student
         DBAccess db      = new DBAccess();                      // connect to database
         TODO     student = db.TODOes.Single(st => st.id == id); // select the student that matches the id
         db.TODOes.DeleteObject(student);                        // delete the selected student
         db.SaveChanges();                                       // commit the command
         this.getListTasks();                                    // refresh the students list
     }
     else
     {
         MessageBox.Show("You should select a thing!");
     }
 }
Ejemplo n.º 3
0
        void SaveButtonClick(object sender, EventArgs e)
        {
            //DateTime class_id = (DateTime)this.cboClass.SelectedValue; // get selected id value from combobox
            string id; // get inputted value from textbox
            string title    = this.txtTitle.Text;
            string content  = this.txtContent.Text;
            string deadline = this.txtDeadline.Text;
            string finished = this.txtFinished.Text;

            DBAccess db      = new DBAccess(); // open connection to database
            TODO     student = new TODO();     // create a new student object

            student.id = DateTime.Now;         // set all data for student object
            //student.id = id;
            student.Title    = title;          // then add student object to database
            student.Content  = content;
            student.Deadline = Convert.ToDateTime(deadline);
            student.finished = Convert.ToBoolean(finished);
            db.TODOes.AddObject(student);
            db.SaveChanges(); // commit the command
            this.Close();     // close the window and show message
            MessageBox.Show("Add Task successfully!");
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the TODOes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTODOes(TODO tODO)
 {
     base.AddObject("TODOes", tODO);
 }