public ActionResult Create(footballer footballer)
        {
            if (ModelState.IsValid)
            {
                var dao       = new footballer_dao();
                var info_rule = new general_rule_dao().GetRule();

                int result = dao.Insert(footballer);
                if (result == 1)
                {
                    SetAlert(StaticResources.Resources.Pub_InsertSuccess, "success");
                    return(RedirectToAction("Index", "Footballer", new { club_id = footballer.footballClub_id }));
                }
                else if (result == -2)
                {
                    ModelState.AddModelError("", "Tuổi không hợp lệ (" + info_rule.min_age + " -> " + info_rule.max_age + ")");
                }
                else if (result == -3)
                {
                    ModelState.AddModelError("", "Số lượng cầu thủ trong đội đã đủ (" + info_rule.max_footballer + ")");
                }
                else if (result == -4)
                {
                    ModelState.AddModelError("", "Số lượng cầu thủ ngoại trong đội đã đủ (" + info_rule.max_foreign_footballer + ")");
                }
                else
                {
                    ModelState.AddModelError("", StaticResources.Resources.InsertFootballerFailed);
                }
            }
            SetListFootballClub(footballer.footballClub_id);
            SetListFootballerType(footballer.footballer_type_id);
            return(View());
        }
        /// <summary>
        /// return 1(success),return -1(error-insert),return -2(error-age),
        /// return -3(club have enough foreign footballer)
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(footballer entity)
        {
            try
            {
                // check age in accordance with the regulations
                var info_rule      = db.general_rule.FirstOrDefault();
                var age_footballer = DateTime.Now.Year - entity.birth_date.Value.Year;
                var num_foreignFootballer_in_club = new football_club_dao().CountAllForeignFootballerInclub(entity.footballClub_id);

                if (age_footballer < info_rule.min_age || age_footballer > info_rule.max_footballer)
                {
                    return(-2);
                }
                else if (entity.footballer_type_id == "FOREIGN" && num_foreignFootballer_in_club >= info_rule.max_foreign_footballer)
                {
                    return(-3);
                }

                var info = db.footballers.Find(entity.id);
                info.name               = entity.name;
                info.birth_date         = entity.birth_date;
                info.hometown           = entity.hometown;
                info.position           = entity.position;
                info.footballer_type_id = entity.footballer_type_id;
                info.footballClub_id    = entity.footballClub_id;
                db.SaveChanges();
                return(1);
            }
            catch (Exception)
            {
                return(-1);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            footballer f            = new footballer();
            int        birth_Year   = int.Parse(txtBoxBirthYear.Text);
            int        age          = f.ageCalculate(birth_Year);
            var        gender       = "";
            var        country      = "";
            var        current_club = "";

            if (ddlForCurrentClub.SelectedItem != null)
            {
                current_club = current_club + ddlForCurrentClub.SelectedItem.ToString();
            }
            if (rdoButtonForMale.Checked)
            {
                gender = gender + rdoButtonForMale.Text.ToString();
            }
            if (rdoButtonForFemale.Checked)
            {
                gender = gender + rdoButtonForFemale.Text.ToString();
            }
            if (ddlCountryList.SelectedItem != null)
            {
                country = country + ddlCountryList.SelectedItem.ToString();
            }
            else
            {
                MessageBox.Show("Please select one catagory");
            }
            table.Rows.Add(txtBoxForPlayerName.Text, current_club.ToString(), txtBoxForShirtNumber.Text, txtBoxForNickName.Text, gender.ToString(), country.ToString(), birth_Year.ToString(), age.ToString(), txtBoxForHeight.Text, txtBoxForWeight.Text
                           );
            dataGridViewAdd.DataSource = table;
        }