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

            DatabaseHelper.Execute("dbo.spInnerMaterials_ModifyInnerMaterial @Id, @Title, @Authors, @KeyWords",
                                   innerMaterial);
        }
Beispiel #2
0
        /// <summary>
        /// Adds inner material to database
        /// </summary>
        /// <param name="innerMaterial">Information about inner material</param>
        /// <returns>Document id</returns>
        public static long AddInnerMaterial(InnerMaterial innerMaterial)
        {
            if (innerMaterial == null)
            {
                throw new ArgumentNullException();
            }

            DatabaseHelper.Execute("dbo.spInnerMaterials_AddInnerMaterial @Title, @Authors, @Type, @Room, @Level, @KeyWords, @CoverURL",
                                   innerMaterial);

            return(GetDocumentId(innerMaterial));
        }
 public static InnerMaterial[] GetAllInnerMaterialsList()
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("LibraryDB")))
     {
         var             output = connection.Query <TempInner>("dbo.spInnerMaterials_GetAll").ToArray();
         InnerMaterial[] temp   = new InnerMaterial[output.Count()];
         for (int i = 0; i < temp.GetLength(0); i++)
         {
             temp[i] = new InnerMaterial(output[i].Id, output[i].Authors, output[i].Title, output[i].Type, output[i].KeyWords, output[i].Room, output[i].Level, output[i].CoverURL);
         }
         return(temp);
     }
 }
 public ModifyInnerMaterial(InnerMaterial inner, LibrarianWorkWindow window)
 {
     InitializeComponent();
     this.inner           = inner;
     this.window          = window;
     titleTextBox.Text    = inner.Title;
     authorTextBox.Text   = inner.Authors;
     keyWordsTextBox.Text = inner.KeyWords;
     roomTextBox.Text     = Convert.ToString(inner.Room);
     levelTextBox.Text    = Convert.ToString(inner.Level);
     typeTextBox.Text     = inner.Type;
     coverUrlTextBox.Text = inner.CoverURL;
 }
Beispiel #5
0
        private void reference_book_MouseUp(object sender, MouseButtonEventArgs e)
        {
            InnerMaterial inner = DataGridRefernce_book.SelectedItem as InnerMaterial;

            if (inner == null)
            {
                return;
            }

            ModifyInnerMaterial window = new ModifyInnerMaterial(inner, this);

            window.Owner = this;
            window.Show();
        }
 private void add_inner_to_db_Click(object sender, RoutedEventArgs e)
 {
     if (inner_title_box.Text != null &&
         inner_author_box.Text != null &&
         inner_level_text_box.Text != null &&
         inner_room_text_box.Text != null &&
         inner_type_text_box.Text != null &&
         inner_cover_url_box.Text != null &&
         inner_keywords_text_box.Text != null)
     {
         InnerMaterial innerMaterials = new InnerMaterial(InputFieldsManager.ReturnStringFromTextBox(inner_author_box), InputFieldsManager.ReturnStringFromTextBox(inner_title_box), InputFieldsManager.ReturnStringFromTextBox(inner_type_text_box), InputFieldsManager.ReturnStringFromTextBox(inner_keywords_text_box), Convert.ToInt32(InputFieldsManager.ReturnStringFromTextBox(inner_room_text_box)), Convert.ToInt32(InputFieldsManager.ReturnStringFromTextBox(inner_level_text_box)), InputFieldsManager.ReturnStringFromTextBox(inner_cover_url_box));
         LibrarianDataManager.AddInnerMaterial(innerMaterials);
         this.Close();
     }
 }
Beispiel #7
0
 public static void EditInnerMaterial(InnerMaterial innerMaterial)
 {
     HttpHelper.MakePutRequest("librarian/edit_inner_material", innerMaterial);
 }
Beispiel #8
0
 public static long AddInnerMaterial(InnerMaterial innerMaterial)
 {
     return(HttpHelper.MakePostRequest <long>("librarian/add_inner_material", innerMaterial));
 }
        /// <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
                    });
                }
            }
        }