Exemple #1
0
        private void cmsAddSurvey_Click(object sender, EventArgs e)
        {
            string surveyTitle = Interaction.InputBox("Create new survey", "New Survey", "New Survey", 300, 300);

            if (!G.glb.lstSurvey.Exists(o => o.SurveyTitle == surveyTitle))
            {
                CSurvey survey = new CSurvey();
                survey.SurveyTitle = surveyTitle;
                G.glb.lstSurvey.Add(survey);
                lsbSurvey.Items.Clear();
                foreach (CSurvey sur in G.glb.lstSurvey)
                {
                    lsbSurvey.Items.Add(sur.SurveyTitle);
                }
            }
            else
            {
                MessageBox.Show("Survey exists!");
            }
            LoadTrvTag();
        }
Exemple #2
0
 private void GetSurvey(string strSurvey)
 {
     // 如果文献标题可编辑,先暂存到缓存区,否则直接操作存储区
     if (txtTitle.Enabled == true)
     {
         if (!lstSurveyLiterature.Exists(o => o.SurveyTitle == strSurvey))
         {
             RSurveyLiterature newSurveyLiterature = new RSurveyLiterature();
             newSurveyLiterature.SurveyTitle = strSurvey;
             lstSurveyLiterature.Add(newSurveyLiterature);
             lsbSurvey.Items.Add(strSurvey);
         }
         else
         {
             MessageBox.Show("Already included in survey");
         }
     }
     else
     {
         if (!G.glb.lstSurvey.Exists(o => o.SurveyTitle == strSurvey))
         {
             CSurvey survey = new CSurvey();
             survey.SurveyTitle = strSurvey;
             G.glb.lstSurvey.Add(survey);
         }
         if (!G.glb.lstSurveyLiterature.Exists(o => o.LiteratureTitle == txtTitle.Text && o.SurveyTitle == strSurvey))
         {
             RSurveyLiterature newSurveyLiterature = new RSurveyLiterature();
             newSurveyLiterature.LiteratureTitle = txtTitle.Text;
             newSurveyLiterature.SurveyTitle     = strSurvey;
             G.glb.lstSurveyLiterature.Add(newSurveyLiterature);
             lsbSurvey.Items.Add(strSurvey);
         }
         else
         {
             MessageBox.Show("Already included in survey");
         }
     }
 }
