//public int a { get; set; } private void ConfirmBtn_Click(object sender, EventArgs e) { if (NameTb.Text != "" && PhoneNumberTb.Text != "" && seatlist.Count != 0) { Bus b = new Bus(); b = br.GetBus(tablebusid, tablebusname, tabledate, tabletime, tableavailableseats, tablefare); Customer c = new Customer(); c.Name = NameTb.Text; try { int phn = Convert.ToInt32(PhoneNumberTb.Text); c.PhoneNumber = phn + ""; } catch (Exception exp) { MessageBox.Show("invalid phone number"); } c.From = b.From; c.To = b.To; c.BusId = b.BusId; c.Date = b.Date; c.Time = b.Time; c.Type = b.Type; c.Fare = b.Fare * count; foreach (string item in seatlist) { s = s + item + ","; } c.SeatNumber = s; if (cr.InsertCustomer(c)) { MessageBox.Show("seat booked. THANK YOU!"); } else { MessageBox.Show("Can Not Book: " + c.Name); } for (int i = 0; i < seatlist.Count; i++) { br.UpdateSeat(b, seatlist[i]); } b.NumberOfSeats = b.NumberOfSeats - count; br.UpdateNumberSeat(b); PrintTicket p = new PrintTicket(c); p.Visible = true; this.Visible = false; } else { MessageBox.Show("Please fillup Name, Phone number and Seats"); } }
private void DeleteBtn_Click(object sender, EventArgs e) { Customer cm = new Customer(); cm.Name = this.CustomerNameTb.Text; cm.PhoneNumber = this.PhoneTB.Text; cm.From = tablefrom; cm.To = tableto; cm.BusId = tablebusid; cm.Date = tabledate; cm.Time = tabletime; cm.Type = tabletype; cm.SeatNumber = tableseatnumber; cm.Fare = Convert.ToInt32(tablefare); string [] seatnumbers = tableseatnumber.Split(','); if (cr.DeleteCustomer(cm)) { MessageBox.Show("Deleted"); this.ShowAllBtn_Click(sender, e); int i = 0; Bus b = new Bus(); BusRepo br = new BusRepo(); while (seatnumbers[i] != "") { b = br.GetBus(tablebusid, tabledate, tabletime); br.updatefordelete(b, seatnumbers[i]); i++; } MessageBox.Show(b.NumberOfSeats + " " + seatnumbers.Length); b.NumberOfSeats = (b.NumberOfSeats + seatnumbers.Length - 1); br.UpdateNumberSeat(b); } else { MessageBox.Show("Can Not Delete"); } }
private void SeatBookBtn_Click(object sender, EventArgs e) { br = new BusRepo(); CustomerDetailsPanel.Visible = true; FromToPanel.Visible = false; WelcomePanel.Visible = false; BusTablePanel.Visible = false; Bus b = new Bus(); b = br.GetBus(tablebusid, tablebusname, tabledate, tabletime, tableavailableseats, tablefare); if (b.Type == "AC") { acseatpanel.Visible = true; nonacseatpanel.Visible = false; if (b.A1 == 1) { A1btn.Enabled = false; } else { A1btn.Enabled = true; } if (b.A2 == 1) { A2btn.Enabled = false; } else { A2btn.Enabled = true; } if (b.A3 == 1) { A3btn.Enabled = false; } else { A3btn.Enabled = true; } //if (b.A4 == 1) { A4btn.Enabled = false; } else { A4btn.Enabled = true; } if (b.B1 == 1) { B1btn.Enabled = false; } else { B1btn.Enabled = true; } if (b.B2 == 1) { B2btn.Enabled = false; } else { B2btn.Enabled = true; } if (b.B3 == 1) { B3btn.Enabled = false; } else { B3btn.Enabled = true; } //if (b.B4 == 1) { B4btn.Enabled = false; } else { B4btn.Enabled = true; } if (b.C1 == 1) { C1btn.Enabled = false; } else { C1btn.Enabled = true; } if (b.C2 == 1) { C2btn.Enabled = false; } else { C2btn.Enabled = true; } if (b.C3 == 1) { C3btn.Enabled = false; } else { C3btn.Enabled = true; } //if (b.C4 == 1) { C4btn.Enabled = false; } else { C4btn.Enabled = true; } if (b.D1 == 1) { D1btn.Enabled = false; } else { D1btn.Enabled = true; } if (b.D2 == 1) { D2btn.Enabled = false; } else { D2btn.Enabled = true; } if (b.D3 == 1) { D3btn.Enabled = false; } else { D3btn.Enabled = true; } //if (b.D4 == 1) { D4btn.Enabled = false; } else { D4btn.Enabled = true; } if (b.E1 == 1) { E1btn.Enabled = false; } else { E1btn.Enabled = true; } if (b.E2 == 1) { E2btn.Enabled = false; } else { E2btn.Enabled = true; } if (b.E3 == 1) { E3btn.Enabled = false; } else { E3btn.Enabled = true; } //if (b.E4 == 1) { E4btn.Enabled = false; } else { E4btn.Enabled = true; } if (b.F1 == 1) { F1btn.Enabled = false; } else { F1btn.Enabled = true; } if (b.F2 == 1) { F2btn.Enabled = false; } else { F2btn.Enabled = true; } if (b.F3 == 1) { F3btn.Enabled = false; } else { F3btn.Enabled = true; } //if (b.F4 == 1) { F4btn.Enabled = false; } else { F4btn.Enabled = true; } if (b.G1 == 1) { G1btn.Enabled = false; } else { G1btn.Enabled = true; } if (b.G2 == 1) { G2btn.Enabled = false; } else { G2btn.Enabled = true; } if (b.G3 == 1) { G3btn.Enabled = false; } else { G3btn.Enabled = true; } //if (b.G4 == 1) { G4btn.Enabled = false; } else { G4btn.Enabled = true; } if (b.H1 == 1) { H1btn.Enabled = false; } else { H1btn.Enabled = true; } if (b.H2 == 1) { H2btn.Enabled = false; } else { H2btn.Enabled = true; } if (b.H3 == 1) { H3btn.Enabled = false; } else { H3btn.Enabled = true; } //if (b.H4 == 1) { H4btn.Enabled = false; } else { H4btn.Enabled = true; } } else if (b.Type == "Non-AC") { acseatpanel.Visible = false; nonacseatpanel.Visible = true; if (b.A1 == 1) { A1Button.Enabled = false; } else { A1Button.Enabled = true; } if (b.A2 == 1) { A2Button.Enabled = false; } else { A2Button.Enabled = true; } if (b.A3 == 1) { A3Button.Enabled = false; } else { A3Button.Enabled = true; } if (b.A4 == 1) { A4Button.Enabled = false; } else { A4Button.Enabled = true; } if (b.B1 == 1) { B1Button.Enabled = false; } else { B1Button.Enabled = true; } if (b.B2 == 1) { B2Button.Enabled = false; } else { B2Button.Enabled = true; } if (b.B3 == 1) { B3Button.Enabled = false; } else { B3Button.Enabled = true; } if (b.B4 == 1) { B4Button.Enabled = false; } else { B4Button.Enabled = true; } if (b.C1 == 1) { C1Button.Enabled = false; } else { C1Button.Enabled = true; } if (b.C2 == 1) { C2Button.Enabled = false; } else { C2Button.Enabled = true; } if (b.C3 == 1) { C3Button.Enabled = false; } else { C3Button.Enabled = true; } if (b.C4 == 1) { C4Button.Enabled = false; } else { C4Button.Enabled = true; } if (b.D1 == 1) { D1Button.Enabled = false; } else { D1Button.Enabled = true; } if (b.D2 == 1) { D2Button.Enabled = false; } else { D2Button.Enabled = true; } if (b.D3 == 1) { D3Button.Enabled = false; } else { D3Button.Enabled = true; } if (b.D4 == 1) { D4Button.Enabled = false; } else { D4Button.Enabled = true; } if (b.E1 == 1) { E1Button.Enabled = false; } else { E1Button.Enabled = true; } if (b.E2 == 1) { E2Button.Enabled = false; } else { E2Button.Enabled = true; } if (b.E3 == 1) { E3Button.Enabled = false; } else { E3Button.Enabled = true; } if (b.E4 == 1) { E4Button.Enabled = false; } else { E4Button.Enabled = true; } if (b.F1 == 1) { F1Button.Enabled = false; } else { F1Button.Enabled = true; } if (b.F2 == 1) { F2Button.Enabled = false; } else { F2Button.Enabled = true; } if (b.F3 == 1) { F3Button.Enabled = false; } else { F3Button.Enabled = true; } if (b.F4 == 1) { F4Button.Enabled = false; } else { F4Button.Enabled = true; } if (b.G1 == 1) { G1Button.Enabled = false; } else { G1Button.Enabled = true; } if (b.G2 == 1) { G2Button.Enabled = false; } else { G2Button.Enabled = true; } if (b.G3 == 1) { G3Button.Enabled = false; } else { G3Button.Enabled = true; } if (b.G4 == 1) { G4Button.Enabled = false; } else { G4Button.Enabled = true; } if (b.H1 == 1) { H1Button.Enabled = false; } else { H1Button.Enabled = true; } if (b.H2 == 1) { H2Button.Enabled = false; } else { H2Button.Enabled = true; } if (b.H3 == 1) { H3Button.Enabled = false; } else { H3Button.Enabled = true; } if (b.H4 == 1) { H4Button.Enabled = false; } else { H4Button.Enabled = true; } } }