public DALUnitOfWork() { vygCtx = new VoyageContext(); BusExpeditionPocos = new BusExpeditionRepo(vygCtx); BusPocos = new BusRepo(vygCtx); BusTypePocos = new BusTypeRepo(vygCtx); DriverPocos = new DriverRepo(vygCtx); HostPocos = new HostRepo(vygCtx); PersonPocos = new PersonRepo(vygCtx); RoutePocos = new RouteRepo(vygCtx); SeatInformationPocos = new SeatInformationRepo(vygCtx); TicketPocos = new TicketRepo(vygCtx); }
private void cboTo_SelectedIndexChanged(object sender, EventArgs e) { try { string[] bustypes = BusTypeRepo.GetBusTypeByRoute(this.cboFrom.Text, this.cboTo.Text); this.cmbBusType.Items.Clear(); foreach (string s in bustypes) { this.cmbBusType.Items.Add(s); } } catch { MessageBox.Show("Unable to find bus type!"); } }
private void btnSave_Click(object sender, EventArgs e) { int busIdExist = BusRepo.SearchBusId(this.rtxtPhn.ToString()); if (this.invisibleBusNoText.Text != "") //this is for update purpose { //string busNumber = this.Bus.BusNo; if (!UpdateFillEntity()) { return; } else { UpdateFillEntity(); if (this.Bus.TypeId == "Non AC") { this.Bus.TypeId = "NON-AC"; } this.Bus.TypeId = BusTypeRepo.GetBusTypeForBus(this.Bus.TypeId); bool updateSignal = BusRepo.Update(this.Bus, this.invisibleBusNoText.Text); if (updateSignal) { MessageBox.Show("Bus Updated Successuflly!!"); ClearBusInput(); this.invisibleBusNoText.Text = ""; this.FillBusDataGridView(); } } } else //this is for insert purpose { if (!FillEntity()) { return; } else if (FillEntity()) { int checkBusNumberExist = BusRepo.CheckBusNumber(this.Bus.BusNo); if (checkBusNumberExist == 1) { MessageBox.Show("The Bus Number already Exists. Create a New One!"); } else { if (this.Bus.TypeId == "Non AC") { this.Bus.TypeId = "NON-AC"; } this.Bus.TypeId = BusTypeRepo.GetBusTypeForBus(this.Bus.TypeId); bool insertSignal = BusRepo.Insert(this.Bus); if (insertSignal) { MessageBox.Show("Bus Created Successuflly!!"); ClearBusInput(); this.FillBusDataGridView(); } } } } }