Beispiel #1
0
        public void editTask(ListViewItem item)
        {
            WorkTimeEditForm editForm = new WorkTimeEditForm();

            string taskId = item.SubItems[1].Text;

            string taskName = "",
                   consumed = "",
                   left     = "";

            bool     finished = item.SubItems[6].Tag == null ? false : (bool)item.SubItems[6].Tag;
            TaskInfo task     = queryTaskById(taskId);

            taskName = task.name;
            consumed = task.consumed;
            left     = task.left;
            finished = finished ? finished : task.isDone;

            //设置弹窗初始化值
            editForm.setValues(taskId, taskName, consumed, left, finished);

            DialogResult result = editForm.ShowDialog();


            task.name            = editForm.getTaskName();
            task.currentConsumed = Convert.ToString(float.Parse(editForm.getConsumed()) - float.Parse(task.consumed));
            task.consumed        = editForm.getConsumed();
            task.left            = editForm.getLeft();
            task.isDone          = editForm.isFinished();
            taskList.BeginUpdate();

            item.Checked          = true;
            item.SubItems[2].Text = task.name;
            item.SubItems[4].Text = task.consumed;
            item.SubItems[5].Text = task.left;
            item.SubItems[6].Tag  = task.isDone;

            drawCheckBox(taskList, item.SubItems[6], task.isDone);

            taskList.EndUpdate();
        }
        public void editTask(ListViewItem item)
        {
            WorkTimeEditForm editForm = new WorkTimeEditForm();

            string taskId = item.SubItems[1].Text;

            string taskName = "",
                   consumed = "",
                   left = "";

            bool finished = item.SubItems[6].Tag == null ? false : (bool)item.SubItems[6].Tag;
            TaskInfo task = queryTaskById(taskId);

            taskName = task.name;
            consumed = task.consumed;
            left = task.left;
            finished = finished ? finished : task.isDone;

            //设置弹窗初始化值
            editForm.setValues(taskId, taskName, consumed, left, finished);

            DialogResult result = editForm.ShowDialog();

            task.name = editForm.getTaskName();
            task.currentConsumed = Convert.ToString(float.Parse(editForm.getConsumed()) - float.Parse(task.consumed));
            task.consumed = editForm.getConsumed();
            task.left = editForm.getLeft();
            task.isDone = editForm.isFinished();
            taskList.BeginUpdate();

            item.Checked = true;
            item.SubItems[2].Text = task.name;
            item.SubItems[4].Text = task.consumed;
            item.SubItems[5].Text = task.left;
            item.SubItems[6].Tag = task.isDone;

            drawCheckBox(taskList, item.SubItems[6], task.isDone);

            taskList.EndUpdate();
        }