예제 #1
0
 protected void DDListSortMethod_SelectedIndexChanged(object sender, EventArgs e)
 {
     PanelPublicationInfo.Visible    = false;
     PanelEditDelete.Visible         = false;
     GridViewPublications.DataSource = PublicationsDAL.GetPublications($"SELECT * FROM publications ORDER BY {DDListSortMethod.SelectedValue}");
     GridViewPublications.DataBind();
 }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GridViewAuthors.PageSize = int.Parse(DDListNumberResults.SelectedValue);
     if (!IsPostBack) //only at the beginning
     {
         PublicationsDAL.AuthorsAll = PublicationsDAL.GetAuthors();
     }
     GridViewAuthors.DataSource = PublicationsDAL.AuthorsAll;
     GridViewAuthors.DataBind();
     PanelChangeName.Visible = false;
 }
예제 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GridViewPublications.PageSize = int.Parse(DDListNumberResults.SelectedValue);
     if (!IsPostBack) //only at the beginning
     {
         PublicationsDAL.PublicationsAll = PublicationsDAL.GetPublications($"SELECT * FROM publications ORDER BY {DDListSortMethod.SelectedValue}");
     }
     GridViewPublications.DataSource = PublicationsDAL.PublicationsAll;
     GridViewPublications.DataBind();
     PanelFields.Visible = false;
 }
예제 #4
0
    private void ShowPublications(Author author)
    {
        List <Publication> publications = PublicationsDAL.GetPublications($"SELECT * FROM publications WHERE idauthors LIKE '%;{author.Id};%' ORDER BY {order}");

        TextBoxPublications.Text = $"Publikacje autora {author.Autor}:\n";
        int index = 0;

        foreach (var publication in publications)
        {
            if (publication.Tytul != "")
            {
                TextBoxPublications.Text += $"{++index}. \"{publication.Tytul}\"\n";
            }
        }
    }
예제 #5
0
 protected void ButtonDeletePublication_Click(object sender, EventArgs e)
 {
     PublicationsDAL.DeletePublication(selectedPublication.PairsFieldValue["tag"]);
     Find();
     GridViewResults.SelectedIndex = 0;
     foreach (var publication in PublicationsDAL.PublicationsAll)
     {
         if (publication.Klucz == (string)GridViewResults.SelectedValue)
         {
             selectedPublication = new Publication(publication.PairsFieldValue);
             ShowInfo(selectedPublication);
             break;
         }
     }
     Response.Write("<script>alert('Publikacja została usunięta')</script>");
 }
예제 #6
0
 protected void ButtonDelete_Click(object sender, EventArgs e)
 {
     PublicationsDAL.DeletePublication(selectedPublication.PairsFieldValue["tag"]);
     GridViewPublications.DataSource = PublicationsDAL.PublicationsAll = PublicationsDAL.GetPublications($"SELECT * FROM publications " +
                                                                                                         $"ORDER BY {DDListSortMethod.SelectedValue}");
     GridViewPublications.DataBind();
     GridViewPublications.SelectedIndex = 0;
     foreach (var publication in PublicationsDAL.PublicationsAll)
     {
         if (publication.Klucz == (string)GridViewPublications.SelectedValue)
         {
             selectedPublication = new Publication(publication.PairsFieldValue);
             ShowInfo(selectedPublication);
             break;
         }
     }
     Response.Write("<script>alert('Publikacja została usunięta')</script>");
 }
예제 #7
0
 protected void ButtonSaveName_Click(object sender, EventArgs e)
 {
     if (selectedAuthor.Id != 0 && TextBoxName.Text != selectedAuthor.Autor) //if something has changed
     {
         PublicationsDAL.UpdateAuthor(selectedAuthor.Id, TextBoxName.Text);
         //update view
         GridViewResults.DataSource = PublicationsDAL.AuthorsAll = PublicationsDAL.GetAuthors();
         GridViewResults.DataBind();
         foreach (var author in PublicationsDAL.AuthorsAll)
         {
             if (author.Id == (int)GridViewResults.SelectedValue)
             {
                 selectedAuthor = new Author(author.Id, author.Autor);
                 ShowPublications(selectedAuthor);
                 break;
             }
         }
         Response.Write("<script>alert('Imię i nazwisko autora zaktualizowane')</script>");
     }
 }
