Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            AirlineCompany company = obj as AirlineCompany;

            if (ReferenceEquals(company, null))
            {
                return(false);
            }
            return(this == company);
        }
Ejemplo n.º 2
0
        static DBConnection con = new DBConnection();// defining the conection calss
        #region IBASICDB IMPLEMENTS
        public void Add(AirlineCompany t)
        {
            SqlCommand cmd = con.GetSQLCommand();

            cmd.CommandText = $"INSERT INTO AirLineCompanies (AIRLINE_NAME,USER_NAME,PASSWORD,COUNTRY_CODE) VALUES ('{t.AirlineName}','{t.Username}','{t.Password}',{t.CountryCode});";
            cmd.ExecuteNonQuery();// inserting the company to the database
            con.close(cmd);
            SqlCommand command = con.GetSQLCommand();

            command.CommandText = $"SELECT ID FROM AirLineCompanies WHERE AIRLINE_NAME='{t.AirlineName}' ;";// defining the id of the company by taking the id from the database list
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.Default);

            while (reader.Read())
            {
                t.Id = (long)reader[0];
            }
            con.close(command);
        }
Ejemplo n.º 3
0
        public AirlineCompany Get(long id)
        {
            AirlineCompany air1 = new AirlineCompany();
            SqlCommand     cmd  = con.GetSQLCommand();

            cmd.CommandText = $"SELECT * FROM AirLineCompanies WHERE ID ={id};";
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);

            while (reader.Read() == true)
            {
                air1.Id          = (long)reader[0];
                air1.AirlineName = (string)reader[1];
                air1.Username    = (string)reader[2];
                air1.Password    = (string)reader[3];
                air1.CountryCode = (long)reader[4];
            }

            con.close(cmd);
            return(air1);
        }
Ejemplo n.º 4
0
        public IList <AirlineCompany> GetAll()
        {
            AirlineCompany air1 = new AirlineCompany();
            SqlCommand     cmd  = con.GetSQLCommand();

            cmd.CommandText = $"SELECT * FROM AirLineCompanies ;";
            SqlDataReader         reader = cmd.ExecuteReader(CommandBehavior.Default);
            List <AirlineCompany> list   = new List <AirlineCompany>();

            while (reader.Read() == true)
            {
                air1.Id          = (long)reader[0];
                air1.AirlineName = (string)reader[1];
                air1.Username    = (string)reader[2];
                air1.Password    = (string)reader[3];
                air1.CountryCode = (long)reader[4];
                list.Add(air1);
            }

            con.close(cmd);
            return(list);
        }