Пример #1
0
 public void FillAllCombobox()
 {
     try
     {
         var       db = new SQLDatabaseHelper();
         DataTable recipe;
         String    query = "SELECT * FROM TypeSentence";
         recipe = db.GetDataTable(query);
         if (recipe != null)
         {
             foreach (DataRow r in recipe.Rows)
             {
                 cbbType.Items.Add(r["Description"].ToString());
             }
         }
         query  = "SELECT * FROM People";
         recipe = db.GetDataTable(query);
         if (recipe != null)
         {
             foreach (DataRow r in recipe.Rows)
             {
                 cbbPeople.Items.Add(r["RealName"].ToString());
                 cbbAuthor.Items.Add(r["RealName"].ToString());
             }
         }
     }
     catch (Exception fail)
     {
         String error = "The following error has occurred:\n\n";
         error += fail.Message.ToString() + "\n\n";
     }
 }
Пример #2
0
 public void ShowData(int type, int people, int author)
 {
     try
     {
         var       db = new SQLDatabaseHelper();
         DataTable recipe;
         String    query =
             "SELECT  s.ID,s.Sentence AS 'Câu',t.Description AS 'Kiểu câu',p.RealName AS 'Viết cho',s.Author AS 'Người viết' " +
             "FROM Sentence s, TypeSentence t, People p " +
             "WHERE (s.TypeId = t.ID AND s.PeopleId = p.ID";
         if (type != 0)
         {
             query += " AND s.TypeId =" + type;
         }
         if (people != 0)
         {
             query += " AND s.PeopleId =" + people;
         }
         if (author != 0)
         {
             query += " AND s.Author =" + author;
         }
         query += ")";
         recipe = db.GetDataTable(query);
         dgvSentence.DataSource = recipe;
     }
     catch (Exception fail)
     {
         String error = "The following error has occurred:\n\n";
         error += fail.Message.ToString() + "\n\n";
     }
 }
Пример #3
0
        public string getStringPeople(int Id)
        {
            string result = "";

            try
            {
                var       db = new SQLDatabaseHelper();
                DataTable recipe;
                String    query = "SELECT * FROM People WHERE ID =" + Id;
                recipe = db.GetDataTable(query);
                if (recipe != null)
                {
                    foreach (DataRow r in recipe.Rows)
                    {
                        result = (string)r["RealName"];
                    }
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
            }
            return(result);
        }
Пример #4
0
        public int getIDPeople(string str)
        {
            if (str == "")
            {
                return(0);
            }
            int result = 1;

            try
            {
                var       db = new SQLDatabaseHelper();
                DataTable recipe;
                String    query = "SELECT * FROM People WHERE RealName LIKE N'%" + str + "%'";
                recipe = db.GetDataTable(query);
                if (recipe != null)
                {
                    foreach (DataRow r in recipe.Rows)
                    {
                        result = (int)r["ID"];
                    }
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
            }
            return(result);
        }