Beispiel #1
0
        /// <summary>
        /// Edits av material in database
        /// </summary>
        /// <param name="avMaterial">Information about edited av material</param>
        public static void EditAVMaterial(AVMaterial avMaterial)
        {
            if (avMaterial == null)
            {
                throw new ArgumentNullException();
            }

            DatabaseHelper.Execute("dbo.spAudioVideos_ModifyAV @Id, @Title, @Authors, @KeyWords, @CoverURL, @Price",
                                   avMaterial);
        }
Beispiel #2
0
 public ModifyAVMaterials(AVMaterial av, LibrarianWorkWindow workWindow)
 {
     InitializeComponent();
     this.av                    = av;
     this.workWindow            = workWindow;
     av_title_text_box.Text     = av.Title;
     authors_av_text_box.Text   = av.Authors;
     av_coverUrl_text_box.Text  = av.CoverURL;
     av_key_words_text_box.Text = av.KeyWords;
     av_price_text_box.Text     = Convert.ToString(av.Price);
 }
        /// <summary>
        /// Method for checking out document.
        /// </summary>
        /// <param name="documentId">Id of cheking ount document.</param>
        /// <param name="userId">Id of borrowing patron.</param>
        public static void CheckOutDocument(long documentId, long userId)
        {
            if (!IsAvailable(documentId, userId))
            {
                return;
            }

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("LibraryDB")))
            {
                string date = "";
                string type = GetType(documentId);
                if (type == "Inner")
                {
                    return;
                }
                else if (type == "Book")
                {
                    var    outputDoc = connection.Query <TempBook>("dbo.spBooks_GetAllById @DocumentId", new { DocumentId = documentId }).ToArray();
                    Book[] documents = new Book[outputDoc.Count()];
                    for (int i = 0; i < documents.GetLength(0); i++)
                    {
                        documents[i] = new Book(outputDoc[i].Authors, outputDoc[i].Title, outputDoc[i].Publisher, outputDoc[i].Edition, outputDoc[i].Year, outputDoc[i].IsBestseller, outputDoc[i].KeyWords, outputDoc[i].CoverURL, outputDoc[i].Price);
                    }
                    var patronType = connection.Query <string>("dbo.spUsers_GetType @UserId", new { UserId = userId }).ToList();
                    date = documents[0].EvaluateReturnDate(patronType[0]);
                }
                else if (type == "AV")
                {
                    var          outputDoc = connection.Query <TempAV>("dbo.spAudioVideos_GetAllById @DocumentId", new { DocumentId = documentId }).ToArray();
                    AVMaterial[] documents = new AVMaterial[outputDoc.Count()];
                    for (int i = 0; i < documents.GetLength(0); i++)
                    {
                        documents[i] = new AVMaterial(outputDoc[i].Authors, outputDoc[i].Title, outputDoc[i].KeyWords, outputDoc[i].CoverURL, outputDoc[i].Price);
                    }
                    var patronType = connection.Query <string>("dbo.spUsers_GetType @UserId", new { UserId = userId }).ToList();
                    date = documents[0].EvaluateReturnDate(patronType[0]);
                }
                else if (type == "Journal Article")
                {
                    var       outputDoc = connection.Query <TempJournal>("dbo.spJournals_GetAllById @DocumentId", new { DocumentId = documentId }).ToArray();
                    Journal[] documents = new Journal[outputDoc.Count()];
                    for (int i = 0; i < documents.GetLength(0); i++)
                    {
                        documents[i] = new Journal(outputDoc[i].Authors, outputDoc[i].Title, outputDoc[i].Publisher, outputDoc[i].Issue, outputDoc[i].PublicationDate, outputDoc[i].KeyWords, outputDoc[i].CoverURL, outputDoc[i].Price);
                    }
                    var patronType = connection.Query <string>("dbo.spUsers_GetType @UserId", new { UserId = userId }).ToList();
                    date = documents[0].EvaluateReturnDate(patronType[0]);
                }

                var output = connection.Query <long>("dbo.spCopies_GetAvailableCopies @BookId, @UserId", new { BookId = documentId, UserId = userId }).ToList();
                connection.Execute("dbo.spCopies_takeCopyWithReturningDate @CopyId, @UserId, @ReturningDate", new { CopyId = output[0], UserId = userId, ReturningDate = date });
            }
        }
Beispiel #4
0
        /// <summary>
        /// Adds AV material to database
        /// </summary>
        /// <param name="avMaterial">Information about AV material</param>
        /// <returns>Document id</returns>
        public static long AddAVMaterial(AVMaterial avMaterial)
        {
            if (avMaterial == null)
            {
                throw new ArgumentNullException();
            }

            DatabaseHelper.Execute("dbo.spAudioVideos_AddAV @Title, @Authors, @KeyWords, @CoverURL, @Price, @IsOutstanding",
                                   avMaterial);

            return(GetDocumentId(avMaterial));
        }
 public static AVMaterial[] GetAllAVMaterialsList()
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("LibraryDB")))
     {
         var          output = connection.Query <TempAV>("dbo.spAudioVideos_GetAll").ToArray();
         AVMaterial[] temp   = new AVMaterial[output.Count()];
         for (int i = 0; i < temp.GetLength(0); i++)
         {
             temp[i] = new AVMaterial(output[i].Id, output[i].Authors, output[i].Title, output[i].KeyWords, output[i].CoverURL, output[i].Price);
         }
         return(temp);
     }
 }
