示例#1
0
 //get id from all manga and added them to a list array.
 public void getAllManga()
 {
     DBSetup();
     cmd = "SELECT ID FROM Manga;";
     OleDbDataAdapter2.SelectCommand.CommandText = cmd;
     OleDbDataAdapter2.SelectCommand.Connection  = OleDbConnection2;
     //Console.WriteLine(cmd);
     try
     {
         OleDbConnection2.Open();
         System.Data.OleDb.OleDbDataReader dr;
         dr = OleDbDataAdapter2.SelectCommand.ExecuteReader();
         int   i  = 0;
         manga a1 = new manga();
         while (dr.Read())
         {
             //taking id a pulling all data from manga to add to list
             i  = dr.GetInt32(0);
             a1 = new manga();
             a1.selectSingleManga(i);
             arrL.add(a1);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     finally
     {
         OleDbConnection2.Close();
     }
 }
示例#2
0
 //takes two string one the keyword and the other the col in the database used to find the search results
 public void search(string keyWord, string col)
 {
     DBSetup();
     cmd = "Select * from Manga Where " + col + " Like '%" + keyWord + "%';";
     OleDbDataAdapter2.SelectCommand.CommandText = cmd;
     OleDbDataAdapter2.SelectCommand.Connection  = OleDbConnection2;
     Console.WriteLine(cmd);
     try
     {
         OleDbConnection2.Open();
         System.Data.OleDb.OleDbDataReader dr;
         dr = OleDbDataAdapter2.SelectCommand.ExecuteReader();
         int   i  = 0;
         manga a1 = new manga();
         while (dr.Read())
         {
             //taking id a pulling all data from manga to add to list
             i  = dr.GetInt32(0);
             a1 = new manga();
             a1.selectSingleManga(i);
             arrL.add(a1);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     finally
     {
         OleDbConnection2.Close();
     }
 }
示例#3
0
        private void searchBtn_Click(object sender, EventArgs e)
        {
            //gets both string from the form and trims the extra spaces from the front and end of the keyword.
            string key = searchTB.Text;
            string c   = colCB.Text;

            key = key.Trim(' ');
            //makes sure nothing is null or empty
            if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(c))
            {
                MessageBox.Show("Some Information is missing.");
            }
            else
            {
                manga s = new manga();
                s.search(key, c);
                //if there is no search result, shows message.
                if (s.arrL.count == 0)
                {
                    MessageBox.Show("Sorry there is no manga for " + key + " under " + c);
                }
                //when manga is found clears the datagridview and displays the search result.
                else
                {
                    mangaDGV.Rows.Clear();
                    totalLabel.Text = s.arrL.count.ToString();
                    fillTable(s.arrL.arrlist);
                }
            }
        }
示例#4
0
 //getNewMangaInfo method checks if all information is filled.
 public void getNewMangaInfo()
 {
     name   = mNameTB.Text;
     author = mAuthorTB.Text;
     getGenres();
     type = typeCB.Text;
     //error message if some information is missing.
     if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(author) || string.IsNullOrWhiteSpace(genres) || string.IsNullOrWhiteSpace(type) || string.IsNullOrWhiteSpace(file))
     {
         MessageBox.Show("Some information is missing");
         genres = null;
     }
     else
     {
         //Double checks with user, id all information is right.
         DialogResult ans = MessageBox.Show("Is this information right?\n Name:" + name +
                                            "\n Author: " + author +
                                            "\n Genres: " + genres +
                                            "\n Type: " + type +
                                            "\n File Loaction: " + file,
                                            "Check", MessageBoxButtons.YesNo);
         if (ans == DialogResult.Yes)
         {
             //execute insert query
             //////note- might make it to work with single manga object
             manga getLast = new manga();
             getLast.getLastAccount();
             id = getLast.lastIDNum;
             manga add = new manga(id, name, author, genres, type, file);
             add.insertSingleManga();
             Image    img = Image.FromFile(file);
             Object[] row = new Object[] { id, name, author, genres, type, img };
             frm1.mangaDGV.Rows.Add(row);
             MessageBox.Show("You added");
             frm1.Enabled = true;
             Close();
         }
         else if (ans == DialogResult.No)
         {
             genres = null;
         }
     }
 }
示例#5
0
 //Adds an manga the the list
 public void add(manga a)
 {
     arrlist.Add(a);
     count++;
 }