예제 #1
0
        public static List <ClientObs> GetList()
        {
            List <ClientObs> listeClient = new List <ClientObs>();
            SqlConnection    oConn       = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\marilou\Documents\mdsb3.mdf;Integrated Security=True;Connect Timeout=30");

            oConn.Open();

            SqlCommand oCmd = oConn.CreateCommand();

            oCmd.CommandText = "SELECT * FROM CLIENT";

            // notre objet contient le resultat de la req
            SqlDataReader oReader = oCmd.ExecuteReader();

            while (oReader.Read())
            {
                var client = ClientObs.CreateObject(TypeClient.NORMAL);
                client.Id   = Convert.ToInt32(oReader["Id"]);
                client.Name = Convert.ToString(oReader["NOM"]);
                //client.Type = Convert.ToString(oReader["TYPE"]);
                client.MtEncours = Convert.ToInt32(oReader["MtEnCours"]);
                listeClient.Add(client);
            }

            oReader.Close();
            oConn.Close();

            return(listeClient);
        }
예제 #2
0
        public static ClientObs CreateObject(TypeClient type)
        {
            ClientObs obj = null;

            switch (type)
            {
            case TypeClient.NORMAL:
                obj = new ClientNormal();
                break;

            case TypeClient.PREMIUM:
                obj = new ClientPremium();
                break;

            case TypeClient.ASURVEILLER:
                obj = new ClientAsurveiller();
                break;

            default:
                break;
            }

            return(obj);
        }
예제 #3
0
        public void Notifier(Observable obj)
        {
            ClientObs client = (ClientObs)obj;

            Console.WriteLine("calcul de {0} à {1}", client.Name, DateTime.Now);
        }