public Category getValuesAsCategory(CategoryFilter cf) { string text = this.textBoxTitle.Text; List <Participant> participants = new List <Participant>(); foreach (DataGridViewRow row in (IEnumerable)this.dataGridViewParticipants.Rows) { if (row.Cells["FullName"].Value != null && row.Cells["Team"].Value != null) { int id = 0; if (row.Cells["id"].Value != null) { id = Convert.ToInt32(row.Cells["id"].Value.ToString()); } string name = row.Cells["FullName"].Value.ToString(); string team = row.Cells["Team"].Value.ToString(); Participant participant = new Participant(); participant.setName(name); participant.setTeam(team); if (id > 0) { participant.setId(id); } participants.Add(participant); } } return(new Category(text, participants, cf)); }
public Team getValuesAsTeam() { List <Participant> participants = new List <Participant>(); foreach (DataGridViewRow row in (IEnumerable)this.dataGridViewParticipants.Rows) { if (row.Cells["FullName"].Value != null) { int id = 0; string name = ""; int age = 0; double weight = 0.0; string sex = ""; int ku = 0; List <CategoryType> categories = new List <CategoryType>(); if (row.Cells["id"].Value != null) { id = Convert.ToInt32(row.Cells["Id"].Value.ToString()); } if (row.Cells["FullName"].Value != null) { try { name = row.Cells["FullName"].Value.ToString(); } catch (Exception ex) { } } if (row.Cells["Age"].Value != null) { try { age = Convert.ToInt32(row.Cells["Age"].Value.ToString()); } catch (Exception ex) { } } if (row.Cells["Weight"].Value != null) { try { weight = Convert.ToDouble(row.Cells["Weight"].Value.ToString()); } catch (Exception ex) { } } if (row.Cells["Sex"].Value != null) { try { sex = row.Cells["Sex"].Value.ToString(); if (sex.Length == 0) { sex = "M"; } } catch (Exception ex) { } } else { sex = "M"; } if (row.Cells["Ku"].Value != null) { try { ku = Convert.ToInt32(row.Cells["Ku"].Value.ToString()); } catch (Exception ex) { } } if (row.Cells["Kata"].Value != null && Convert.ToBoolean(row.Cells["Kata"].Value.ToString())) { categories.Add(CategoryType.Kata); } if (row.Cells["Kumite"].Value != null && Convert.ToBoolean(row.Cells["Kumite"].Value.ToString())) { categories.Add(CategoryType.Kumite); } if (row.Cells["Fukugo"].Value != null && Convert.ToBoolean(row.Cells["Fukugo"].Value.ToString())) { categories.Add(CategoryType.Fukugo); } if (row.Cells["Irigumi"].Value != null && Convert.ToBoolean(row.Cells["Irigumi"].Value.ToString())) { categories.Add(CategoryType.Irigumi); } Participant participant = new Participant(name, age, weight, sex, ku, categories); if (id != 0) { participant.setId(id); } participants.Add(participant); } } return(new Team(this.textBoxTitle.Text, participants)); }