private void btnSave_Click(object sender, EventArgs e) { string VehicleNo = txtVehicleNo.Text.Trim(); bool CheckVehicleNo = db.CheckVehicleNo(VehicleNo); if (CheckVehicleNo == true) { MessageBox.Show("This Vehicle No already added to Vehicle List"); } else { Vehicle Vehi = new Vehicle { vehicle_no = txtVehicleNo.Text.Trim(), brand = txtBrand.Text.Trim(), model = txtModel.Text.Trim(), type = txtType.Text.Trim(), current_mileage = Convert.ToInt32(txtCurrentMileage.Text), service_mileage_due = Convert.ToInt32(txtServiceMileageDue.Text), owner = txtOwnerName.Text.Trim(), added_date = dtpAddedDate.Value }; db.InsertVehicle(Collection, Vehi); ClearText(); LoadForm(); } }