Ejemplo n.º 1
0
 /// <summary>
 /// Attempts to attach a Project_File Entity to Project_Files EntitySet
 /// </summary>
 /// <param name="theFile">Project_File Entity to be attached</param>
 /// <returns>true upon success, false upon failure</returns>
 public bool AddFile(Project_File theFile)
 {
     try
     {
         Project_Files.InsertOnSubmit(theFile);
         SubmitChanges();
         return true;
     }
     catch
     {
         // Karol: 19.12.2012, add proper handling.
         return false;
     }
 }
        /// <summary>
        /// Responsible for adding the entered file to the Database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            if (Data.DoesFileExist(myProject, fileNameTextBox.Text))
            {
                MessageBox.Show("The file is already added to the project.", "KChange: Error");
                return;
            }

            Project_File newProjectFile = new Project_File();
            newProjectFile.File_Name = fileNameTextBox.Text;
            newProjectFile.File_Path = filePathTextBox.Text;
            newProjectFile.Project = myProject;

            if(!Data.AddFile(newProjectFile))
            {
                MessageBox.Show("Error upon adding!", "KChange: Error");
                return;
            }

            this.Close();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Attemps to remove a Project_File entity from the Project_Files EntitySet
 /// </summary>
 /// <param name="theFile">The Project_File Entity to be removed</param>
 /// <returns>true upon success, false upon failure</returns>
 public bool RemoveFile(Project_File theFile)
 {
     try
     {
         Project_Files.DeleteOnSubmit(theFile);
         SubmitChanges();
         return true;
     }
     catch (Exception ex)
     {
         //TODO: Add proper event handling
         return false;
     }
 }
 partial void DeleteProject_File(Project_File instance);
 partial void UpdateProject_File(Project_File instance);
 partial void InsertProject_File(Project_File instance);
		private void detach_Project_Files(Project_File entity)
		{
			this.SendPropertyChanging();
			entity.Project = null;
		}
		private void attach_Project_Files(Project_File entity)
		{
			this.SendPropertyChanging();
			entity.Project = this;
		}