public DataTable DataSetToObject(DataSet ds) { ds.Tables[0].Columns.Add("hashValue", typeof(System.Int32)); int count = 0; Hashing.BookPublication bookPub = new Hashing.BookPublication(); foreach (DataRow dr in ds.Tables[0].Rows) { count++; long id = 0; bool idResult = Int64.TryParse(dr["id"].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out id); string title = dr["title"].ToString(); string author = ""; if (!string.IsNullOrEmpty(dr["author"].ToString())) { author = dr["author"].ToString(); } string publication = dr["publication"].ToString(); DateTime date = default(DateTime); if (!string.IsNullOrEmpty(dr["date"].ToString()) && dr["date"].ToString().Length <= 10) { date = DateTime.ParseExact(dr["date"].ToString().Substring(0, 10), "dd-MM-yyyy", CultureInfo.CurrentCulture); } Hashing.BookPublication bp = new Hashing.BookPublication(id, title, author, publication, date); dr["hashValue"] = bp.GetHashCode(); Int32 key = Int32.Parse(dr["hashValue"].ToString()); Hashing.HashTableOfBook.ComputeHashtable(key, bp); } return(ds.Tables[0]); }
private void button1_Click_1(object sender, EventArgs e) { Hashing.BookPublication bookPub = new Hashing.BookPublication(); int key = Int32.Parse(textBox2.Text); bookPub = bookPub.GetDetailsfromKey(key, Hashing.HashTableOfBook.bookTable); StringBuilder sb = new StringBuilder(); sb.AppendLine("BookId : " + bookPub.BookId.ToString()); sb.AppendLine("Title : " + bookPub.Title.ToString()); sb.AppendLine("Author : " + bookPub.Author.ToString()); sb.AppendLine("Publication : " + bookPub.Publication.ToString()); sb.AppendLine("Date : " + bookPub.Date.ToString()); richTextBox1.Text = sb.ToString(); }