Exemple #1
0
        private void AddBook_Load(object sender, EventArgs e)
        {
            c = new Connexion();
            b = new Books();

            SelectfromTable("SELECT * FROM Autor", "autor_name", cb_Writer);
            SelectfromTable("SELECT * FROM EDITOR", "EDITOR_name", cb_Publisher);
            SelectfromTable("SELECT * FROM Category", "nom", cb_cate);
            SelectfromTable("SELECT * FROM Zon", "nom", cb_zon);


            if (b.ID != null)
            {
                dataTable = c.showDataTable(String.Format(@"SELECT * FROM dbo.book WHERE book_id = '{0}'", b.ID));

                using (MemoryStream ms = new MemoryStream(c.getImage(int.Parse(dataTable.Rows[0]["image_id"].ToString()))))
                {
                    image          = Image.FromStream(ms);
                    pic_book.Image = image;
                }

                tb_Title.Text    = dataTable.Rows[0]["title"].ToString();
                tb_ISBN.Text     = dataTable.Rows[0]["book_isbn"].ToString();
                tb_Pnum.Text     = dataTable.Rows[0]["page_number"].ToString();
                tb_Amount.Text   = dataTable.Rows[0]["quantity"].ToString();
                mtb_datePub.Text = DateTime.Parse(dataTable.Rows[0]["date_created"].ToString()).ToString("dd:mm:yyyy");

                cb_Writer.Text    = c.executer_valeur(string.Format(@"SELECT autor_name FROM Autor WHERE [aut_id] = '{0}'", dataTable.Rows[0]["aut_id"].ToString()));
                cb_Publisher.Text = c.executer_valeur(string.Format(@"SELECT EDITOR_name FROM EDITOR WHERE [EDITOR_id] = '{0}'", dataTable.Rows[0]["id_editor"].ToString()));
                cb_cate.Text      = c.executer_valeur(string.Format(@"SELECT nom FROM category WHERE [id] = '{0}'", dataTable.Rows[0]["category"].ToString()));
                cb_zon.Text       = c.executer_valeur(string.Format(@"SELECT nom FROM Zon WHERE [id] = '{0}'", dataTable.Rows[0]["zon_id"].ToString()));

                But_Ok.Text = "Update";
            }
        }
Exemple #2
0
 public Person ReadFileXML()
 {
     try
     {
         XElement[] list = XDocument.Load("persson.xml").Descendants().ToArray();
         Person person = new Person();
         person.ID = Convert.ToInt32(list[2].Value);
         person.Firstname = list[3].Value;
         person.LastName = list[4].Value;
         person.Dateins = Convert.ToDateTime(list[5].Value);
         person.BirthDate = Convert.ToDateTime(list[6].Value);
         person.Phone = list[7].Value;
         person.Password = list[8].Value;
         person.Email = list[9].Value;
         person.Pertype = Convert.ToBoolean(list[10].Value);
         Connexion c = new Connexion(); c.Con.Open();
         person.Image = c.getImage(Convert.ToInt32(new SqlCommand("select image_id from person where per_id=" + person.ID, c.Con).ExecuteScalar().ToString())); c.Con.Close();
         return person;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return new Person();
     }
 }
Exemple #3
0
        private void DG_book_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            c     = new Connexion();
            index = e.RowIndex;

            using (MemoryStream ms = new MemoryStream(c.getImage(int.Parse(DG_book["image_id", index].Value.ToString()))))
            {
                image          = Image.FromStream(ms);
                pic_book.Image = image;
            }

            tb_Title.Text   = DG_book["title", index].Value.ToString();
            tb_Writer.Text  = getAutorName(DG_book["aut_id", index].Value.ToString());
            tb_DatePub.Text = DG_book["date_created", index].Value.ToString();
            tb_Writer.Text  = DG_book["date_created", index].Value.ToString();
            tb_Zon.Text     = getZonNumber(DG_book["zon_id", index].Value.ToString()).ToString();
        }