private void btn_Save_Click(object sender, EventArgs e) { if (CheckForm()) { Street street = new Street(); street = FormToStreet(); StreetArr oldStreetArr = new StreetArr(); oldStreetArr.Fill(); if (!oldStreetArr.IsContain(street.Name)) { if (street.Id == 0) { if (street.Insert()) { MessageBox.Show("Data saved successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); StreetArr streetArr = new StreetArr(); streetArr.Fill(); street = streetArr.GetStreetWithMaxId(); StreetArrToForm(street); } } else { if (street.Update()) { MessageBox.Show("Data updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); StreetArr streetArr = new StreetArr(); streetArr.Fill(); street = streetArr.GetStreetWithMaxId(); StreetArrToForm(street); } } } else { MessageBox.Show("Street already exsits", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ClearForm(); } } }