private void btnSerach_Click(object sender, EventArgs e) { lvTicketInfo.Items.Clear(); TicketCtrl tc = new TicketCtrl(); List <object[]> ticketList = new List <Object[]>(); if (rbPassId.Checked) { ticketList = tc.serachTicketFromPassId(tbInfo.Text); } if (rbTimeId.Checked) { ticketList = tc.serachTicketFromTimeId(tbInfo.Text); } ListViewItem[] lvi = new ListViewItem[ticketList.Count]; for (int i = 0; i < ticketList.Count; i++) { string[] subList = new string[4]; for (int j = 0; j <= 3; j++) { subList[j] = ticketList[i][j].ToString(); } lvi[i] = new ListViewItem(subList); } lvTicketInfo.Items.AddRange(lvi); }
private void btnDel_Click(object sender, EventArgs e) { TicketCtrl tc = new TicketCtrl(); tc.delTicket(tbTicketId.Text); this.Close(); }
private void btnConfirm_Click(object sender, EventArgs e) { TicketCtrl tc = new TicketCtrl(); TimetableCtrl ttc = new TimetableCtrl(); TrainCtrl trc = new TrainCtrl(); string index = (tc.loadMaxId() + 1).ToString(); Ticket t = new Ticket(index, tbName.Text, tbPassId.Text, lvTimetable.SelectedItems[0].Text.ToString()); string trainName = ttc.loadTrainName(lvTimetable.SelectedItems[0].Text.ToString()); if (tc.loadTicket().Count < int.Parse(trc.loadTrain(trainName)[0][3].ToString())) { tc.saveTicket(t); this.Close(); } else { MessageBox.Show("该车次已售完", "购票失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } }