Ejemplo n.º 1
0
        public void AddOneToListView(Activity t)
        {
            this.listView1.BeginUpdate();
            Tourist      tou  = Repository.GetTouristByName(t.TouristName);
            Route        r    = Repository.GetRouteByDesc(t.RouteDescriptions);
            ListViewItem item = new ListViewItem(tou.Name);

            item.SubItems.Add(tou.Gender);
            item.SubItems.Add(tou.Id);
            item.SubItems.Add(tou.Tel);
            item.SubItems.Add(r.Descriptions);
            item.SubItems.Add(r.Price.ToString());
            item.SubItems.Add(r.Date.ToString());
            item.Tag = t;
            this.listView1.Items.Add(item);
            this.listView1.EndUpdate();
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.button1.Enabled = false;
            Tourist t = new Tourist(this.textBoxn.Text.Trim(),
                                    this.GetGender(),
                                    this.textBoxi.Text.Trim(),
                                    this.textBoxt.Text.Trim()
                                    );

            if (Repository.dataTourist.Add(t, x => x.Name))
            {
                Repository.dataTourist.AddOneToListView(this.listView1, t);
                //MessageBox.Show("添加成功!");
            }
            else
            {
                MessageBox.Show("不能重复添加!");
            }
        }