Ejemplo n.º 1
0
        // default constructor
        // loads the Project List
        public ExportProject()
        {
            InitializeComponent();

            projectList = ORM.GetProjects();

            List <string> projectNameList = new List <string>();

            foreach (Project p in projectList)
            {
                projectNameList.Add(p.ProjectName);
            }

            pickerExportProject.ItemsSource = projectNameList;
        }
Ejemplo n.º 2
0
        // Export Project button event
        //  - checks the local database for Projects before navigation
        //  - loads the ExportProject Page
        public async void ExportProject_OnClick(object sender, EventArgs e)
        {
            try
            {
                List <Project> projectList = ORM.GetProjects();

                if (projectList.Count > 0)
                {
                    await Navigation.PushAsync(new ExportProject());
                }
                else
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert("No projects to export!");
                }
            }
            catch (Exception ex)
            {
                DependencyService.Get <ICrossPlatformToast>().ShortAlert("No projects to export!");
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 3
0
        // Collect button event
        //  - loads a list of Projects for the user to choose to collect under
        //  - upon user choosing, loads the Collecting Page
        public async void Collect_OnClick(object sender, EventArgs e)
        {
            try
            {
                List <Project> projectList = ORM.GetProjects();

                string[] projects = new string[projectList.Count + 1];
                for (int i = 0; i < projects.Length - 1; i++)
                {
                    projects[i] = projectList[i].ProjectName;
                }

                // default 'today' project
                Project todayProject = new Project
                {
                    ProjectName      = string.Format("Project-{0}", DateTime.Now.ToString("MM-dd-yyyy")),
                    PrimaryCollector = (AppVariables.CollectorName is null) ? "" : AppVariables.CollectorName,
                    CreatedDate      = DateTime.Now
                };

                bool dayPExists = false;

                foreach (var p in projectList)
                {
                    if (p.ProjectName.Equals(todayProject.ProjectName))
                    {
                        dayPExists = true;
                        break;
                    }
                }

                if (!dayPExists)
                {
                    projectList.Add(todayProject);

                    projects[projects.Length - 1] = string.Format("Project-{0}", DateTime.Now.ToString("MM-dd-yyyy"));
                }
                else
                {
                    projects = (from p in projectList
                                select p.ProjectName).ToArray();
                }

                var action = await DisplayActionSheet("Choose a project", "Cancel", null, projects);

                foreach (Project p in projectList)
                {
                    if (p.ProjectName.Equals(action))
                    {
                        if (action.Equals(string.Format("Project-{0}", DateTime.Now.ToString("MM-dd-yyyy"))))
                        { // add today project to database if it is selected
                            if (!ORM.CheckExists(p))
                            {
                                int autoKeyResult = ORM.InsertObject(p);
                                await Navigation.PushAsync(new CollectingPage(p));

                                break;
                            }
                            else
                            {
                                await Navigation.PushAsync(new CollectingPage(p));

                                break;
                            }
                        }
                        else
                        {
                            await Navigation.PushAsync(new CollectingPage(p));

                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                DependencyService.Get <ICrossPlatformToast>().ShortAlert("Can't start collecting until you've created a project!");
            }
        }