示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var repository = TaskRepository.Instance;
            DropDownListCategories.DataSource     = repository.GetCategories();
            DropDownListCategories.DataTextField  = "Value";
            DropDownListCategories.DataValueField = "Key";
            DropDownListCategories.DataBind();

            CalendarStartTime.SelectedDate = CalendarStartTime.TodaysDate;
            CalendarDueDate.SelectedDate   = CalendarDueDate.TodaysDate;

            DropDownListPriority.DataSource = TaskRepository.GetValidPriorities();
            DropDownListPriority.DataBind();
        }

        LabelResults.Text = string.Empty;
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int  taskId     = Convert.ToInt32(Request["taskId"]);
        var  repository = TaskRepository.Instance;
        Task task       = repository.GetTask(taskId);

        if (task == null || task.UserName != User.Identity.Name)
        {
            LabelResults.Text      = string.Format("Cannot find task with id '{0}' or this task does not belong to you", taskId);
            ButtonEditTask.Enabled = false;
        }
        else
        {
            TextBoxName.Text = task.Name;

            if (!IsPostBack)
            {
                DropDownListCategories.DataSource     = repository.GetCategories();
                DropDownListCategories.DataTextField  = "Value";
                DropDownListCategories.DataValueField = "Key";
                DropDownListCategories.DataBind();

                CalendarStartTime.SelectedDate = task.StartDate;
                CalendarDueDate.SelectedDate   = task.DueDate;

                DropDownListPriority.DataSource = TaskRepository.GetValidPriorities();
                DropDownListPriority.DataBind();

                TextBoxPercentComplete.Text = task.PercentComplete.ToString();

                bool isCompleted = task.Completed;
                CheckBoxIsCompleted.Checked = isCompleted;
                ButtonEditTask.Enabled      = !isCompleted;
            }

            TextBoxStartDate.Text = CalendarStartTime.SelectedDate.ToLongDateString();
            TextBoxDueDate.Text   = CalendarDueDate.SelectedDate.ToLongDateString();
        }
    }