internal string InsertCountryInfo( Country objCountry ) {
     int affectedRow = objCountryGateway.InsertInfo(objCountry);
     if (affectedRow > 0) {
         return "Insert Succesfull";
     }
     return "Insert Failed!!";
 }
 internal string InsertCountryInfo( Country objCountry ) {
     if (CheckCountryByName(objCountry.CountryName)) {
         return "Country Name Already exists";
     }
     int affectedRow = objCountryGateway.InsertInfo(objCountry);
     if (affectedRow > 0) {
         return "Insert Succesfull";
     }
     return "Insert Failed!!";
 }
 public List<Country> GetCountryInfo() {
     List<Country> countries = new List<Country>();
     string getCountryQuery = "SELECT CountryID, CountryName FROM Country ORDER BY CountryName";
     SqlCommand command = new SqlCommand(getCountryQuery, connection);
     connection.Open();
     SqlDataReader reader = command.ExecuteReader();
     while (reader.Read()) {
         Country country = new Country();
         country.CountryID = Convert.ToInt32(reader["CountryID"].ToString());
         country.CountryName = reader["CountryName"].ToString();
         countries.Add(country);
     }
     reader.Close();
     connection.Close();
     return countries;
 }
        internal int InsertInfo( Country objCountry ) {
            string insertQuery = "INSERT INTO  Country VALUES(@name, @about)";
            SqlCommand insertCommand = new SqlCommand(insertQuery, connection);

            insertCommand.Parameters.Clear();
            insertCommand.Parameters.Add("name", SqlDbType.NVarChar);
            insertCommand.Parameters["name"].Value = objCountry.CountryName;

            byte[] aboutBytes = Encoding.UTF8.GetBytes(objCountry.AboutCountry);
            insertCommand.Parameters.Add("about", SqlDbType.VarBinary);
            insertCommand.Parameters["about"].Value = aboutBytes;
            connection.Open();

            int affectedRow = insertCommand.ExecuteNonQuery();
            connection.Close();
            return affectedRow;
        }
        internal List<Country> GetAllInfo() {
            int countSl = 1;
            List<Country> countries = new List<Country>();
            string getAllQuery = "SELECT * FROM Country ORDER BY CountryName";
            SqlCommand getAllCommand = new SqlCommand(getAllQuery, connection);

            connection.Open();
            SqlDataReader objReader = getAllCommand.ExecuteReader();
            while (objReader.Read()) {
                Country objCountry = new Country();
                objCountry.CountryName = Convert.ToString(objReader["CountryName"]);
                byte[] objBytes = (byte[])objReader["AboutCountry"];
                objCountry.AboutCountry = Encoding.UTF8.GetString(objBytes);
                objCountry.CountrySL = countSl++;
                countries.Add(objCountry);
            }
            objReader.Close();
            connection.Close();
            return countries;
        }
 protected void saveButton_Click( object sender, EventArgs e ) {
     Country objCountry = new Country();
     double parsedValue;
     int parsedInteger;
     objCountry.CountryName = nameTextBox.Text;
     objCountry.AboutCountry = aboutTextArea.Value;
     if (objCountry.CountryName == string.Empty) {
         messageLabel.Text = "Name Field is Empty";
     }
     else if (double.TryParse(objCountry.CountryName, out parsedValue)) {
         messageLabel.Text = "Invalid Name Input!";
     }
     else if(int.TryParse(objCountry.CountryName,out parsedInteger)) {
         messageLabel.Text = "Invalid Name Input!";
     }
     else if (objCountryManager.CheckCountryByName(objCountry.CountryName)) {
         messageLabel.Text = "Country Name already Exists";
     }
     else {
         messageLabel.Text = objCountryManager.InsertCountryInfo(objCountry);
         LoadIntoGridview();
         ClearAllFields();
     }
 }
 internal int InsertInfo( Country objCountry ) {
     return 0;
 }
        public List<Country> GetAllCounty() {
            string query = "SELECT * FROM Country ORDER BY CountryName ";
            SqlCommand command = new SqlCommand(query, connection);

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

            List<Country> countryList = new List<Country>();

            while (reader.Read()) {
                Country countryObj = new Country();
                countryObj.CountryID = Convert.ToInt32(reader["CountryID"].ToString());
                countryObj.CountryName = reader["CountryName"].ToString();

                countryList.Add(countryObj);
            }
            connection.Close();
            return countryList;
        }