Esempio n. 1
0
        static void getBookInput()
        {
            Console.Write("\nEnter hexagon: ");
            string addr = Console.ReadLine(); Console.Write('\n');

            Console.Write("Enter wall: ");
            int wall; int.TryParse(Console.ReadLine(), out wall);

            Console.Write('\n');

            Console.Write("Enter shelf: ");
            int shelf; int.TryParse(Console.ReadLine(), out shelf);

            Console.Write('\n');

            Console.Write("Enter volume: ");
            int vol; int.TryParse(Console.ReadLine(), out vol);

            Console.Write('\n');

            Console.Write("Enter page: ");
            int page; int.TryParse(Console.ReadLine(), out page);

            Console.Write('\n');

            Console.WriteLine("================================================");

            BookStruct book = lib.decodeHex(addr);

            book.wall = wall; book.shelf = shelf; book.vol = vol; book.page = page;
            lib.generateBook(book, false);
        }
Esempio n. 2
0
        public static void TestBookStruct()
        {
            BookStruct book = new BookStruct("Hello World", "Greetings", "Program", 5, 2, "insertIsbnHere", "Fancy");

            Console.WriteLine($"book.Title = {book.Title}");
            Console.WriteLine($"book.Category = {book.Category}");
            Console.WriteLine($"book.Author = {book.Author}");
            Console.WriteLine($"book.PageCount = {book.PageCount}");
            Console.WriteLine($"book.Page = {book.Page}");
            Console.WriteLine($"book.ISBN = {book.ISBN}");
            Console.WriteLine($"book.CoverStyle = {book.CoverStyle}");
            Console.WriteLine();

            Console.WriteLine("book.NextPage();");
            book.NextPage();
            Console.WriteLine($"book.Page = {book.Page}");
            Console.WriteLine();

            Console.WriteLine("book.PreviousPage();");
            book.PreviousPage();
            Console.WriteLine($"book.Page = {book.Page}");
            Console.WriteLine();

            Console.WriteLine("book.NextPage(); x10 times");
            for (int i = 0; i < 10; i++)
            {
                book.NextPage();
            }
            Console.WriteLine($"book.Page = {book.Page}");
            Console.WriteLine();
        }
Esempio n. 3
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            wasBDError          = false;
            LabelException.Text = "";
            string name = "", author = "", year = "01.01.0001", contents = "";

            int        id         = int.Parse(TextBoxID.Text);
            BookStruct bookStruct = SelectBook(id, name, author, year, contents);

            name     = TextBoxName.Text;
            author   = TextBoxAuthor.Text;
            year     = TextBoxYear.Text;
            contents = TextBoxContents.Text;

            if (bookStruct.id != 0)
            {
                UpdateBook(id, name, author, year, contents);
            }
            else
            {
                InsertBook(id, name, author, year, contents);
            }

            if (!wasBDError)
            {
                Response.Redirect("BookViewer.aspx?");
            }
        }
Esempio n. 4
0
 public void OnEnable()
 {
     assetPath = AssetDatabase.GetAssetPath(target);
     if (assetPath.IsExcel())
     {
         var book = ExcelUtils.Open(assetPath);
         var tmp  = new BookStruct();
         tmp.Name = assetPath;
         tmp.Book = book;
         foreach (var sheet in book.AllSheets())
         {
             var ss = new SheetStruct();
             ss.Name  = sheet.SheetName;
             ss.Sheet = sheet;
             tmp.Sheets.Add(ss);
         }
         mTarget = tmp;
     }
 }
Esempio n. 5
0
        protected void ButtonDelete_Click(object sender, EventArgs e)
        {
            wasBDError = false;

            int id = int.Parse(TextBoxID.Text);

            string     name = "", author = "", year = "01.01.0001", contents = "";
            BookStruct bookStruct = SelectBook(id, name, author, year, contents);


            if (bookStruct.id != 0)
            {
                DeleteBook(id);
                if (!wasBDError)
                {
                    Response.Redirect("BookViewer.aspx?");
                }
            }
        }
Esempio n. 6
0
        public void TestGenSuc()
        {
            string     input = "1";
            Library    lib   = new Library();
            BookStruct page  = lib.decodeHex(lib.encodeHex(input));

            Assert.AreEqual(page.searchText, input); //See if extraction is a success

            BookStruct page2 = lib.decodeHex(lib.encodeHex(input));
            //Assert.AreEqual(page, page2);

            string text = lib.generateBook(page, false);

            page2.page += 1;
            string text1 = lib.generateBook(page2, false);

            Assert.AreNotSame(text, text1);
            StringAssert.Contains(text, page.searchText);
        }
        public void DesBookStructTest()
        {
            object obj = BookStruct.GetSampleInstance();

            PerformTest(obj);
        }
Esempio n. 8
0
        private BookStruct SelectBook(int id, string name, string author, string year, string contents)
        {
            BookStruct bookStruct;

            bookStruct = new BookStruct();

            using (SqlConnection con = new SqlConnection(SqlDataSource1.ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("SelectBook", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    //cmd.Parameters.Add("@id", SqlDbType.Int).Value = id;


                    SqlParameter idParam = cmd.Parameters.Add("@id", SqlDbType.Int);
                    idParam.Value = id;

                    SqlParameter idParamReturn = cmd.Parameters.Add("@idRet", SqlDbType.Int);
                    idParamReturn.Direction = ParameterDirection.Output;
                    idParamReturn.Value     = name;

                    SqlParameter nameParam = cmd.Parameters.Add("@name", SqlDbType.VarChar, 255);
                    nameParam.Direction = ParameterDirection.Output;
                    nameParam.Value     = name;

                    SqlParameter authorParam = cmd.Parameters.Add("@author", SqlDbType.VarChar, 255);
                    authorParam.Direction = ParameterDirection.Output;
                    authorParam.Value     = author;

                    SqlParameter yearParam = cmd.Parameters.Add("@year", SqlDbType.Date);
                    yearParam.Direction = ParameterDirection.Output;
                    yearParam.Value     = year;

                    SqlParameter contentsParam = cmd.Parameters.Add("@contents", SqlDbType.Xml);
                    contentsParam.Direction = ParameterDirection.Output;
                    contentsParam.Value     = contents;


                    con.Open();
                    try
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            name     = nameParam.Value.ToString();
                            author   = authorParam.Value.ToString();
                            year     = yearParam.Value.ToString();
                            contents = contentsParam.Value.ToString();

                            if (idParamReturn.Value != DBNull.Value)
                            {
                                bookStruct = new BookStruct(id, name, author, year, contents);
                            }

                            if (reader.HasRows)
                            {
                                if (reader.Read())
                                {
                                    //more code
                                }
                            }
                        }
                    }
                    catch (Exception e) { SetErrorState(e); }
                }
            }

            return(bookStruct);
        }