Exemplo n.º 1
0
        /// <summary>
        /// Funtion that asks for a new sample name and adds it to the database.
        /// </summary>
        /// <returns>The SampleID of the sample added to the database.</returns>
        public static int? AddNewSample()
        {
            Views.Utils.InputDialog inputDialog = new Views.Utils.InputDialog("Enter new sample name:", "");
            if (inputDialog.ShowDialog() == true)
            {
                if (inputDialog.Answer == "") return null;

                return AddNewSample(inputDialog.Answer);
            }
            else
                return null;
        }
        /// <summary>
        /// Function that renames the selected <see cref="Project"/>.
        /// </summary>
        public void _RenameProjectCommand()
        {
            if (SelectedProject == null) return;

            Views.Utils.InputDialog inputDialog = new Views.Utils.InputDialog("Enter new project name:", SelectedProject.ProjectName);
            if (inputDialog.ShowDialog() == true)
                if (inputDialog.Answer != "")
                {
                    using (DatabaseDataContext Database = MyGlobals.Database)
                    {
                        Project renamedProject = Database.Projects.FirstOrDefault(x => x.ProjectID == SelectedProject.ProjectID);
                        string OldName = renamedProject.ProjectName;
                        renamedProject.ProjectName = inputDialog.Answer;
                        Database.SubmitChanges();

                        trace.Value.TraceEvent(TraceEventType.Information, 0, "Project '" + OldName + "' renamed to '" + renamedProject.ProjectName + "'");
                    }

                    Projects.FirstOrDefault(x => x.ProjectID == SelectedProject.ProjectID).ProjectName = inputDialog.Answer;
                }
        }
        /// <summary>
        /// Function that adds a new <see cref="Project"/> to the <see cref="Projects"/> list.
        /// </summary>
        public void _NewProjectCommand()
        {
            Views.Utils.InputDialog inputDialog = new Views.Utils.InputDialog("Enter new project name:", "");
            if (inputDialog.ShowDialog() == true)
                if (inputDialog.Answer != "")
                    using (DatabaseDataContext Database = MyGlobals.Database)
                    {
                        Project newProject = new Project { ProjectName = inputDialog.Answer };
                        Database.Projects.InsertOnSubmit(newProject);
                        Database.SubmitChanges();
                        Projects.Add(newProject);

                        trace.Value.TraceEvent(TraceEventType.Information, 0, "Created new project: '" + newProject.ProjectName + "'");
                    }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Function that renames the selected <see cref="Material"/>.
 /// </summary>
 public void _RenameMaterialCommand()
 {
     Views.Utils.InputDialog inputDialog = new Views.Utils.InputDialog("Enter new material name:", SelectedMaterial.MaterialName);
     if (inputDialog.ShowDialog() == true)
         SelectedMaterial.MaterialName = inputDialog.Answer;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Function that adds a new <see cref="Material"/>.
        /// </summary>
        public void _AddMaterialCommand()
        {
            Views.Utils.InputDialog inputDialog = new Views.Utils.InputDialog("Enter new material name:", "new Material");
            if (inputDialog.ShowDialog() == true)
            {
                Material newMaterial = new Material { MaterialName = inputDialog.Answer };

                Database.Materials.InsertOnSubmit(newMaterial);

                Materials.Add(newMaterial);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Function that renames the selected <see cref="Sample"/>.
 /// </summary>
 public void _RenameSampleCommand()
 {
     Views.Utils.InputDialog inputDialog = new Views.Utils.InputDialog("Enter new sample name:", SelectedSample.SampleName);
     if (inputDialog.ShowDialog() == true)
     {
         Database.Samples.FirstOrDefault(x => x.SampleID == SelectedSample.SampleID).SampleName = inputDialog.Answer;
     }
 }