Ejemplo n.º 1
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            TaskFile tf  = new TaskFile();
            string   str = " ";

            foreach (Control c in groupBox1.Controls)
            {
                if (c is RadioButton)
                {
                    if ((c as RadioButton).Checked)
                    {
                        str = c.Text;
                    }
                }
            }
            if (textBox1.Text == "" || textBox2.Text.ToString() == "")
            {
                MessageBox.Show("作业者和详细不能为空");
            }
            else
            {
                if (dateTimePicker1.Value < DateTime.Now)
                {
                    MessageBox.Show("预定日应该为今天以后的日期");
                }
                else
                {
                    tf.Addtask(str, dateTimePicker1.Value.ToString("yyyyMMddHHmmss"), textBox2.Text.ToString(), textBox1.Text.ToString(), DateTime.Now.ToString("yyyyMMddHHmmss"));
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show("添加成功");
                    this.Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void Fileopen()
        {
            TaskFile       tf         = new TaskFile();
            string         file       = "";
            OpenFileDialog fileDialog = new OpenFileDialog
            {
                Multiselect = true,
                Title       = "请选择文件",
                Filter      = "所有文件(*xml*)|*.xml*"
            };

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                file = fileDialog.FileName;
            }
            if (file == "")
            {
                MessageBox.Show("请选择文件");
            }
            else
            {
                List <Task> tasks = tf.LoadTasks(file);
                Listview(tasks);
            }
        }
Ejemplo n.º 3
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            if (TaskFile.Tasks == null)
            {
                MessageBox.Show("请先打开文件");
            }
            else
            {
                TaskFile tf = new TaskFile();
                if (textBox1.Text == "" || textBox2.Text == "")
                {
                    MessageBox.Show("作业者和详细不能为空");
                }
                else
                {
                    if (dateTimePicker1.Value < DateTime.Now)
                    {
                        MessageBox.Show("预定日应该为今天以后的日期");
                    }
                    else
                    {
                        switch (updateoradd)
                        {
                        case "add":
                            Task addtask = new Task
                            {
                                Priority   = priority,
                                DueTime    = DateTime.ParseExact(dateTimePicker1.Value.ToString("yyyyMMddHHmmss"), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture),
                                Assignee   = textBox2.Text,
                                Content    = textBox1.Text,
                                SubmitTime = DateTime.ParseExact(DateTime.Now.ToString("yyyyMMddHHmmss"), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture)
                            };
                            addtask.Assignee = textBox2.Text;
                            tf.Addtask(addtask);
                            break;

                        case "update":
                            Task udtask = new Task
                            {
                                Priority   = priority,
                                DueTime    = DateTime.ParseExact(dateTimePicker1.Value.ToString("yyyyMMddHHmmss"), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture),
                                Assignee   = textBox2.Text,
                                Content    = textBox1.Text,
                                SubmitTime = DateTime.ParseExact(DateTime.Now.ToString("yyyyMMddHHmmss"), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture),
                                Id         = updatetask[11].ToString(),
                            };
                            tf.UpdateTask(udtask);
                            break;
                        }
                        this.DialogResult = DialogResult.OK;
                        MessageBox.Show("编辑成功");
                        closeedit = false;
                        this.Close();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        void ChoicePriority(TaskPriority priority)
        {
            TaskFile tf = new TaskFile();

            if (this.listView1.SelectedItems.Count > 0)
            {
                int b = listView1.SelectedItems.Count;
                for (int i = 0; i < b; i++)
                {
                    tf.UpdatePriority(listView1.SelectedItems[i].SubItems[11].Text, priority);
                }
                Listview(TaskFile.Tasks);
            }
        }
Ejemplo n.º 5
0
 private void ToolStripButton6_Click(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems.Count > 0)
     {
         for (int i = 0; i < listView1.SelectedItems.Count; i++)
         {
             TaskFile tf = new TaskFile();
             tf.DeleteTask(listView1.SelectedItems[i].SubItems[11].Text);
         }
         Listview(TaskFile.Tasks);
     }
     else
     {
         MessageBox.Show("请先选择需要删除的项目");
     }
 }
Ejemplo n.º 6
0
        private void Savefile()
        {
            TaskFile       tf  = new TaskFile();
            SaveFileDialog sfd = new SaveFileDialog
            {
                Title  = "请选择保存路径",
                Filter = @"XML文件|*.xml"
            };

            sfd.ShowDialog();
            string file = sfd.FileName;

            if (string.IsNullOrEmpty(file) == false)
            {
                tf.Savefile(file);
            }
        }
Ejemplo n.º 7
0
 private void ChooseTaskPriority(string num)
 {
     try
     {
         TaskFile tf = new TaskFile();
         if (this.listView1.SelectedItems.Count > 0)
         {
             int b = listView1.SelectedItems.Count;
             for (int i = 0; i < b; i++)
             {
                 tf.UpdatePriority(listView1.SelectedItems[i].SubItems[11].Text, (TaskPriority)Enum.Parse(typeof(TaskPriority), num));
             }
             Listview(Program.Tasks);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 8
0
        private void Savefile()
        {
            TaskFile       tf  = new TaskFile();
            SaveFileDialog sfd = new SaveFileDialog
            {
                Title  = "请选择保存路径",
                Filter = @"XML文件|*.xml"
            };

            sfd.ShowDialog();
            string file = sfd.FileName;

            if (file == "")
            {
            }
            else
            {
                tf.Savefile(file);
            }
        }