예제 #8
0
    protected void ButtonExportBibtexAuthor_Click(object sender, EventArgs e)
    {
        const int max      = 100;
        int       index    = 0;
        string    output   = "";
        string    fileName = "bibtex_author_";

        if (selectedAuthor.Id != 0)
        {
            List <Publication> publications = PublicationsDAL.GetPublications($"SELECT * FROM publications WHERE idauthors LIKE '%;{selectedAuthor.Id};%' ORDER BY title");
            foreach (var publication in publications)
            {
                ++index;
                output += $"{publication.GetBibtex()}\n\n\n";
                if (index == max)
                {
                    break;
                }
            }
            string name = "";
            foreach (char ch in selectedAuthor.Autor)
            {
                if (char.IsWhiteSpace(ch))
                {
                    name += "-";
                }
                else
                {
                    name += ch;
                }
            }
            fileName += name;
        }
        Response.Clear();
        Response.AppendHeader("Content-Length", output.Length.ToString());
        Response.ContentType = "text/plain";
        Response.AppendHeader("content-disposition", $"attachment; filename={fileName}.bib");
        Response.Flush();
        Response.Write(output);
        Response.End();
    }
예제 #9
0
 protected void ButtonSavePublication_Click(object sender, EventArgs e)
 {
     if (searchedTable == "publications")
     {
         Dictionary <string, string> changes = GetChanges(selectedPublication);
         if (changes.Count != 0)
         {
             PublicationsDAL.UpdatePublication(selectedPublication.PairsFieldValue["tag"], changes);
             Find();
             foreach (var publication in PublicationsSearched)
             {
                 if (publication.Klucz == (string)GridViewResults.SelectedValue)
                 {
                     selectedPublication = new Publication(publication.PairsFieldValue);
                     ShowInfo(selectedPublication);
                     break;
                 }
             }
             Response.Write("<script>alert('Publikacja zaktualizowana')</script>");
         }
     }
 }
예제 #10
0
    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        Dictionary <string, string> changes = GetChanges(selectedPublication);

        if (changes.Count != 0)
        {
            PublicationsDAL.UpdatePublication(selectedPublication.PairsFieldValue["tag"], changes);
            //update view
            GridViewPublications.DataSource = PublicationsDAL.PublicationsAll = PublicationsDAL.GetPublications($"SELECT * FROM publications " +
                                                                                                                $"ORDER BY {DDListSortMethod.SelectedValue}");
            GridViewPublications.DataBind();
            foreach (var publication in PublicationsDAL.PublicationsAll)
            {
                if (publication.Klucz == (string)GridViewPublications.SelectedValue)
                {
                    selectedPublication = new Publication(publication.PairsFieldValue);
                    ShowInfo(selectedPublication);
                    break;
                }
            }
            Response.Write("<script>alert('Publikacja zaktualizowana')</script>");
        }
    }
