예제 #1
0
 /// <summary>
 /// Proje Ekleme İşlemini Gerçekleştiren Metod
 /// </summary>
 public void SaveProject()
 {
     DatabaseHelper.SaveProject(ProjectGetAll);
     MessageBox.Show("Added..");
     addProjectView.Close();
 }
예제 #2
0
        /// <summary>
        /// method for saving the data to the database
        /// </summary>
        private void SaveExecute()
        {
            try
            {
                using (CompanyDBEntities context = new CompanyDBEntities())
                {
                    tblProject newProject = new tblProject();

                    // inputs and validations
                    newProject.ProjectName        = project.ProjectName;
                    newProject.ProjectDescription = project.ProjectDescription;

                    if (project.ClientName.All(Char.IsLetter))
                    {
                        newProject.ClientName = project.ClientName;
                    }
                    else
                    {
                        MessageBox.Show("Wrong Client Name input, please try again.");
                    }

                    newProject.ContractDate = DateTime.Now;

                    if (project.ContractManager.All(Char.IsLetter))
                    {
                        newProject.ContractManager = project.ContractManager;
                    }
                    else
                    {
                        MessageBox.Show("Wrong Contract Manager input, please try again.");
                    }

                    newProject.ProjectStartDate = DateTime.Now.AddDays(7);
                    newProject.ProjectDeadline  = DateTime.Now.AddDays(30);

                    newProject.HourlyRate = project.HourlyRate;

                    string a = project.Realisation;

                    if (a == "1" || a == "2" || a == "0")
                    {
                        newProject.Realisation = project.Realisation;
                    }
                    else
                    {
                        MessageBox.Show("Wrong Realisation input, please try again. \n(0/1/2)");
                    }

                    // getting the ManagerID for the project
                    tblManager viaManager = (from x in context.tblManagers where x.ManagerID == manager.ManagerID select x).FirstOrDefault();
                    newProject.ManagerID = viaManager.ManagerID;
                    newProject.ProjectID = project.ProjectID;

                    // saving data
                    context.tblProjects.Add(newProject);
                    context.SaveChanges();

                    MessageBox.Show("The project created successfully.");

                    // logging action
                    FileActions.FileActions.Instance.Adding(FileActions.FileActions.path, FileActions.FileActions.actions, "project", newProject.ProjectName);

                    // updating the project list view
                    IsUpdateProject = true;
                }
                addProject.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong inputs. Please try again.");
            }
        }