Exemplo n.º 1
0
        public void InsertCopy(Copy copy)
        {
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(INSERT_COPY, conn);

                /* Add parameters into the command */
                command.Parameters.AddWithValue("@copy_is_present", copy.copy_is_present);
                command.Parameters.AddWithValue("@book_id", copy.book_id);

                /* Executes the command */
                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 2
0
        public List<Copy> SelectAll()
        {
            List<Copy> copyList = new List<Copy>();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ALL, conn);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Copy copy = new Copy();
                    copy.copy_id = reader.GetInt32(0);
                    copy.copy_is_present = reader.GetInt32(1);
                    copy.book_id = reader.GetInt32(2);

                    copyList.Add(copy);
                }
            }
            return copyList;
        }
Exemplo n.º 3
0
        public Copy SelectOne(int copyId)
        {
            Copy copy = new Copy();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ONE, conn);
                command.Parameters.AddWithValue("@copy_id", copyId);

                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    copy.copy_id = reader.GetInt32(0);
                    copy.book_id = reader.GetInt32(1);
                    copy.copy_is_present = reader.GetInt32(2);
                }
                reader.Close();
            }
            return copy;
        }
Exemplo n.º 4
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            //prida zaznam do kopie
            DatabaseLibrary.Copy copy = new DatabaseLibrary.Copy();

            copy.copy_is_present = Convert.ToInt32(TextBox_copy_isPresent.Text);
            copy.book_id = Convert.ToInt32(ddl_copy_bookID.SelectedValue);

            new DatabaseLibrary.CopyTable().InsertCopy(copy);

            Response.Redirect(Request.RawUrl);
        }
Exemplo n.º 5
0
        public List<Copy> SelectAllPresentByBook(int bookId)
        {
            List<Copy> copyList = new List<Copy>();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ALLPRESENT_BY_BOOK_ID, conn);
                command.Parameters.AddWithValue("@book_id", bookId);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Copy copy = new Copy();
                    copy.copy_id = reader.GetInt32(0);
                    copy.copy_is_present = reader.GetInt32(1);
                    copy.book_id = reader.GetInt32(2);

                    copyList.Add(copy);
                }
            }
            return copyList;
        }