public Company GetStudentById(int companyId)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            string query = "SELECT * FROM company WHERE company_id = '" + companyId + "'";

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            Company company = null;

            while (reader.Read())
            {

                if (company == null)
                {
                    company = new Company();
                }
                company.CompanyId = int.Parse(reader["company_id"].ToString());
                company.Name = reader["company_name"].ToString();
                company.Address = reader["address"].ToString();

            }

            reader.Close();
            connection.Close();

            return company;
        }
        public void Delete(Company company)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            string query = "Delete from company WHERE company_id =" + company.CompanyId;

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();

            command.ExecuteNonQuery();

            connection.Close();
        }
 public void Update(Company company)
 {
     myCompanyGateway.Update(company);
     //MessageBox.Show("Update Success");
 }
 public bool Save(Company company)
 {
     return myCompanyGateway.Save(company) > 0;
 }
 public void Delete(Company company)
 {
     myCompanyGateway.Delete(company);
 }
        public int Save(Company company)
        {
            SqlConnection sqlConnection = new SqlConnection(connectionString);
            string query = "INSERT INTO company VALUES('" + company.Name + "','" + company.Address + "')";
            SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
            sqlConnection.Open();

            int rowAffected = sqlCommand.ExecuteNonQuery();

            sqlConnection.Close();

            return rowAffected;
        }
        public void Update(Company company)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            string query = "UPDATE company SET company_name = '" + company.Name + "', address= '" + company.Address + "' WHERE company_id =" + company.CompanyId;

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();

            command.ExecuteNonQuery();

            connection.Close();
        }
 public List<Company> ShowAll()
 {
     List<Company> companieslList = new List<Company>();
     SqlConnection sqlConnection = new SqlConnection(connectionString);
     string query = "SELECT * FROM company";
     SqlCommand command = new SqlCommand(query, sqlConnection);
     sqlConnection.Open();
     SqlDataReader myReader = command.ExecuteReader();
     while (myReader.Read())
     {
         Company company = new Company();
         company.CompanyId = Convert.ToInt32(myReader["company_id"].ToString());
         company.Name = myReader["company_name"].ToString();
         company.Address = myReader["address"].ToString();
         companieslList.Add(company);
     }
     return companieslList;
 }