Example #1
0
        public List <RTicket> GetAllTicket()
        {
            string         query = "SELECT * from Ticket";
            List <RTicket> tList = new List <RTicket>();

            DatabaseConnectionClass dcc = new DatabaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                RTicket t = new RTicket();
                t.Ticketid     = sdr["Ticketid"].ToString();
                t.Journeydate  = sdr["Journeydate"].ToString();
                t.Tranid       = sdr["Trainid"].ToString();
                t.SeatClassid  = sdr["SeatClassid"].ToString();
                t.Passsengerid = sdr["Passsengerid"].ToString();
                t.Seatno       = sdr["Seatno"].ToString();
                t.Price        = Convert.ToDouble(sdr["Price"]);;

                tList.Add(t);
            }
            dcc.CloseConnection();
            return(tList);
        }
Example #2
0
        public bool TicketSell(RTicket t)
        {
            try
            {
                string query = "INSERT into Ticket VALUES ('" + t.Ticketid + "', '" + t.Journeydate + "', '" + t.Tranid + "', '" + t.SeatClassid + "', '" + t.Passsengerid + "', '" + t.Seatno + "', " + t.Price + ")";

                DatabaseConnectionClass dcc = new DatabaseConnectionClass();
                dcc.ConnectWithDB();
                int x = dcc.ExecuteSQL(query);

                dcc.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }