Beispiel #1
0
        private void menuItem1_Click(object sender, System.EventArgs e)
        {
            PersonPropertiesForm ppf = new PersonPropertiesForm();

            ppf.ShowDialog(this);
            if (ppf.DialogResult == DialogResult.OK)
            {
                try
                {
                    string name     = ppf.getNameTextBoxText();
                    string lastName = ppf.getLastNameTextBoxText();
                    int    age      = System.Convert.ToInt32(ppf.getAgeTextBoxText());
                    string city     = ppf.getCityComboBoxText();

                    Person p = new Person(name, lastName, age, city);

                    AddPersonCmd apc = new AddPersonCmd(p);
                    _cmdProcessor.doCmd(apc);
                }
                catch
                {
                }
            }

            ppf.Dispose();
        }
Beispiel #2
0
        private void showData_Click(object sender, System.EventArgs e)
        {
            Person p = (Person)treeView1.SelectedNode;
            PersonPropertiesForm ppf = new PersonPropertiesForm(p);

            ppf.ShowDialog(this);
            if (ppf.DialogResult == DialogResult.OK)
            {
                try
                {
                    string newName     = ppf.getNameTextBoxText();
                    string newLastName = ppf.getLastNameTextBoxText();
                    int    newAge      = System.Convert.ToInt32(ppf.getAgeTextBoxText());
                    string newCity     = ppf.getCityComboBoxText();

                    if (p.Name != newName || p.LastName != newLastName || p.Age != newAge || p.City != newCity)
                    {
                        ChangePersonCmd cpc = new ChangePersonCmd(p, newName, newLastName, newAge, newCity);
                        _cmdProcessor.doCmd(cpc);
                    }
                }
                catch
                {
                }
            }

            ppf.Dispose();
        }
Beispiel #3
0
        private void ShowPersonData_Click(object sender, System.EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem lvi = listView1.SelectedItems[0];
                Person       p   = (Person)lvi.Tag;

                PersonPropertiesForm ppf = new PersonPropertiesForm(p);
                ppf.ShowDialog(this);
                if (ppf.DialogResult == DialogResult.OK)
                {
                    try
                    {
                        p.Name     = ppf.getNameTextBoxText();
                        p.LastName = ppf.getLastNameTextBoxText();
                        p.Age      = System.Convert.ToInt32(ppf.getAgeTextBoxText());
                        p.City     = ppf.getCityComboBoxText();

                        lvi.SubItems[0].Text = p.Name;
                        lvi.SubItems[1].Text = p.LastName;
                    }
                    catch
                    {
                    }
                }
                ppf.Dispose();
            }
        }
Beispiel #4
0
        private void menuItem1_Click(object sender, System.EventArgs e)
        {
            PersonPropertiesForm ppf = new PersonPropertiesForm();

            ppf.ShowDialog(this);
            if (ppf.DialogResult == DialogResult.OK)
            {
                try
                {
                    string name     = ppf.getNameTextBoxText();
                    string lastName = ppf.getLastNameTextBoxText();
                    int    age      = System.Convert.ToInt32(ppf.getAgeTextBoxText());
                    string city     = ppf.getCityComboBoxText();
                    Person p        = new Person(name, lastName, age, city);

                    string[] str = new string[2] {
                        name, lastName
                    };
                    ListViewItem lvi = new ListViewItem(str);
                    lvi.Tag = p;
                    listView1.Items.Add(lvi);

                    ///
                    MyLabel label = new MyLabel(p.Index);
                    panel1.Controls.Add(label);
                }
                catch
                {
                }
            }
            ppf.Dispose();
        }
Beispiel #5
0
        private void ShowPersonMenuItem_Click(object sender, EventArgs e)
        {
            ListViewItem lvi    = (ListViewItem)this.Tag;
            Person       person = (Person)lvi.Tag;

            PersonPropertiesForm personPropertiesForm = new PersonPropertiesForm(person);

            personPropertiesForm.ShowDialog(this);
        }
Beispiel #6
0
        private void viewPersonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListViewItem lvi = (ListViewItem)panel1.Controls[indexOfLabelInUse].Tag;
            Person       p   = (Person)lvi.Tag;

            PersonPropertiesForm ppf = new PersonPropertiesForm(p);

            ppf.ShowDialog(this);
        }
Beispiel #7
0
        private void newPersonMenuItem_Click(object sender, System.EventArgs e)
        {
            PersonPropertiesForm ppf = new PersonPropertiesForm();

            ppf.ShowDialog(this);
            if (ppf.DialogResult == DialogResult.OK)
            {
                try
                {
                    string name     = ppf.getNameTextBoxText();
                    string lastName = ppf.getLastNameTextBoxText();
                    int    age      = System.Convert.ToInt32(ppf.getAgeTextBoxText());
                    string city     = ppf.getCityComboBoxText();
                    Person p        = new Person(name, lastName, age, city);

                    PersonDataModel.getDataModel().addNewPerson(p);
                }
                catch
                {
                }
            }

            ppf.Dispose();
        }