1. La classe Connexion class Connexion {



Similar documents
How To Create A Database In Araba

Conexión SQL Server C#

{ oledbdataadapter1.updatecommand.commandtext = "update personel set ad='" + textbox2.text + "' where id=" + textbox1.text; oledbconnection1.

C# Datenbank-Programmierung

Access Data Object (cont.)

I A Form és a párbeszédablakok I.1. MessageBox osztály MessageBox.Show(szöveg[,cím[,gombok[,ikon[,defaultbutton]]]]);

1.Tüm Kayıtları Getirme - Arama Yapma

PROCEDURE INSERTION(NUM IN EMPLOYES.NUMEMP%TYPE, NOM VARCHAR2, PRENOM IN VARCHAR2, PPHOTO IN BLOB, SALAIRE IN NUMBER);

BACKING UP A DATABASE

ASP and ADO (assumes knowledge of ADO)

A Step by Step Guide for Building an Ozeki VoIP SIP Softphone

Real-World ASP.NET: Building a Content Management System

How To Design An Eprescription System

Introduction to Visual Studio and C#

ASP.NET(C#) ile Kayıt Listeleme, Silme ve Düzenleme İşlemi

Aucune validation n a été faite sur l exemple.

Form Tasarımı - 5. Veri Tabanı Veri tabanı ismi; m Tablo ismi; mt

How To Create A Data Gateway On A Microsoft Powerbook On A Pc Or Macode (For Microsoft) On A Macode 2.5 (For A Microode) On An Ipad Or Macroode ( For A Microos

ADOBE READER AND ACROBAT

RSS Feed from an Access Database

Sending Data from a computer to a microcontroller using a UART (Universal Asynchronous Receiver/Transmitter)

Chapter 14 WCF Client WPF Implementation. Screen Layout

J a v a Quiz (Unit 3, Test 0 Practice)

Systems Programming & Scripting

Using IRDB in a Dot Net Project

A PROJECT REPORT ON. SkyDrive. Submitted for the partial fulfillment of the requirement for the Award of the degree of MASTER OF COMPUTER APPLICATION

VB.NET - DATABASE ACCESS

How To Develop A Mobile Application On Sybase Unwired Platform

آموزش DataGrid در WPF به همراه صفحه بندي و جستجوي انتخابی. کلیک کن

v1.1.0 SimpleSQL SQLite manager for Unity3D echo17.com

MyChartWebPart.cs. // For SortList using System.Collections.Generic; using System.Collections; // For DataTable using System.Data;

Tutorial: Windows Mobile Application Development. Sybase Unwired Platform 2.1 ESD #2

Facebook Twitter YouTube Google Plus Website

Secure Authentication and Session. State Management for Web Services

One method for batch DHI data import into SQL-Server. A batch data import technique for DateSet based on.net Liang Shi and Wenxing Bao

Interaction Tracker Interaction Segments

Self Service User Authentication Service Usage Guidelines. Copyright 2013, CionSystems Inc.

Is Paradox a good front-end for MySql?

如 何 在 C#.2005 中 使 用 ICPDAS I/O Card 的 DLL 檔 案

Sage HRMS 2015 Sage Employee Self Service Advanced Customization. February 2015

Brazil + JDBC Juin 2001, douin@cnam.fr

Licence Informatique Année Exceptions

Bronson Door Company Web Site

Server side scripting and databases

Using C# for Graphics and GUIs Handout #2

120, 200 x. r1 = 25. virtua void translate (int dx, dy) = 0; virtual void dessiner(graphics &g) = 0;

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

Einführung in die Windows Store App Entwicklung mit C# und XAML. Modul 2 Datenbindung und Zugriff auf das lokale Dateisystem

Beginning MYSQL 5.0. With. Visual Studio.NET 2005

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Bertrand Meyer. C#: Persistence

Log/Process/Hashing. Details. Activities. Processes

Synchronizing databases

TP1 : Correction. Rappels : Stream, Thread et Socket TCP

Project 4 DB A Simple database program

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";! SET time_zone = "+00:00";!

WINDOWS PRESENTATION FOUNDATION LEKTION 3

Web Development using PHP (WD_PHP) Duration 1.5 months

2. Modify default.aspx and about.aspx. Add some information about the web site.

LSINF1124 Projet de programmation

Obfuscating your code with SmartAssembly. SmartAssembly - 6.2

Database Communica/on in Visual Studio/C# using ASP.NET Web Forms. Hans- PeBer Halvorsen, M.Sc.

DIPLOMA IN WEBDEVELOPMENT

Coding Standards for C#

public void setusername(string username) { this.username = username; } public void setname(string name) { this.name = name; }

TP JSP : déployer chaque TP sous forme d'archive war

Creating the Product Catalog Part I (continued)

TS: Microsoft.NET Framework 3.5, ASP.NET Application Development

Windows Mobile Power Management

Security API Cookbook

Building a Custom User Manager

Sage Abra SQL HRMS. Abra Workforce Connections. Advanced Customization Guide

A Static Analysis Framework for Database Applications

Hands-On Lab. Client Workflow. Lab version: Last updated: 2/23/2011

Advanced Object Oriented Database access using PDO. Marcus Börger

C Coding Style Guide. Technotes, HowTo Series. 1 About the C# Coding Style Guide. 2 File Organization. Version 0.3. Contents

Tutorial 1: M/M/n Service System Simulation Tutorial 2: M/M/n Simulation using Excel input file Tutorial 3: A Production/Inventory System Simulation

Hibernate Validator. Olivier Devoisin Kevin Gallardo. Université Pierre et Marie Curie. 9 Decembre 2014

EMC Documentum Application Connectors Software Development Kit

Collections.sort(population); // Método de ordenamiento

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

Login with other services to ASP.NET websites with TMS Cloud Pack for.net

Evaluation. Copy. Evaluation Copy. Chapter 7: Using JDBC with Spring. 1) A Simpler Approach ) The JdbcTemplate. Class...

Software Engineering 1 EEL5881 Spring Homework - 2

Active Commerce Developer s Cookbook

Corrigés des exercices SQL pour MySQL

Note concernant votre accord de souscription au service «Trusted Certificate Service» (TCS)

CS170 Lab 11 Abstract Data Types & Objects

The Developer Side of the MS Business Intelligence Stack

Transcription:

1. La classe Connexion class Connexion public static string chaine; IDbConnection cnx; IDbCommand cmd; IDataReader dr; private string chainesqlserver = "Data Source=localhost;Initial catalog=reservations; User Id=user;password=111"; private string chainemysql = ""; private string chaineaccess = ""; private string chaineoracle = ""; private void ouvrirconnexion(string type) switch (type) // case "MYSQL": // MySqlConnection cnx; // cnx = new MySqlConnection(chaineMysql); // break; case "ACCESS": //OleDbConnection cnx; cnx = new OleDbConnection(chaineAccess); break; case "SQLSERVER": //SqlConnection cnx; cnx = new SqlConnection(chaineSqlServer); break; cnx.open(); public Connexion() //Obtenir le type de bases de données //ConfigurationException ouvrirconnexion("sqlserver"); public Connexion(string type) ouvrirconnexion(type);

public void Fermer() cnx.close(); public DataTable requete(string sql) return dt; cmd = cnx.createcommand(); cmd.commandtext = sql; dr = cmd.executereader(); DataTable dt = new DataTable(); dt.load(dr); dr.close(); public bool Update(string sql) int r; cmd = cnx.createcommand(); cmd.commandtext = sql; r=cmd.executenonquery(); if (r > 0) return true; else return false; 2. La classe CtrlListeHotels public class CtrlListeHotels public List<Ville> GetListeVilles() Connexion cnx=new Connexion(); DataTable dt= cnx.requete("select * from ville");

List<Ville> villes=new List<Ville>(); Ville ville; foreach (DataRow ligne in dt.rows ) ville= new Ville(); ville.nom = ligne["nom"].tostring(); villes.add(ville); cnx.fermer(); return villes; public List<Hotel> GetListeHotels(String ville) Connexion cnx = new Connexion(); +"'"); DataTable dt = cnx.requete("select * from hotel where nomville='" + ville List<Hotel> hotels = new List<Hotel>(); Hotel hotel; foreach (DataRow ligne in dt.rows) hotel = new Hotel(); hotel.nom = ligne["nom"].tostring(); hotel.adresse = ligne["adresse"].tostring(); hotel.prixchambre =(decimal) ligne["prixchambre"] ; hotels.add(hotel); cnx.fermer(); return hotels; public Hotel GetInfoHotel(String nom) Connexion cnx = new Connexion(); DataTable dt = cnx.requete("select * from hotel where nom='" + nom + "'"); Hotel hotel = new Hotel(); hotel.nom = dt.rows[0]["nom"].tostring(); hotel.adresse = dt.rows[0]["adresse"].tostring(); hotel.prixchambre = (decimal)dt.rows[0]["prixchambre"]; return hotel;

3. La classe CtrlReservation public class CtrlReservation public void AjouterReservation(Reservation r) Connexion cnx = new Connexion(); string sql = "insert into reservation values(" + r.numero + ",'" + r.nomhotel + "','" + r.datededebut + "'," + r.nombredejours + "," + r.nombredechambres + ",'" + r.nom + "','" + r.nom + "','" + r.email + "')"; cnx.update(sql); cnx.fermer(); 4. Formulaire Sélection Hôtel public static string nom; public static string adresse; public static string prix; CtrlListeHotels ctr = new CtrlListeHotels(); public Form1() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) combobox1.datasource = ctr.getlistevilles(); combobox1.displaymember = "nom"; combobox1.valuemember = "nom"; private void combobox1_selectedindexchanged(object sender, EventArgs e) clear(); lsthotels.datasource = ctr.getlistehotels(combobox1.text); lsthotels.displaymember = "nom"; lsthotels.valuemember = "nom"; private void listbox1_selectedindexchanged(object sender, EventArgs e)

Hotel H = ctr.getinfohotel(lsthotels.text); txtnom.text = lsthotels.text; txtadresse.text = H.Adresse; txtprix.text = H.PrixChambre.ToString(); txtprixeuro.text = (H.PrixChambre / 10).ToString(); private void clear() foreach (Control c in this.controls) if (c is TextBox) c.text = String.Empty; txtprix.clear(); txtprixeuro.clear(); private void button1_click(object sender, EventArgs e) nom=txtnom.text ; adresse=txtadresse.text; prix=txtprix.text; Form2 forme = new Form2(); frome.show() ; 5. Formulaire Réservation public Form2() InitializeComponent(); private void Form2_Load(object sender, EventArgs e) textbox1.text = Form1.nom; textbox2.text = Form1.adresse; textbox3.text = Form1.prix; Random rd = new Random(); textbox7.text = rd.next(999999999).tostring(); private void button1_click(object sender, EventArgs e) Reservation res = new Reservation(); res.numero = int.parse(textbox7.text); res.nomhotel=textbox1.text; res.datededebut =datetimepicker1.value; res.nombredechambres = int.parse(textbox9.text); res.nombredejours = int.parse(textbox10.text); res.montant = decimal.parse(textbox3.text) * decimal.parse(textbox9.text) * decimal.parse(textbox10.text); res.nom = textbox4.text; res.email = textbox5.text; res.adresse = textbox6.text; CtrlReservation ctr = new CtrlReservation(); //appel de la fonction ctr.ajouterreservation(res);

MessageBox.Show("reservation validée, montant= " + res.montant.tostring());