Exemple #1
0
        public ToDoLists AddToDo(ToDoLists item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            db.ToDoLists.Add(item);
            db.SaveChanges();
            return(item);
        }
Exemple #2
0
 public bool EditToDo(ToDoLists item)
 {
     try
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemple #3
0
 public bool DeleteToDo(int id)
 {
     try
     {
         ToDoLists ToDoLists = db.ToDoLists.Find(id);
         db.ToDoLists.Remove(ToDoLists);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemple #4
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ToDoLists toDoLists = _toDosServices.GetToDoByID(Convert.ToInt32(id));

            if (toDoLists == null)
            {
                return(HttpNotFound());
            }
            return(View(toDoLists));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "ID,Definition,DueDate,Priority,Attribute,Reminders")] ToDoLists ToDoList)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _toDosServices.AddToDo(ToDoList);
                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    return(View("Error", new HandleErrorInfo(e, "ToDoLists", "Create")));
                }
            }

            return(View(ToDoList));
        }
Exemple #6
0
        public ActionResult Edit([Bind(Include = "ID,Definition,DueDate,Priority,Attribute")] ToDoLists toDoLists)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    bool edit = _toDosServices.EditToDo(toDoLists);
                    if (edit)
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                catch (Exception e)
                {
                    return(View("Error", new HandleErrorInfo(e, "ToDoLists", "Edit")));
                }
            }

            return(View(toDoLists));
        }
Exemple #7
0
        public void button_Click(object sender, EventArgs e)
        {
            switch (fun)
            {
            case 1:
                Form1.getInstance().ShowTypeNote();
                //Form1.getInstance().NewNote();
                break;

            case 2:     //edit
                if (Form1.type == 0)
                {
                    MessageBox.Show("Vui lòng thử lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    switch (Form1.type)
                    {
                    case 1:
                        Notes a = DataHandle.getInstance().GetDataFromNote();
                        Form1.getInstance().editNote(a.Tittle, a.Content);
                        break;

                    case 2:
                        ToDoLists b = DataHandle.getInstance().GetDataToDoList();
                        if (b == null)
                        {
                            MessageBox.Show("Choose note to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            Form1.getInstance().editToDoList(b.Tittle, b.item);
                        }
                        break;

                    case 3:
                        Reminders c = DataHandle.getInstance().GetDateReminder();
                        if (c == null)
                        {
                            MessageBox.Show("Choose note to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            Form1.getInstance().EditReminder(c.Tittle, c.Content, c.Time, c.Check);
                        }
                        break;
                    }
                }


                break;

            case 3:     //delete

                if (Form1.type == 0)
                {
                    MessageBox.Show("Vui lòng thử lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    switch (Form1.type)
                    {
                    case 1:
                        DataHandle.getInstance().DeleteNote();
                        DataHandle.getInstance().ShowNote();
                        break;

                    case 2:
                        DataHandle.getInstance().DeleteToDoList();
                        DataHandle.getInstance().ShowNote();
                        break;

                    case 3:
                        DataHandle.getInstance().DeleteReminder();
                        DataHandle.getInstance().ShowNote();
                        break;
                    }
                }
                break;

            case 4:
                if (Form1.type == 0)
                {
                    MessageBox.Show("Vui lòng thử lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    switch (Form1.type)
                    {
                    case 1:         //note
                        Notes a = DataHandle.getInstance().GetDataFromNote();
                        if (Connection.clientStatus == -1)
                        {
                            MessageBox.Show("No connection is found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else if (Connection.clientStatus == 0)
                        {
                            Connection.DistributeNote(a);
                        }
                        else
                        {
                            Form1.connection.CSendNote(a);
                        }
                        break;

                    case 2:        //tdl
                        break;

                    case 3:        //rmd
                        Reminders rmd = DataHandle.getInstance().GetDateReminder();
                        if (Connection.clientStatus == -1)
                        {
                            MessageBox.Show("No connection is found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else if (Connection.clientStatus == 0)
                        {
                            Connection.DistributeReminder(rmd);
                        }
                        else
                        {
                            Form1.connection.CSendReminder(rmd);
                        }
                        break;
                    }
                }
                break;
            }
        }