示例#1
0
 private void AddSiteLink_OnClick()
 {
     // Make sure the Survey has admin levels
     if (Survey == null || Survey.AdminLevels == null)
         return;
     // Show the modal for adding sites
     SentinelSiteAdd modal = new SentinelSiteAdd(Survey.AdminLevels);
     modal.OnSave += sites_OnAdd;
     modal.ShowDialog();
 }
示例#2
0
 private void AddSentinelSite(ListBox cntrl, Indicator indicator, IndicatorEntityType entityType)
 {
     SentinelSiteAdd form = new SentinelSiteAdd(options.AdminLevels);
     form.OnSave += (v) =>
     {
         cntrl.Items.Add(v);
     };
     form.ShowDialog();
 }
 private void AddSentinelSite(ComboBox cntrl, KeyValuePair<string, SurveyUnitsAndSentinelSite> survey)
 {
     SentinelSiteAdd form = new SentinelSiteAdd(survey.Value.Units);
     form.OnSave += (v) =>
     {
         cntrl.Items.Add(v);
     };
     form.ShowDialog();
 }
示例#4
0
        private void sentinelSiteListView_HyperlinkClicked(object sender, BrightIdeasSoftware.HyperlinkClickedEventArgs e)
        {
            e.Handled = true;
            if (e.Column.AspectName == "EditText")
            {
                SentinelSiteAdd modal = new SentinelSiteAdd((SentinelSite) e.Model);
                modal.OnSave += sites_OnEdit;
                modal.ShowDialog();
            }
            else if (e.Column.AspectName == "DeleteText")
            {
                // The site to delete
                SentinelSite siteToDelete = (SentinelSite) e.Model;

                // Check if the site has associated data
                if (SurveyRepo.GetSiteSurveyCount(siteToDelete) > 0)
                {
                    // The site has associated data, so display a message
                    MessageBox.Show(Translations.CannotDeleteSentinelSiteHasData, Translations.CannotDeleteSite);
                    return;
                }

                // Confirm the delete with the user
                DeleteConfirm confirm = new DeleteConfirm();
                if (confirm.ShowDialog() == DialogResult.OK)
                {
                    // The site has no associated data, so it is safe to delete
                    SurveyRepo.DeleteSite(siteToDelete, ApplicationData.Instance.GetUserId());
                    // Get the index of the site in the collection
                    int currentIndex = SentinelSites.IndexOf(siteToDelete);
                    // Remove the deleted site from the collection
                    if (currentIndex >= 0)
                        SentinelSites.RemoveAt(currentIndex);
                    // Update the list
                    UpdateSiteList(null);
                }
            }
        }