private void saveButton_Click(object sender, EventArgs e) { int error = 0; aErrorProvider.Clear(); if (countryNameTextBox.Text == "") { error++; aErrorProvider.SetError(countryNameTextBox, "Requred"); } if (error > 0) { return; } DAL.Country aCountry = new DAL.Country(); aCountry.Name = countryNameTextBox.Text; if (aCountry.Insert()) { MessageBox.Show("Data Saved"); countryNameTextBox.Text = ""; countryNameTextBox.Focus(); } else { MessageBox.Show(aCountry.Error); } }
private void formCity_Load(object sender, EventArgs e) { DAL.Country aCountry = new DAL.Country(); countryNameComboBox.DataSource = aCountry.Select().Tables[0]; countryNameComboBox.DisplayMember = "Name"; countryNameComboBox.ValueMember = "id"; countryNameComboBox.SelectedValue = -1; }