コード例 #1
0
        public void save(object sender, EventArgs e)
        {
            AirlineEmployee oldticket = AirlineEmployee.Copy((AirlineEmployee)o);

            oldObject = oldticket;
            ((AirlineEmployee)o).firstName = controls[0].Text;
            ((AirlineEmployee)o).lastName  = controls[1].Text;
            ((AirlineEmployee)o).airline   = (Airline)(((ComboBox)(controls[2])).SelectedItem);
            ((Form)((Button)sender).Parent).Close();
        }
コード例 #2
0
        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;
        }