Пример #1
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            //Remove any whitespace from the text in the control
            textBox1.Text = textBox1.Text.Trim();
            textBox2.Text = textBox2.Text.Trim();
            textBox4.Text = textBox4.Text.Trim();
            textBox5.Text = textBox5.Text.Trim();

            //If we fail validation, abort the save procedure and return
            if (!ValidateForm())
            {
                return;
            }

            textBox1.Text = textBox1.Text.Substring(0, 1).ToUpper() + textBox1.Text.Substring(1);

            //
            //MessageBox.Show("TEST PASSED!!", ProductName, MessageBoxButtons.OK);
            foreach (SsOpsDatabaseLibrary.Entity.Task task in _tasks)
            {
                if (task.TaskName.ToUpper() == textBox1.Text.ToUpper())
                {
                    MessageBox.Show("This task already exists in the grid.", "Attention", MessageBoxButtons.OK);
                    textBox1.Focus();
                    textBox1.SelectionStart  = 0;
                    textBox1.SelectionLength = textBox1.Text.Length;
                    return;
                }
            }
            //Uppercase the first character of each to ensure title case
            textBox1.Text = textBox1.Text.Substring(0, 1).ToUpper() + textBox1.Text.Substring(1);

            //We have to connect each of the columns in the table to recognize the text from the textbox should be in there now
            SsOpsDatabaseLibrary.Entity.Task tsk = new SsOpsDatabaseLibrary.Entity.Task();
            tsk.BudgetHours = textBox2.Text;
            tsk.TaskName    = textBox1.Text;
            tsk.StartDate   = DateFormat_UK(textBox4.Text);
            tsk.EndDate     = (String.IsNullOrEmpty(textBox5.Text) ? null : DateFormat_UK(textBox5.Text));
            tsk.ActualHours = "0";

            TaskCategory tc = (TaskCategory)cbxCategories.SelectedItem;

            tsk.CategoryId = tc.CategoryId;
            AppendTask(tsk);
            _isNewTask = true;

            //Once task is appended, clear the text boxes
            textBox1.Clear();
            textBox2.Clear();
            textBox4.Clear();
            textBox5.Clear();

            //Get the list of all tasks
            GetAllTasks();
            dataGridView1.DataSource = _tasks;
            //refresh the data so you can see the new task
            dataGridView1.Refresh();
        }
Пример #2
0
        public SsOpsDatabaseLibrary.Entity.Task[] GetSelectedTasks()
        {
            SsOpsDatabaseLibrary.Entity.Task[] outTsks = new SsOpsDatabaseLibrary.Entity.Task[listBox1.SelectedItems.Count];
            listBox1.SelectedItems.CopyTo(outTsks, 0);

            if (_canceled)
            {
                return(null);
            }
            return(outTsks);
        }
Пример #3
0
        private void AppendTask(SsOpsDatabaseLibrary.Entity.Task newtask)
        {
            try {
                //Assert wait cursor
                Application.UseWaitCursor = true;

                using (OpsDatabaseAdapter dbLib = new OpsDatabaseAdapter()) {
                    // Call OpsDataReader to get the details for the selected week
                    int x = dbLib.CreateTask(newtask);
                }
            }
            catch (Exception ex) {
                Application.UseWaitCursor = false;
                string errHead = GetType().Name + "  " + System.Reflection.MethodBase.GetCurrentMethod().Name + "() failed. \n\n";
                MessageBox.Show(errHead + "Source: " + ex.Source + "\n\n" + ex.Message, ProductName + " " + ProductVersion, MessageBoxButtons.OK);
                Application.Exit();
            }
            finally {
                //Deny the wait cursor
                Application.UseWaitCursor = false;
            }
        }