private bool checkNewCountry() { // creating of a new address // check possible address if (!r.IsMatch(cbCountry.Text)) { if (!cbCountry.Text.Contains(" ")) { if (cbCountry.Text.Length > 50) { MessageBox.Show("Incorect address!"); return(false); } } } // check on a unique List <country> all = new List <country>(); all.AddRange(db.countries); all = all.FindAll ( delegate(country c) { return(c.code.Equals(cbCountry.Text)); } ); if (all.Count == 0) { // create a new address country c = new country(); c.code = cbCountry.Text; c = countryCrud.create(c); conferenceDTO.country = c.countryId; newCountry = true; } else { newCountry = false; } return(true); }
private void addButton_Click(object sender, EventArgs e) { if (validateData(countryTb.Text)) { country c = new country(); c.code = countryTb.Text; if (crud.create(c) != null) { MessageBox.Show("Country was added!"); this.Close(); } else { MessageBox.Show("Country alredy exists!!!"); } } }
private void checkNewCountry() { if (!r.IsMatch(cbCountry.Text)) { if (!cbCountry.Text.Contains(" ")) { if (cbCountry.Text.Length > 50) { MessageBox.Show("Incorect address!"); return; } } } // check on a unique List <country> all = new List <country>(); all.AddRange(db.countries); all = all.FindAll ( delegate(country c) { return(c.code.Equals(cbCountry.Text)); } ); if (all.Count == 0) { country c = new country(); c.code = cbCountry.Text; c = countryCrud.create(c); dto.country = c.countryId; } }