Exemple #1
0
        private void btnTrainList_Click(object sender, EventArgs e)
        {
            lvComplex.Clear();
            TrainCtrl tc = new TrainCtrl();

            gbLvName.Text = "信息视图-车组列表";
            lvComplex.Columns.Add("车组名称", 120, HorizontalAlignment.Left);
            lvComplex.Columns.Add("车厢类型", 120, HorizontalAlignment.Left);
            lvComplex.Columns.Add("车厢节数", 120, HorizontalAlignment.Left);
            lvComplex.Columns.Add("容量", 120, HorizontalAlignment.Left);
            List <object[]> nameList = tc.loadVolume();

            for (int k = 0; k < nameList.Count; k++)
            {
                ListViewGroup lvg = new ListViewGroup();
                lvg.Header = nameList[k][0].ToString() + "  总容量  " + nameList[k][1].ToString();
                lvComplex.Groups.Add(lvg);
                lvComplex.ShowGroups = true;
                List <object[]> trainList = tc.loadTrain(nameList[k][0].ToString());
                ListViewItem[]  lvi       = new ListViewItem[trainList.Count];
                for (int i = 0; i < trainList.Count; i++)
                {
                    string[] subList = new string[4];
                    for (int j = 0; j <= 3; j++)
                    {
                        subList[j] = trainList[i][j].ToString();
                    }
                    lvi[i] = new ListViewItem(subList);
                    lvg.Items.Add(lvi[i]);
                }
                lvComplex.Items.AddRange(lvi);
            }
        }
Exemple #2
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);
            }
        }