Ejemplo n.º 1
0
        public int PassengerCount()
        {
            string             query = "SELECT COUNT(*) FROM Passengers";
            DatabaseConnection dcc   = new DatabaseConnection();

            dcc.ConnectWithDB();
            int res = dcc.ExecuteSQL(query);

            Console.WriteLine(res);

            return(res);
        }
Ejemplo n.º 2
0
        public bool Insertcomplain(Complain c)
        {
            string query = "INSERT into Complains VALUES ('" + c.CId + "', '" + c.Csub + "', '" + c.Cbody + "','" + c.CuserId + "')";

            try
            {
                dcc.ConnectWithDB();
                int n = dcc.ExecuteSQL(query);
                dcc.CloseConnection();
                return(true);
            }
            catch (Exception exp)
            {
                return(false);
            }
        }
 public bool Insert(BookedSeats b)
 {
     try
     {
         string             query = "INSERT into BookedSeats VALUES (" + b.FlightId + ", " + b.BookTicketId + " , '" + b.Seats + "')";
         DatabaseConnection dcc   = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
 public bool Update(Flight f)
 {
     try
     {
         string             query = "UPDATE Flight SET AirlineName = '" + f.AirlineName + "', Source = '" + f.Source + "', Destination = '" + f.Destination + "',  Arrival = '" + f.Arrival + "', Departure = '" + f.Departure + "', Cost = " + f.Cost + " WHERE FlightID = '" + f.FlightId + "'";
         DatabaseConnection dcc   = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e + "error database");
         return(false);
     }
 }
Ejemplo n.º 5
0
 public bool Insert(AllUsers a)
 {
     try
     {
         string             query = "INSERT into UserInfo VALUES ('" + a.UserId + "', '" + a.UserType + "', '" + a.UserName + "')";
         DatabaseConnection dcc   = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
Ejemplo n.º 6
0
 public bool Insert(Airplane air)
 {
     try
     {
         string             query = "INSERT into Airplane VALUES ('" + air.AirplaneId + "', '" + air.AirplaneName + "', " + air.Capacity + ")";
         DatabaseConnection dcc   = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
 public bool Insert(BookTicket bTicket)
 {
     try
     {
         string             query = "INSERT into BookTicket VALUES ( " + bTicket.BookTicketId + ", " + bTicket.PassengerId + ", " + bTicket.FlightId + " , '" + bTicket.PassengerFullName + "', '" + bTicket.PassengerUsername + "', '" + bTicket.Airplane + "', '" + bTicket.Source + "', '" + bTicket.Destination + "', '" + bTicket.Departure + "', " + bTicket.Cost + " , '" + bTicket.Seats + "')";
         DatabaseConnection dcc   = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
 public bool Insert(Airport airport)
 {
     try
     {
         string query = "INSERT into Airport VALUES (" + airport.AirportId + ", '" + airport.AirportName + "', '" +
                        airport.City + "')";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
 public bool Update(Airport airport)
 {
     try
     {
         string query = "UPDATE Airport SET Name = '" + airport.AirportName + "', City = '" +
                        airport.City + "' WHERE AirportId = " + airport.AirportId + "";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }
        public bool CancelTicketByPassenger(int pId, int bId)
        {
            try
            {
                string             query = "DELETE from BookTicket WHERE PassengerId  = " + pId + " AND BTId = " + bId + "";
                DatabaseConnection dcc   = new DatabaseConnection();
                dcc.ConnectWithDB();
                int x = dcc.ExecuteSQL(query);

                dcc.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
        }
Ejemplo n.º 11
0
        public bool Delete(int employeeId)
        {
            try
            {
                string             query = "DELETE From Employee WHERE EmployeeId = " + employeeId + " ";
                DatabaseConnection dcc   = new DatabaseConnection();
                dcc.ConnectWithDB();
                int x = dcc.ExecuteSQL(query);

                dcc.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
        }
        /*public bool Update(Bookticket bt)
         * {
         *
         *  try
         *  {
         *      string query = "UPDATE Airplane SET Source = '" + bt.Source + "', Destination = '" + bt.Destination + "', Departure = '" + bt.Departure
         + "', Arrival = '" + bt.Arrival + "', Airplane = '" + bt.Airplane + "', '" + bTicket.Seats + "', " + bTicket.Cost + "'";
         +      DatabaseConnection dcc = new DatabaseConnection();
         +      dcc.ConnectWithDB();
         +      int x = dcc.ExecuteSQL(query);
         +      dcc.CloseConnection();
         +      return true;
         +  }
         +  catch (Exception ex)
         +  {
         +      Console.WriteLine(ex);
         +      return false;
         +  }
         + }*/

        public bool Delete(string ticketId)
        {
            try
            {
                string             query = "DELETE From BookTicket WHERE BookTicketId = '" + ticketId + "' ";
                DatabaseConnection dcc   = new DatabaseConnection();
                dcc.ConnectWithDB();
                int x = dcc.ExecuteSQL(query);

                dcc.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
        }
Ejemplo n.º 13
0
 public bool Update(AllUsers a)
 {
     try
     {
         string query = "UPDATE UserInfo SET UserType = '" + a.UserType
                        + "', UserName = '******' WHERE UserId = '" + a.UserId + "'";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }
Ejemplo n.º 14
0
 public bool Update(Airplane air)
 {
     try
     {
         string query = "UPDATE Airplane SET AirplaneName = '" + air.AirplaneName
                        + "', Capacity = " + air.Capacity + " WHERE AirplaneId = '" + air.AirplaneId + "'";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }
 public bool Insert(Flight f)
 {
     //string query2 = "INSERT into Flight VALUES ('" + f.FlightId + "', '" + f.AirlineName + "', '" + f.Source + "', '" + f.Destination + "', '" + f.Arrival + "', '" + f.Departure + "', " + f.Cost + ")";
     try
     {
         string             query = "INSERT into Flight VALUES ('" + f.FlightId + "', '" + f.AirlineName + "', '" + f.Source + "', '" + f.Destination + "', '" + f.Arrival + "', '" + f.Departure + "', " + f.Cost + ")";
         DatabaseConnection dcc   = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e + "error database");
         //Console.WriteLine(query2);
         return(false);
     }
 }
Ejemplo n.º 16
0
 public bool Insert(Employee e)
 {
     try
     {
         string query = "INSERT into Employee VALUES ( " + e.EmployeeID + ", '" + e.Name + "', '" +
                        e.Username + "','" + e.Email + "', '" + e.Password + "', '" + e.Gender +
                        "', " + e.Age + ", '" + e.Address + "','" + e.Question + "')";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }
Ejemplo n.º 17
0
 public bool Update(Employee e)
 {
     try
     {
         string query = "UPDATE Employee SET Name = '" + e.Name + "', Username = '******', Email = '" + e.Email + "', Password = '******', Gender = '" + e.Gender + "', Age = " + e.Age + ", Address = '"
                        + e.Address + "', Question = '" + e.Question + "' WHERE EmployeeId = " + e.EmployeeID + "";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }
Ejemplo n.º 18
0
 public bool Insert(Admin a)
 {
     try
     {
         string query = "INSERT into Admin VALUES ('" + a.AdminId + "', '" + a.Name + "', '" +
                        a.Username + "','" + a.Email + "', '" + a.Password + "', '" + a.Gender +
                        "'," + a.Age + ", '" + a.Address + "','" + a.Question + "')";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         Console.WriteLine("x= " + x);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
 public bool Update(Passenger pass)
 {
     try
     {
         string query = "UPDATE Passengers SET Name = '" + pass.Pname + "', UserName = '******', Email = '" + pass.Pemail + "', Password = '******', Gender = '" + pass.Pgender +
                        "', Age = " + pass.Page + ", Address = '" + pass.Paddress
                        + "', Question = '" + pass.Pquestion + "' WHERE PassengerId = '" + pass.PassengerId + "'";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }
 public bool Insert(Passenger p)
 {
     try
     {
         string query = "INSERT into Passengers VALUES ('" + p.PassengerId + "', '" + p.Pname + "', '" +
                        p.Pusername + "','" + p.Pemail + "', '" + p.Ppassword + "', '" + p.Pgender +
                        "', " + p.Page + ", '" + p.Paddress + "', '" + p.Pquestion + "')";
         DatabaseConnection dcc = new DatabaseConnection();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         Console.WriteLine("x= " + x);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }