Exemplo n.º 1
0
        public void DeleteEmprunt(Emprunt emp)
        {
            SqlConnection connect = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Jean\Downloads\EasyBorrowing.mdf;Integrated Security=True;Connect Timeout=30");
            SqlCommand    command = new SqlCommand("DELETE FROM Emprunts WHERE ID = @id", connect);

            command.Parameters.AddWithValue("@id", emp.Id);
            connect.Open();
            command.ExecuteNonQuery();
            connect.Close();
        }
Exemplo n.º 2
0
        public void AddModifyEmprunt(Emprunt emp)
        {
            SqlConnection connect = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Jean\Downloads\EasyBorrowing.mdf;Integrated Security=True;Connect Timeout=30");
            SqlCommand    command = new SqlCommand("UPDATE Emprunts SET ID = @id, ID_LIVRE = @idli, ID_EMPRUNTEUR = @idemp, DATE_DEBUT = @Date debut, DATE_FIN = @datefin, DATE_FIN_PREVUE = @datefinprevu  FROM (SELECT ID FROM Emprunts WHERE ID = @id", connect);

            command.Parameters.AddWithValue("@id", emp.Id);
            command.Parameters.AddWithValue("@idli", emp.Livre.Id);
            command.Parameters.AddWithValue("@idemp", emp.Emprunteur.Id);
            command.Parameters.AddWithValue("@Datedebut", emp.DateDebut);
            command.Parameters.AddWithValue("@datefin", emp.DateFin);
            command.Parameters.AddWithValue("@datefinprevu", emp.DateDebut.AddDays(14));
            connect.Open();
            command.ExecuteNonQuery();
            connect.Close();
        }
Exemplo n.º 3
0
        public static List <Emprunt> getEmprunt()
        {
            List <Emprunt> res = new List <Emprunt>();
            DataTable      dt  = Datafill("SELECT * FROM Emprunts");

            foreach (DataRow dr in dt.Rows)
            {
                Emprunt n = new Emprunt(
                    (DateTime)dr["DATE_DEBUT"],
                    (DateTime)dr["DATE_FIN"],
                    getEmprunteurByID((int)dr["ID_EMPRUNTEUR"]),
                    getLivreByID((int)dr["ID_LIVRE"])
                    );
            }

            return(res);
        }