Exemplo n.º 1
0
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            dbHelper = new DatabaseHelper();
            if (DataGood())
            {
                if (typeOfAction.Equals("create"))
                {
                    Task t = new Task(list.ID, txtName.Text, txtDescription.Text, monthCalendar1.SelectionStart, DateTime.MinValue);
                    dbHelper.CreateTask(t);
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else if (typeOfAction.Equals("update"))
                {
                    //task = new Task(txtName.Text, txtDescription.Text, monthCalendar1.SelectionStart);
                    task.Name = txtName.Text;
                    task.Description = txtDescription.Text;
                    task.DueDate = monthCalendar1.SelectionStart;
                    dbHelper.UpdateTask(task);
                }

                this.Close();
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Retry;
            }
        }
        private void CreateNewList()
        {
            DatabaseHelper dbhelper = new DatabaseHelper();
            projectName = txtProjectName.Text;

            if (DataGood())
            {
                List newProject = new List(projectName);
                dbhelper.CreateList(newProject);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Enter a List Item Name", "List Item Add Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = System.Windows.Forms.DialogResult.Retry;
            }
        }
Exemplo n.º 3
0
        private void GetData()
        {
            dbHelper = new DatabaseHelper();
            allLists = dbHelper.GetLists();

            int previousIndex = listSelectedIndex;
            listBox1.DataSource = allLists;

            if ((previousIndex + 1) > allLists.Count)
            {
                if (allLists.Count == 0)
                {
                    listBox1.ClearSelected();
                    ResetInterface();
                }
                else
                {
                    listBox1.SelectedIndex = previousIndex - 1;
                }
            }
            else
            {
                listBox1.SelectedIndex = previousIndex;
            }
        }