Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //Establish a connection with DBConnect class to access patron table
            DBConnect db = new DBConnect();
            Address myAddress = new Address();
            PreviousVisit pVisit = new PreviousVisit();
            Patron myPatron = new Patron(2, "Joe", "Bloggs", "S", "5550134", myAddress,pVisit);

            //holds quiried data. First element will contain cells of first column from table. Second element contains second column and so on....
            List<Patron> list = new List<Patron>();

            list = db.SelectPatron("SELECT * FROM patron WHERE firstName = 'Rob'");
            for (int x = 0; x < list.Count; x++)
            {
                Console.WriteLine(list[x].Id);
                Console.WriteLine(list[x].FirstName);
                Console.WriteLine(list[x].LastName);
                Console.WriteLine(list[x].MiddleInitial);
                Console.WriteLine(list[x].Phone);
                Console.WriteLine(list[x].StreetNum);
                Console.WriteLine(list[x].AddressLine1);
                Console.WriteLine(list[x].AddressLine2);
                Console.WriteLine(list[x].City);
                Console.WriteLine(list[x].State);
                Console.WriteLine(list[x].Zip);
                Console.WriteLine(list[x].NumChildren);
                Console.WriteLine(list[x].NumAdults);
                Console.WriteLine(list[x].Date.Month+"/"+list[x].Date.Day+"/"+list[x].Date.Year);
                Console.WriteLine(" ");
            }

            /*list = db.SelectPatron("SELECT * FROM patron WHERE firstName = 'Rob'");
            foreach (var i in list)
            {
                Console.WriteLine(i);
            }
            for (int x = 0; x < list.Length; x++)
            {
                for(int y=0;y<list[x].Count;y++){
                    Console.WriteLine(list[x].ElementAt(y));
                }
            }*/
            //db.Query("INSERT INTO patron (patron_id, firstName, lastName, middleInitial, phone) VALUES ('10', 'Tom', 'Maey', 'ff', '2353744')");

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public Form1()
        {
            /*
             * dataGridView2
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllFirstName;
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllLastName;
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllMiddleInitial;
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllAddressLine1;
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllAddressLine2;
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllPhone;
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllAdults;
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllChildren;
            private System.Windows.Forms.DataGridViewTextBoxColumn viewAllPrevVisit;
            */

            InitializeComponent();
            DBConnect db = new DBConnect();

            int count = db.Count("SELECT * FROM patron");

            String[] rows = new String[count];

            List<Patron> list = new List<Patron>();
            list = db.SelectPatron("SELECT * FROM patron");

            for (int x = 0; x < list.Count; x++)
            {
                String date = list[x].Date.Month + "/" + list[x].Date.Day + "/" + list[x].Date.Year;
                String children = "";
                children += list[x].NumChildren;
                String adults = "";
                adults += list[x].NumAdults;
                string[] row = { list[x].FirstName, list[x].LastName, list[x].MiddleInitial, list[x].AddressLine1, list[x].AddressLine2, list[x].Phone, children, adults, date };
                dataGridView2.Rows.Add(row);
            }
        }