Example #1
0
    //permet de generer le pdf pour un client
    public static void genererPDFClient(string adresseMail)
    {
        Client client = ControleurClient.getClient(adresseMail);

        using (FileStream stream = new FileStream("..//..//Client_" + client.Nom + "_" + client.Prenom + ".pdf", FileMode.Create))
        {
            int nombreHeureEffective        = ControleurClient.getNombreHeureEffectiveClient(adresseMail);
            List <Reservation> reservations = ControleurReservation.getReservationClient(client.AdresseMail);

            Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
            PdfWriter.GetInstance(pdfDoc, stream);
            pdfDoc.Open();
            Paragraph p1 = new Paragraph();
            p1.Add(new Phrase("\n\n\n   " + client.Nom + " " + client.Prenom, new Font(Font.NORMAL, 24)));
            p1.Add(new Phrase("\n\n\t   " + client.Adresse, new Font(Font.NORMAL, 24)));
            p1.Add(new Phrase("\n\n\t   " + client.Telephone, new Font(Font.NORMAL, 24)));
            p1.Add(new Phrase("\n\n\t   " + client.AdresseMail, new Font(Font.NORMAL, 24)));
            pdfDoc.Add(p1);

            Image logo = Image.GetInstance("C:\\Users\\med\\Documents\\Visual Studio 2015\\Projects\\DesktopIHM\\DesktopIHM\\Images\\téléchargement.jpg");
            logo.SetAbsolutePosition(900, 1400);
            pdfDoc.Add(logo);
            Phrase ph1 = new Phrase("\n\n\n   Nombre d'heure effectives : " + nombreHeureEffective + "H", new Font(Font.NORMAL, 24));
            pdfDoc.Add(ph1);
            Phrase ph2 = new Phrase("\n\n\n   Mon planning : ", new Font(Font.NORMAL, 24));
            pdfDoc.Add(ph2);
            PdfPTable table = new PdfPTable(3);
            foreach (Reservation reservation in reservations)
            {
                table.AddCell(reservation.Moniteur.Nom + " " + reservation.Moniteur.Prenom);
                table.AddCell(reservation.Vehicule.Immatriculation);
                table.AddCell(reservation.Date.ToString());
            }
            pdfDoc.Add(table);

            double res = GestionPaiement.calculPaiement(client.AdresseMail);
            if (res < 0)
            {
                Phrase ph3 = new Phrase("\n\n\n   L'auto école vous doit : " + Math.Abs(res) + "€", new Font(Font.NORMAL, 24));
                pdfDoc.Add(ph3);
            }
            else
            {
                Phrase ph3 = new Phrase("\n\n\n   Vous devez  : " + res + "€ à l'auto école", new Font(Font.NORMAL, 24));
                pdfDoc.Add(ph3);
            }



            pdfDoc.Close();
            stream.Close();
        }
    }
    //permet de recuperer tous les paiement d'un client
    public static List <Paiement> getPaiementClient(int idClient)
    {
        List <Paiement> paiements = new List <Paiement>();

        conn.Open();
        MySqlCommand query = new MySqlCommand("select * from ladi.DSMSpaiement where idClient=@idClient", conn);

        query.Parameters.AddWithValue("@idClient", idClient);

        using (MySqlDataReader reader = query.ExecuteReader())
        {
            while (reader.Read())
            {
                paiements.Add(new Paiement(ControleurClient.getClient(idClient), reader.GetString(2), reader.GetDateTime(3), reader.GetDouble(4)));
            }
        }

        conn.Close();
        Console.WriteLine("paiements");
        return(paiements);
    }
    //permet de recuperer tous les reservations d'un véhicule à partir d'une adresseMail
    public static List <Reservation> getReservationVehicule(string immatriculation)
    {
        List <Reservation> reservations = new List <Reservation>();

        conn.Open();
        MySqlCommand query = new MySqlCommand("select * from ladi.DSMSreservation r,ladi.DSMSvehicule v where r.idVehicule=v.idVehicule and r.realisee=0 and v.immatriculation=@immatriculation", conn);

        query.Parameters.AddWithValue("@immatriculation", immatriculation);

        using (MySqlDataReader reader = query.ExecuteReader())
        {
            while (reader.Read())
            {
                reservations.Add(new Reservation(ControleurClient.getClient(reader.GetInt32(1)), ControleurMoniteur.getMoniteur(reader.GetInt32(2)), ControleurVehicule.getVehicule(immatriculation), Outils.convertirStringToDateTime(reader.GetString(4))));
            }
        }

        conn.Close();
        Console.WriteLine("reservations");
        return(reservations);
    }
    //permet de recuperer tous les reservations d'un client à partir d'une adresseMail
    public static List <Reservation> getReservationClient(string adresseMail)
    {
        List <Reservation> reservations = new List <Reservation>();

        conn.Open();
        MySqlCommand query = new MySqlCommand("select * from ladi.DSMSreservation r,ladi.DSMSpersonne p  where r.idClient=p.idPersonne and r.realisee=0 and p.adresseMail=@adresseMail", conn);

        query.Parameters.AddWithValue("@adresseMail", adresseMail);

        using (MySqlDataReader reader = query.ExecuteReader())
        {
            while (reader.Read())
            {
                reservations.Add(new Reservation(ControleurClient.getClient(adresseMail), ControleurMoniteur.getMoniteur(reader.GetInt32(2)), ControleurVehicule.getVehicule(reader.GetInt32(3)), Outils.convertirStringToDateTime(reader.GetString(4))));
            }
        }

        conn.Close();
        Console.WriteLine("reservations");
        return(reservations);
    }
Example #5
0
 public FicheClient(string adresseMail)
 {
     client = ControleurClient.getClient(adresseMail);
     InitializeComponent();
     completerFenetre();
 }