Exemple #3
0
        private void frmAddLiterature_FormClosing(object sender, FormClosingEventArgs e)
        {
            bool CanSaveFlag       = true;
            bool EntirelyEmptyFlag = true;

            if (modifiedFlag)
            {
                if (txtTitle.Text == "")
                {
                    MessageBox.Show("Title is missing.");
                    CanSaveFlag = false;
                }
                else
                {
                    EntirelyEmptyFlag = false;
                }
                if (G.glb.lstLiterature.Exists(o => o.Title == txtTitle.Text) && txtTitle.Enabled == true)
                {
                    MessageBox.Show("Literature exists.");
                    CanSaveFlag = false;
                }
                if (G.glb.lstLiterature.Exists(o => o.BibKey != "" && o.BibKey == txtBibKey.Text && o.Title != txtTitle.Text))
                {
                    MessageBox.Show("Bibkey exists.");
                    CanSaveFlag = false;
                }
                if (txtYear.Text == "")
                {
                    MessageBox.Show("Publish year is missing");
                    CanSaveFlag = false;
                }
                else
                {
                    EntirelyEmptyFlag = false;
                }
                if (txtJournalConference.Text == "")
                {
                    MessageBox.Show("Journal/Conference Name is missing");
                    CanSaveFlag = false;
                }
                else
                {
                    EntirelyEmptyFlag = false;
                }
                if (lsbAuthor.Items.Count == 0)
                {
                    MessageBox.Show("Add author");
                    CanSaveFlag = false;
                }
                else
                {
                    EntirelyEmptyFlag = false;
                }
                if (lsbTag.Items.Count == 0)
                {
                    MessageBox.Show("Add tag");
                    CanSaveFlag = false;
                }
                else
                {
                    EntirelyEmptyFlag = false;
                }
                if (lsbInstitution.Items.Count == 0)
                {
                    MessageBox.Show("Add institution");
                    CanSaveFlag = false;
                }
                else
                {
                    EntirelyEmptyFlag = false;
                }
                if (CanSaveFlag)
                {
                    // 如果本来没有这篇文献,说明是新增文献,否则是删改文献
                    if (!G.glb.lstLiterature.Exists(o => o.Title == txtTitle.Text))
                    {
                        CLiterature newLiterature = new CLiterature();
                        newLiterature.Title                   = txtTitle.Text;
                        newLiterature.PublishYear             = Convert.ToInt32(txtYear.Text);
                        newLiterature.JournalOrConferenceName = txtJournalConference.Text;
                        newLiterature.InOneSentence           = txtInOneSentence.Text;
                        newLiterature.BibKey                  = txtBibKey.Text;
                        newLiterature.BibTeX                  = literatureBib;
                        newLiterature.DateAdded               = DateTime.Today;
                        newLiterature.DateModified            = DateTime.Today;
                        newLiterature.Star           = chkStar.Checked;
                        newLiterature.PredatoryAlert = chkPredatroyAlert.Checked;

                        foreach (RLiteratureAuthor author in lstLiteratureAuthor)
                        {
                            author.Title = txtTitle.Text;
                        }
                        foreach (RLiteratureOutSource outSource in lstLiteratureOutsource)
                        {
                            outSource.Title = txtTitle.Text;
                        }
                        foreach (RLiteratureTag tag in lstLiteratureTag)
                        {
                            tag.Title = txtTitle.Text;
                        }
                        foreach (RLiteratureInstitution institution in lstLiteratureInstitution)
                        {
                            institution.Title = txtTitle.Text;
                        }
                        foreach (RLiteratureInCiting inCiting in lstLiteratureInCiting)
                        {
                            inCiting.Title = txtTitle.Text;
                        }
                        foreach (RSurveyLiterature surveyLiterature in lstSurveyLiterature)
                        {
                            surveyLiterature.LiteratureTitle = txtTitle.Text;
                            if (!G.glb.lstSurvey.Exists(o => o.SurveyTitle == surveyLiterature.SurveyTitle))
                            {
                                CSurvey survey = new CSurvey();
                                survey.SurveyTitle = surveyLiterature.SurveyTitle;
                                G.glb.lstSurvey.Add(survey);
                            }
                        }
                        G.glb.lstLiterature.Add(newLiterature);
                        G.glb.lstLiteratureTag.AddRange(lstLiteratureTag);
                        G.glb.lstLiteratureAuthor.AddRange(lstLiteratureAuthor);
                        G.glb.lstLiteratureOutSource.AddRange(lstLiteratureOutsource);
                        G.glb.lstLiteratureInstitution.AddRange(lstLiteratureInstitution);
                        G.glb.lstLiteratureCiting.AddRange(lstLiteratureInCiting);
                        G.glb.lstSurveyLiterature.AddRange(lstSurveyLiterature);
                    }
                    else
                    {
                        G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).PublishYear             = Convert.ToInt32(txtYear.Text);
                        G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).JournalOrConferenceName = txtJournalConference.Text;
                        G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).InOneSentence           = txtInOneSentence.Text;
                        G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).BibKey         = txtBibKey.Text;
                        G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).BibTeX         = literatureBib;
                        G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).DateModified   = DateTime.Today;
                        G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).Star           = chkStar.Checked;
                        G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).PredatoryAlert = chkPredatroyAlert.Checked;
                        foreach (RLiteratureAuthor author in lstLiteratureAuthor)
                        {
                            author.Title = txtTitle.Text;
                        }
                        foreach (RLiteratureTag tag in lstLiteratureTag)
                        {
                            tag.Title = txtTitle.Text;
                        }
                        foreach (RLiteratureOutSource outSource in lstLiteratureOutsource)
                        {
                            outSource.Title = txtTitle.Text;
                        }
                        foreach (RLiteratureInstitution institution in lstLiteratureInstitution)
                        {
                            institution.Title = txtTitle.Text;
                        }
                        foreach (RLiteratureInCiting inCiting in lstLiteratureInCiting)
                        {
                            inCiting.Title = txtTitle.Text;
                        }
                        G.glb.lstLiteratureAuthor.RemoveAll(o => o.Title == txtTitle.Text);
                        G.glb.lstLiteratureTag.RemoveAll(o => o.Title == txtTitle.Text);
                        G.glb.lstLiteratureOutSource.RemoveAll(o => o.Title == txtTitle.Text);
                        G.glb.lstLiteratureInstitution.RemoveAll(o => o.Title == txtTitle.Text);
                        G.glb.lstLiteratureCiting.RemoveAll(o => o.Title == txtTitle.Text);
                        G.glb.lstLiteratureTag.AddRange(lstLiteratureTag);
                        G.glb.lstLiteratureAuthor.AddRange(lstLiteratureAuthor);
                        G.glb.lstLiteratureOutSource.AddRange(lstLiteratureOutsource);
                        G.glb.lstLiteratureInstitution.AddRange(lstLiteratureInstitution);
                        G.glb.lstLiteratureCiting.AddRange(lstLiteratureInCiting);
                    }

                    foreach (object item in lsbAuthor.Items)
                    {
                        if (!G.glb.lstAuthor.Exists(o => o.Author == item.ToString()))
                        {
                            CAuthor author = new CAuthor();
                            author.Author           = item.ToString();
                            author.IsReliable       = false;
                            author.PrimeAffiliation = "";
                            G.glb.lstAuthor.Add(author);
                        }
                    }
                    RefreshTab();
                    Dispose();
                }
                else
                {
                    if (!EntirelyEmptyFlag)
                    {
                        e.Cancel = true;
                    }
                }
            }
        }