Ejemplo n.º 1
0
        private void btnReg_Click(object sender, EventArgs e)
        {
            string errMsg = Validate();
            if (string.IsNullOrEmpty(errMsg) == false)
            {
                MessageBox.Show(this,errMsg,this.Text,MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }

            var exDao = new ClsExecuteDao(dao.Connection);

            var list = exDao.ExecuteToDo();
            ClsToDoModel insertModel = null;
            if (list.Count == 0)
            {
                insertModel = new ClsToDoModel()
                {
                    TodoCode = 1,
                    Title = textBox1.Text,
                    RegDate = DateTime.Today,
                    StartDate = dateTimePicker2.Value,
                    EndDate = dateTimePicker3.Value,
                    Detail = textBox2.Text
                };

            }
            else
            {
                insertModel = list.Last();
                insertModel.TodoCode = insertModel.TodoCode + 1;
                insertModel.Title = textBox1.Text;
                insertModel.RegDate = DateTime.Today;
                insertModel.StartDate = dateTimePicker2.Value;
                insertModel.EndDate = dateTimePicker3.Value;
                insertModel.Detail = textBox2.Text;
            }

            int result = exDao.InsertToDo(insertModel);

            if (result != 1)
            {
                MessageBox.Show(this, "登録が正常に行われませんでした", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                MessageBox.Show(this, "登録に成功しました", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            Clear();
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            List<int> paramList = new List<int>();
            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i))
                {
                    string[] code = checkedListBox1.Items[i].ToString().Split(':');
                    paramList.Add(Convert.ToInt32(code[0]));
                }
            }

            var executeDao = new ClsExecuteDao(dao.Connection);
            executeDao.UpdateToDo(paramList.ToArray());
            LoadData();
        }
Ejemplo n.º 3
0
        public void LoadData()
        {
            var executeDao = new ClsExecuteDao(dao.Connection);
            var list = executeDao.ExecuteToDo(1);

            while (this.checkedListBox1.Items.Count > 0)
            {
                this.checkedListBox1.Items.Remove(this.checkedListBox1.Items[0]);
            }

            foreach (ClsToDoModel model in list)
            {
                this.checkedListBox1.Items.Add(model.TodoCode.ToString() + ":" + model.Title);
            }

            modelList = list;
        }