示例#1
0
        private void btnTimeList_Click(object sender, EventArgs e)
        {
            lvComplex.Clear();
            lvComplex.ShowGroups = false;
            TimetableCtrl ttc = new TimetableCtrl();
            TrainCtrl     tc  = new TrainCtrl();
            TicketCtrl    tkc = new TicketCtrl();

            gbLvName.Text = "信息视图-车次列表";
            lvComplex.Columns.Add("车次", 90, HorizontalAlignment.Left);
            lvComplex.Columns.Add("车组方式", 60, HorizontalAlignment.Left);
            lvComplex.Columns.Add("始发站", 90, HorizontalAlignment.Left);
            lvComplex.Columns.Add("到达站", 90, HorizontalAlignment.Left);
            lvComplex.Columns.Add("发车时间", 120, HorizontalAlignment.Left);
            lvComplex.Columns.Add("运行时长", 90, HorizontalAlignment.Left);
            lvComplex.Columns.Add("票价", 60, HorizontalAlignment.Left);
            lvComplex.Columns.Add("余票", 60, HorizontalAlignment.Left);
            List <object[]> timeList = ttc.loadTimetable();

            ListViewItem[] lvi = new ListViewItem[timeList.Count];
            for (int i = 0; i < timeList.Count; i++)
            {
                List <object[]> ListTrain = tc.loadTrainSum(timeList[i][1].ToString());
                int             sold      = tkc.serachTicketFromTimeId(timeList[i][0].ToString()).Count;
                string          remain    = (int.Parse(ListTrain[0][0].ToString()) - sold).ToString();
                string[]        subList   = new string[8];
                for (int j = 0; j <= 6; j++)
                {
                    subList[j] = timeList[i][j].ToString();
                }
                subList[7] = remain;
                lvi[i]     = new ListViewItem(subList);
            }
            lvComplex.Items.AddRange(lvi);
        }
示例#2
0
        private void NewTicketForm_Load(object sender, EventArgs e)
        {
            TimetableCtrl   ttc       = new TimetableCtrl();
            List <object[]> timetable = ttc.loadTimetable();

            for (int i = 0; i < timetable.Count; i++)
            {
                string[] subItem = new string[3];
                subItem[0] = timetable[i][0].ToString();
                subItem[1] = timetable[i][2].ToString();
                subItem[2] = timetable[i][3].ToString();
                ListViewItem lvi = new ListViewItem(subItem);
                lvTimetable.Items.Add(lvi);
            }
        }
示例#3
0
        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);
            }
        }