public void save(object sender, EventArgs e) { Airport oldticket = Airport.Copy((Airport)o); oldObject = oldticket; ((Airport)o).name = ((TextBox)controls[0]).Text; ((Airport)o).city = ((TextBox)controls[1]).Text; ((Form)((Button)sender).Parent).Close(); }
public Command(object oldObject, object newObject, Receiver receiver) { string oldObjectTypeName = oldObject.GetType().Name; string newObjectTypeName = newObject.GetType().Name; //check the class of the object if (oldObjectTypeName == "Airline") { // take a copy of the object before and after being updated this.oldObject = Airline.Copy((Airline)oldObject); this.newObject = Airline.Copy((Airline)newObject); } else if (oldObjectTypeName == "AirlineEmployee") { this.oldObject = AirlineEmployee.Copy((AirlineEmployee)oldObject); this.newObject = AirlineEmployee.Copy((AirlineEmployee)newObject); } else if (oldObjectTypeName == "Airplane") { this.oldObject = Airplane.Copy((Airplane)oldObject); this.newObject = Airplane.Copy((Airplane)newObject); } else if (oldObjectTypeName == "Airport") { this.oldObject = Airport.Copy((Airport)oldObject); this.newObject = Airport.Copy((Airport)newObject); } else if (oldObjectTypeName == "BookingAgent") { this.oldObject = BookingAgent.Copy((BookingAgent)oldObject); this.newObject = BookingAgent.Copy((BookingAgent)newObject); } else if (oldObjectTypeName == "Customer") { this.oldObject = Customer.Copy((Customer)oldObject); this.newObject = Customer.Copy((Customer)newObject); } else if (oldObjectTypeName == "Flight") { this.oldObject = Flight.Copy((Flight)oldObject); this.newObject = Flight.Copy((Flight)newObject); } else if (oldObjectTypeName == "Ticket") { this.oldObject = Ticket.Copy((Ticket)oldObject); this.newObject = Ticket.Copy((Ticket)newObject); } this.receiver = receiver; }