public void firstInitialize() { ClientFactory clientFactory = new ClientFactory(); ClientGateway <Client> cg = (ClientGateway <Client>)clientFactory.GetClient(); TrainingFactory trainingFactory = new TrainingFactory(); TrainingGateway <Training> tg = (TrainingGateway <Training>)trainingFactory.GetTraining(); DiscountFactory discountFactory = new DiscountFactory(); DiscountGateway <DiscountCard> dg = (DiscountGateway <DiscountCard>)discountFactory.GetCard(); PurchaseFactory purchaseFactory = new PurchaseFactory(); PurchaseGateway <Purchase> pg = (PurchaseGateway <Purchase>)purchaseFactory.GetPurchase(); TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); Client client = cg.Select(tg.SelectLast().ClientId); clientName.Text = client.ToString(); if (client.CardId != null) { int toSetId = client.CardId ?? default(int); card = dg.Select(toSetId); } Ticket t = ticketg.Select(pg.SelectLast(card.RecordId).TicketId); ticketType.Text = t.Type; credit.Text = card.Credit.ToString(); }
protected override void RefreshData() { TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); Collection <Ticket> tickets = ticketg.Select(); BindingList <Ticket> bindingList = new BindingList <Ticket>(tickets); ticketsGrid.AutoGenerateColumns = false; ticketsGrid.DataSource = bindingList; }
public override bool OpenRecord(object primaryKey) { TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); if (primaryKey != null) { int idTicket = (int)primaryKey; ticket = ticketg.Select(idTicket); newRecord = false; } else { ticket = new Ticket(); newRecord = true; } BindData(); return(true); }
private void backupToolStripMenuItem1_Click(object sender, EventArgs e) { LockerFactory lockerFactory = new LockerFactory(); LockerXMLGateway <Locker> lg = (LockerXMLGateway <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(); // Backup button XDocument xDoc = new XDocument(); XElement xRoot = new XElement("Database"); ClientFactory clientFactory = new ClientFactory(); ClientGateway <Client> cg = (ClientGateway <Client>)clientFactory.GetClient(); Collection <Client> clients = cg.Select(); XElement xClients = new XElement("Clients"); foreach (var client in clients) { xClients.Add(ClientXMLGateway <Client> .Instance.Insert(client)); } DiscountFactory discountFactory = new DiscountFactory(); DiscountGateway <DiscountCard> dg = (DiscountGateway <DiscountCard>)discountFactory.GetCard(); Collection <DiscountCard> cards = dg.Select(); XElement xCards = new XElement("Cards"); foreach (var card in cards) { xCards.Add(DiscountXMLGateway <DiscountCard> .Instance.Insert(card)); } Collection <Locker> lockers = lg.Select(); XElement xLockers = new XElement("Lockers"); foreach (var locker in lockers) { xLockers.Add(LockerXMLGateway <Locker> .Instance.Insert(locker)); } Collection <Purchase> purchases = pg.Select(); XElement xPurchases = new XElement("Purchases"); foreach (var purchase in purchases) { xPurchases.Add(PurchaseXMLGateway <Purchase> .Instance.Insert(purchase)); } Collection <Ticket> tickets = ticketg.Select(); XElement xTickets = new XElement("Tickets"); foreach (var ticket in tickets) { xTickets.Add(TicketXMLGateway <Ticket> .Instance.Insert(ticket)); } Collection <TrainerRating> ratings = tr.Select(); XElement xRatings = new XElement("TrainerRatings"); foreach (var rating in ratings) { xRatings.Add(TrainerRatingXMLGateway <TrainerRating> .Instance.Insert(rating)); } Collection <Trainer> trainers = trainerg.Select(); XElement xTrainers = new XElement("Trainers"); foreach (var trainer in trainers) { xTrainers.Add(TrainerXMLGateway <Trainer> .Instance.Insert(trainer)); } Collection <Training> trainings = tg.Select(); XElement xTrainings = new XElement("Trainings"); foreach (var training in trainings) { xTrainings.Add(TrainingXMLGateway <Training> .Instance.Insert(training)); } xRoot.Add(xClients); xRoot.Add(xCards); xRoot.Add(xLockers); xRoot.Add(xPurchases); xRoot.Add(xTickets); xRoot.Add(xRatings); xRoot.Add(xTrainers); xRoot.Add(xTrainings); xDoc.Add(xRoot); if (!Directory.Exists(Connective.Backup.Paths.FolderPath)) { Directory.CreateDirectory(Connective.Backup.Paths.FolderPath); } using (StreamWriter sw = new StreamWriter(Connective.Backup.Paths.FilePath)) { sw.Write(xDoc.ToString()); } MessageBox.Show("Backed up!"); }