コード例 #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (lsbxPersons.SelectedIndex != -1)
            {
                fAdd f = new fAdd("Edit Selected Client");
                f.tbxFName.Text       = persons[lsbxPersons.SelectedIndex].firstName;
                f.tbxSName.Text       = persons[lsbxPersons.SelectedIndex].secondName;
                f.tbxTName.Text       = persons[lsbxPersons.SelectedIndex].thirdName;
                f.nudThings.Value     = Convert.ToDecimal(persons[lsbxPersons.SelectedIndex].baggageThings);
                f.tbxWeight.Text      = persons[lsbxPersons.SelectedIndex].baggageWeight.ToString();
                f.nudNumber.Value     = Convert.ToDecimal(persons[lsbxPersons.SelectedIndex].flightNumber);
                f.dtpDate.Value       = persons[lsbxPersons.SelectedIndex].flightDate;
                f.dtpTime.Value       = persons[lsbxPersons.SelectedIndex].flightTime;
                f.tbxDuration.Text    = persons[lsbxPersons.SelectedIndex].flightDuration.ToString();
                f.tbxDestination.Text = persons[lsbxPersons.SelectedIndex].destination;

                if (f.ShowDialog() == DialogResult.OK)
                {
                    persons.RemoveAt(lsbxPersons.SelectedIndex);
                    persons.Insert(lsbxPersons.SelectedIndex, new Person(f.tbxFName.Text, f.tbxSName.Text, f.tbxTName.Text, Convert.ToInt32(f.nudThings.Value), Convert.ToDouble(f.tbxWeight.Text), Convert.ToInt32(f.nudNumber.Value), f.dtpDate.Value, f.dtpTime.Value, Convert.ToDouble(f.tbxDuration.Text), f.tbxDestination.Text));
                    lsbxPersons.DataSource = null;
                    lsbxPersons.DataSource = persons;
                }
            }
        }
コード例 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            fAdd f = new fAdd("Add New Client");

            if (f.ShowDialog() == DialogResult.OK)
            {
                persons.Add(new Person(f.tbxFName.Text, f.tbxSName.Text, f.tbxTName.Text, Convert.ToInt32(f.nudThings.Value), Convert.ToDouble(f.tbxWeight.Text), Convert.ToInt32(f.nudNumber.Value), f.dtpDate.Value, f.dtpTime.Value, Convert.ToDouble(f.tbxDuration.Text), f.tbxDestination.Text));
                lsbxPersons.DataSource = null;
                lsbxPersons.DataSource = persons;
            }
        }