예제 #11
0
    private void Find()
    {
        searchPhrase = TextBoxSearch.Text;
        GridViewResults.EmptyDataText = "Przykro mi, nie znaleziono pasujących wyników.";
        GridViewResults.PageIndex     = 0;
        GridViewResults.SelectedIndex = -1;
        searchedTable = DDListTable.SelectedValue;
        PanelPublicationInfo.Visible = false;
        PanelPublications.Visible    = false;
        ButtonExportBibtex.Visible   = false;
        PanelEditDelete.Visible      = false;
        PanelEdit.Visible            = false;
        int    numberResults = 0;
        string word          = "";

        listWords.Clear();
        foreach (char ch in searchPhrase)
        {
            if (!char.IsWhiteSpace(ch))
            {
                word += ch;
            }
            else
            {
                if (word != " ")
                {
                    listWords.Add(word);
                }
                word = "";
            }
        }
        if (word != "")
        {
            listWords.Add(word);
        }
        if (searchedTable == "publications")
        {
            GridViewResults.DataKeyNames = new string[] { "Klucz" };
            PublicationsSearched         = PublicationsDAL.GetPublications(listWords, order);
            GridViewResults.DataSource   = PublicationsSearched;
            if (PublicationsSearched.Count != 0)
            {
                ButtonExportBibtex.Visible = true;
            }
            numberResults = PublicationsSearched.Count;
            if (numberResults > 100)
            {
                LabelExportBibtex.Visible = true;
            }
            else
            {
                LabelExportBibtex.Visible = false;
            }
        }
        else
        {
            GridViewResults.DataKeyNames = new string[] { "Id" };
            AuthorsSearched            = PublicationsDAL.GetAuthors(listWords);
            GridViewResults.DataSource = AuthorsSearched;
            numberResults             = AuthorsSearched.Count;
            LabelExportBibtex.Visible = false;
        }
        GridViewResults.DataBind();
        LabelResults.Text = $"Wyniki wyszukiwania dla: <strong>{searchPhrase}</strong><br/>Znaleziono <strong>{numberResults}</strong> pasujących wyników.";
    }
예제 #12
0
    protected void ButtonAdd_Click(object sender, EventArgs e)
    {
        string missingString = CheckRequiredFields();

        if (missingString != "")
        {
            Response.Write("<script>alert('" + missingString + "')</script>");
            return;
        }
        Dictionary <string, string> pairs = new Dictionary <string, string>();

        pairs.Add("type", ListBoxType.SelectedValue);
        if (TextBoxTitle.Text != "")
        {
            pairs.Add("title", TextBoxTitle.Text);
        }
        if (TextBoxBooktitle.Text != "")
        {
            pairs.Add("booktitle", TextBoxBooktitle.Text);
        }
        if (TextBoxAuthor.Text != "")
        {
            pairs.Add("author", TextBoxAuthor.Text);
        }
        if (TextBoxSchool.Text != "")
        {
            pairs.Add("school", TextBoxSchool.Text);
        }
        if (TextBoxEditor.Text != "")
        {
            pairs.Add("editor", TextBoxEditor.Text);
        }
        if (TextBoxYear.Text != "")
        {
            pairs.Add("year", TextBoxYear.Text);
        }
        if (TextBoxMonth.Text != "")
        {
            pairs.Add("month", TextBoxMonth.Text);
        }
        if (TextBoxChapter.Text != "")
        {
            pairs.Add("chapter", TextBoxChapter.Text);
        }
        if (TextBoxPages.Text != "")
        {
            pairs.Add("pages", TextBoxPages.Text);
        }
        if (TextBoxEdition.Text != "")
        {
            pairs.Add("edition", TextBoxEdition.Text);
        }
        if (TextBoxHowpublished.Text != "")
        {
            pairs.Add("howpublished", TextBoxHowpublished.Text);
        }
        if (TextBoxInstitution.Text != "")
        {
            pairs.Add("institution", TextBoxInstitution.Text);
        }
        if (TextBoxJournal.Text != "")
        {
            pairs.Add("journal", TextBoxJournal.Text);
        }
        if (TextBoxOrganization.Text != "")
        {
            pairs.Add("organization", TextBoxOrganization.Text);
        }
        if (TextBoxPublisher.Text != "")
        {
            pairs.Add("publisher", TextBoxPublisher.Text);
        }
        if (TextBoxAddress.Text != "")
        {
            pairs.Add("address", TextBoxAddress.Text);
        }
        if (TextBoxSeries.Text != "")
        {
            pairs.Add("series", TextBoxSeries.Text);
        }
        if (TextBoxNumber.Text != "")
        {
            pairs.Add("number", TextBoxNumber.Text);
        }
        if (TextBoxVolume.Text != "")
        {
            pairs.Add("volume", TextBoxVolume.Text);
        }
        if (TextBoxNote.Text != "")
        {
            pairs.Add("note", TextBoxNote.Text);
        }
        PublicationsDAL.AddPublication(new Publication(pairs));
        ClearAllTextBoxes();
        Response.Write("<script>alert('Dodawanie nowej publikacji powiodło się')</script>");
    }