Beispiel #6
0
        private void grid_MouseUpForAVMaterial(object sender, MouseButtonEventArgs e)
        {
            AVMaterial AVmaterial = DataGridAV_material.SelectedItem as AVMaterial;

            if (AVmaterial == null)
            {
                return;
            }

            ModifyAVMaterials window = new ModifyAVMaterials(AVmaterial, this);

            window.Owner = this;
            window.Show();
        }
        private void av_add_to_db_Click(object sender, RoutedEventArgs e)
        {
            if (av_title_text_box.Text != null &&
                authors_av_text_box.Text != null &&
                av_room_text_box.Text != null &&
                av_level_text_box.Text != null &&
                av_copy_text_box.Text != null &&
                av_key_words_text_box.Text != null &&
                av_price_text_box.Text != null &&
                av_coverURL_text_box.Text != null)
            {
                AVMaterial av_material  = new AVMaterial(InputFieldsManager.ReturnStringFromTextBox(authors_av_text_box), InputFieldsManager.ReturnStringFromTextBox(av_title_text_box), InputFieldsManager.ReturnStringFromTextBox(av_key_words_text_box), InputFieldsManager.ReturnStringFromTextBox(av_coverURL_text_box), Convert.ToInt32(InputFieldsManager.ReturnStringFromTextBox(av_price_text_box)));
                long       avMaterialId = LibrarianDataManager.AddAVMaterial(av_material);

                Copy copy = new Copy();
                int  n    = Convert.ToInt32(InputFieldsManager.ReturnStringFromTextBox(av_copy_text_box));
                copy.DocumentId = avMaterialId;
                copy.Room       = Convert.ToInt32(InputFieldsManager.ReturnStringFromTextBox(av_room_text_box));
                copy.Level      = Convert.ToInt32(InputFieldsManager.ReturnStringFromTextBox(av_level_text_box));
                LibrarianDataManager.AddCopies(n, copy);

                this.Close();
            }
        }
Beispiel #8
0
 public static void EditAVMaterial(AVMaterial avMaterial)
 {
     HttpHelper.MakePutRequest("librarian/edit_av_material", avMaterial);
 }
Beispiel #9
0
 public static long AddAVMaterial(AVMaterial avMaterial)
 {
     return(HttpHelper.MakePostRequest <long>("librarian/add_av_material", avMaterial));
 }
        /// <summary>
        /// Adds new document to the database.
        /// </summary>
        /// <param name="document">Document, which is going to be added.</param>
        public static void AddDocument(IDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("Invalid document!");
            }
            var type = document.GetType();

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("LibraryDB")))
            {
                if (type == typeof(AVMaterial))
                {
                    AVMaterial temp = document as AVMaterial;
                    connection.Execute("dbo.spAudioVideos_AddAV @Title, @Authors, @KeyWords, @CoverURL, @Price",
                                       new
                    {
                        Title    = temp.Title,
                        Authors  = temp.Authors,
                        KeyWords = temp.KeyWords,
                        CoverURL = temp.CoverURL,
                        Price    = temp.Price
                    });
                }
                else if (type == typeof(Book))
                {
                    Book temp = document as Book;
                    connection.Execute("dbo.spBooks_AddBook @Title, @Authors, @Publisher, @Edition, @Year, @IsBestseller, @KeyWords, @CoverURL, @Price",
                                       new
                    {
                        Title        = temp.Title,
                        Authors      = temp.Authors,
                        Publisher    = temp.Publisher,
                        Edition      = temp.Edition,
                        Year         = temp.Year,
                        IsBestseller = temp.IsBestseller,
                        KeyWords     = temp.KeyWords,
                        CoverURL     = temp.CoverURL,
                        Price        = temp.Price
                    });
                }
                else if (type == typeof(InnerMaterial))
                {
                    InnerMaterial temp = document as InnerMaterial;
                    connection.Execute("dbo.spInnerMaterials_AddInnerMaterial @Title, @Authors, @Type, @Room, @Level, @KeyWords, @CoverURL",
                                       new
                    {
                        Title    = temp.Title,
                        Authors  = temp.Authors,
                        Type     = temp.Type,
                        Room     = temp.Room,
                        Level    = temp.Level,
                        KeyWords = temp.KeyWords,
                        CoverURL = temp.CoverURL
                    });
                }
                else if (type == typeof(Journal))
                {
                    Journal temp = document as Journal;
                    connection.Execute("dbo.spJournals_AddJournal @Title, @Authors, @Publisher, @Issue, @PublicationDate, @KeyWords, @CoverURL, @Price",
                                       new
                    {
                        Title           = temp.Title,
                        Authors         = temp.Authors,
                        Publisher       = temp.Publisher,
                        Issue           = temp.Issue,
                        PublicationDate = temp.PublicationDate,
                        KeyWords        = temp.KeyWords,
                        CoverURL        = temp.CoverURL,
                        Price           = temp.Price
                    });
                }
                else if (type == typeof(Article))
                {
                    Article temp = document as Article;
                    connection.Execute("dbo.spJournalArticles_AddJournalArticle @Title, @Authors, @JournalId, @KeyWords, @CoverURL",
                                       new
                    {
                        Title     = temp.Title,
                        Authors   = temp.Authors,
                        KeyWords  = temp.KeyWords,
                        JournalId = temp.JournalId,
                        CoverURL  = temp.CoverURL
                    });
                }
            }
        }