/// <summary>
 /// Handles the Load event of the Form control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="eventArgs">The <see cref="EventArgs" /> instance containing the event data.</param>
 private void Form_Load(object sender, EventArgs eventArgs)
 {
     if (this.IsEditForm)
     {
         this.taskType = DataAccess.Instance.TaskTypes.Single(x => x.Id == this.ItemToEditID);
         this.Form.NameTextBox.Text = this.taskType.Name;
         this.Form.DescriptionRichTextBox.Text = this.taskType.Description;
         this.Form.Text = "Edycja typu zadania";
     }
     else
     {
         this.Form.Text = "Nowy typ zadania";
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the TaskTypes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTaskTypes(TaskType taskType)
 {
     base.AddObject("TaskTypes", taskType);
 }
 /// <summary>
 /// Create a new TaskType object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static TaskType CreateTaskType(global::System.Int32 id, global::System.String name)
 {
     TaskType taskType = new TaskType();
     taskType.Id = id;
     taskType.Name = name;
     return taskType;
 }
        /// <summary>
        /// Handles the Click event of the OkButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void OkButton_Click(object sender, EventArgs e)
        {
            string taskTypeName = this.Form.NameTextBox.Text;
            string taskTypeDescription = this.Form.DescriptionRichTextBox.Text;
            if (string.IsNullOrEmpty(taskTypeName) || string.IsNullOrEmpty(taskTypeDescription))
            {
                MessageBox.Show(
                    "Podane wartości nie są prawidłowe lub pozostawiono niewypełnione pola.",
                    "Błąd",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1);

                return;
            }

            if (this.IsEditForm)
            {
                this.taskType.Name = taskTypeName;
                this.taskType.Description = taskTypeDescription;
            }
            else
            {
                this.taskType = new TaskType
                {
                    Name = taskTypeName,
                    Description = taskTypeDescription
                };

                DataAccess.Instance.TaskTypes.Add(this.taskType);
            }

            DataAccess.Instance.UnitOfWork.Commit();

            this.Form.Dispose();
        }