/// <summary>
 /// Deprecated Method for adding a new object to the todos EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotodos(todo todo)
 {
     base.AddObject("todos", todo);
 }
 /// <summary>
 /// Create a new todo object.
 /// </summary>
 /// <param name="idTodo">Initial value of the idTodo property.</param>
 /// <param name="descripcion">Initial value of the descripcion property.</param>
 /// <param name="fechaI">Initial value of the fechaI property.</param>
 /// <param name="fechaF">Initial value of the fechaF property.</param>
 /// <param name="status">Initial value of the status property.</param>
 /// <param name="userOwner">Initial value of the userOwner property.</param>
 /// <param name="nombre">Initial value of the nombre property.</param>
 public static todo Createtodo(global::System.Int32 idTodo, global::System.String descripcion, global::System.DateTime fechaI, global::System.DateTime fechaF, global::System.String status, global::System.String userOwner, global::System.String nombre)
 {
     todo todo = new todo();
     todo.idTodo = idTodo;
     todo.descripcion = descripcion;
     todo.fechaI = fechaI;
     todo.fechaF = fechaF;
     todo.status = status;
     todo.userOwner = userOwner;
     todo.nombre = nombre;
     return todo;
 }
        protected void btnAddTodo_Click(object sender, DirectEventArgs e)
        {
            if (this.txtFechaInicio.Text.Equals("") ||
                this.txtFechaFinal.Text.Equals(""))
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Title = "Information Required",
                    Message = "You have to complete Date Fields",
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.ERROR
                });
            }
            else
            {
                using (TodoDBEntities context = new TodoDBEntities())
                {
                    string fechaIn=txtFechaInicio.Text;
                    string fechaEn=txtFechaFinal.Text;
                    string []fechaIns=fechaIn.Split('/');
                    string []fechaEns=fechaEn.Split('/');
                    int index=this.cmbStatusReal.SelectedIndex;
                    string val=(index==0?"O":index==1?"C":"D");
                    todo newTodo=new todo{
                        nombre=txtName.Value.ToString(),
                        descripcion=txtDescription.Value.ToString(),

                        fechaI=new DateTime(int.Parse(fechaIns[2]),
                            int.Parse(fechaIns[0]),
                            int.Parse(fechaIns[1])),
                        fechaF=new DateTime(int.Parse(fechaEns[2]),
                            int.Parse(fechaEns[0]),
                            int.Parse(fechaEns[1])),
                        status=val,
                        userOwner=User.Identity.Name
                    };

                    context.todos.AddObject(newTodo);
                    try
                    {
                        context.SaveChanges();
                    }
                    catch (Exception error)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title = "Error...",
                            Message = error.Message,
                            Buttons = MessageBox.Button.OK,
                            Icon = MessageBox.Icon.ERROR
                        });
                        return;
                    }

                }

                X.Msg.Show(new MessageBoxConfig
                {
                    Title = "TO-DO Added!",
                    Message = "Your new TO-DO has been added",
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.INFO
                });
                resetInformation();
            }
        }