private void btn_Save_Click(object sender, EventArgs e) { if (CheckForm()) { Product product = FormToProduct(); ProductArr productArr = new ProductArr(); productArr.Fill(); if (product.Id == 0) { if (!productArr.IsContainLicenseNumber(txt_LicenseNumber.Text)) { if (product.Insert()) { MessageBox.Show("Data saved successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); productArr.Fill(); product = productArr.GetProductWithMaxId(); ProductArrToForm(product); } } else { MessageBox.Show("License Number already exsits", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (product.Update()) { MessageBox.Show("Data updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); ProductArrToForm(null); } } } }