Beispiel #1
0
        protected void ShowAuthorInfo(Pagedb db)
        {
            bool   valid    = true;
            string authorid = Request.QueryString["authorid"];

            if (String.IsNullOrEmpty(authorid))
            {
                valid = false;
            }


            show_authorfname.InnerHtml = "";
            show_authorlname.InnerHtml = "";

            if (valid)
            {
                Authors author_record = db.FindAuthor(Int32.Parse(authorid));
                show_authorfname.InnerHtml    = author_record.GetAuthorfname();
                show_authorlname.InnerHtml    = author_record.GetAuthorlname();
                show_authorfullname.InnerHtml = show_authorfname.InnerHtml + " " + show_authorlname.InnerHtml;
            }
            else
            {
                valid = false;
            }
        }
Beispiel #2
0
        public void Update_Author(int authorid, Authors new_author)
        {
            string query = "update authors set authorfname='{0}', authorlname='{1}' where authorid={2}";

            query = String.Format(query, new_author.GetAuthorfname(), new_author.GetAuthorlname(), authorid);
            MySqlConnection Connect = new MySqlConnection(ConnectionString);
            MySqlCommand    cmd     = new MySqlCommand(query, Connect);

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
                Debug.WriteLine("Executed query " + query);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong in the Update_Author Method!");
                Debug.WriteLine(ex.ToString());
            }
            Connect.Close();
        }
Beispiel #3
0
        //adding a new author
        public void Add_Author(Authors new_author)
        {
            string query = "insert into authors (authorfname, authorlname) values('{0}', '{1}')";

            query = String.Format(query, new_author.GetAuthorfname(), new_author.GetAuthorlname());
            MySqlConnection Connect = new MySqlConnection(ConnectionString);
            MySqlCommand    cmd     = new MySqlCommand(query, Connect);

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong in the Add_Author Method!");
                Debug.WriteLine(ex.ToString());
            }

            Connect.Close();
        }