コード例 #1
0
        //Restore button
        private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you really want to restore data from XML? Almost all online data will be lost.", "Restore",
                                MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                LockerFactory                        lockerFactory        = new LockerFactory();
                LockerGateway <Locker>               lg                   = (LockerGateway <Locker>)lockerFactory.GetLocker();
                TrainingFactory                      trainingFactory      = new TrainingFactory();
                TrainingGateway <Training>           tg                   = (TrainingGateway <Training>)trainingFactory.GetTraining();
                PurchaseFactory                      purchaseFactory      = new PurchaseFactory();
                PurchaseGateway <Purchase>           pg                   = (PurchaseGateway <Purchase>)purchaseFactory.GetPurchase();
                TrainerFactory                       trainerFactory       = new TrainerFactory();
                TrainerGateway <Trainer>             trainerg             = (TrainerGateway <Trainer>)trainerFactory.GetTrainer();
                TrainerRatingFactory                 trainerRatingFactory = new TrainerRatingFactory();
                TrainerRatingGateway <TrainerRating> tr                   = (TrainerRatingGateway <TrainerRating>)trainerRatingFactory.GetTrainerRating();
                TicketFactory                        ticketFactory        = new TicketFactory();
                TicketGateway <Ticket>               ticketg              = (TicketGateway <Ticket>)ticketFactory.GetTicket();

                tg.Delete();
                pg.Delete();
                tr.Delete();
                trainerg.Delete();
                lg.Delete();
                ticketg.Delete();


                foreach (var locker in lg.Select())
                {
                    lg.Insert(locker);
                }

                foreach (var ticket in TicketXMLGateway <Ticket> .Instance.Select())
                {
                    TicketXMLGateway <Ticket> .Instance.Insert(ticket);
                }

                foreach (var trainer in TrainerXMLGateway <Trainer> .Instance.Select())
                {
                    TrainerXMLGateway <Trainer> .Instance.Insert(trainer);
                }

                foreach (var purchase in PurchaseXMLGateway <Purchase> .Instance.Select())
                {
                    PurchaseXMLGateway <Purchase> .Instance.Insert(purchase);
                }

                foreach (var training in TrainingXMLGateway <Training> .Instance.Select())
                {
                    TrainingXMLGateway <Training> .Instance.Insert(training);
                }

                foreach (var rating in TrainerRatingXMLGateway <TrainerRating> .Instance.Select())
                {
                    TrainerRatingXMLGateway <TrainerRating> .Instance.Insert(rating);
                }

                MessageBox.Show("Data restored!");
            }
        }
コード例 #2
0
        protected override bool DeleteRecord()
        {
            TicketFactory          ticketFactory = new TicketFactory();
            TicketGateway <Ticket> ticketg       = (TicketGateway <Ticket>)ticketFactory.GetTicket();

            ticketg.Delete(ticket.RecordId);
            return(true);
        }