private void lastButton_Click(object sender, EventArgs e) { //Populates all text boxes, check box and data time picker with last record and also updates text box txtOrder to current position. CarsBindingSource.MoveLast(); updatePosition(); }
private void addButton_Click(object sender, EventArgs e) { try { //Adding a new row. //Populating column VehicleRegNo because it can't be empty, and column Available with 0 (False) because it's by default set to True. DataRow row = hireDataSet1.tblCar.NewRow(); row["VehicleRegNo"] = "Regis"; row["Available "] = 0; hireDataSet1.tblCar.Rows.Add(row); //Row is added to last place, so this is going to show that record. CarsBindingSource.MoveLast(); updatePosition(); } //If there is already row with the same value for column VehicleRegNo this message appear on screen. //Column VehicleRegNo is a primary key and it must be unique. catch (ConstraintException) { MessageBox.Show("Vehicle Registration Number 'Regis' already exist"); } }
private void cancelButton_Click(object sender, EventArgs e) { //Cancels all changes. hireDataSet1.RejectChanges(); CarsBindingSource.ResetBindings(false); updatePosition(); }