private void btn_Save_Click(object sender, EventArgs e) { if (CheckForm()) { ColorType colorType = new ColorType(); colorType = FormToColorTypes(); ColorTypeArr oldColorTypesArr = new ColorTypeArr(); oldColorTypesArr.Fill(); if (!oldColorTypesArr.IsContain(colorType.Name)) { if (colorType.Id == 0) { if (colorType.Insert()) { MessageBox.Show("Data saved successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); ColorTypeArr colorTypes = new ColorTypeArr(); colorTypes.Fill(); colorType = colorTypes.GetColorTypesWithMaxId(); ColorTypesArrToForm(colorType); } } else { if (colorType.Update()) { MessageBox.Show("Data updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); ColorTypeArr carColorArr = new ColorTypeArr(); carColorArr.Fill(); colorType = carColorArr.GetColorTypesWithMaxId(); ColorTypesArrToForm(null); } } } else { MessageBox.Show("Color Type already exsits", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ClearForm(); } } }