Beispiel #1
0
        public EditForm(Museum t)
        {
            InitializeComponent();

            nameField.Text    = t.Name;
            ownerField.Text   = t.Owner;
            addressField.Text = t.Address;
            visitsLabel.Text  = t.Visits.ToString();
            visitsField.Value = t.Visits;
        }
Beispiel #2
0
        public EditForm(Museum t)
        {
            InitializeComponent();

            nameField.Text = t.Name;
            ownerField.Text = t.Owner;
            addressField.Text = t.Address;
            visitsLabel.Text = t.Visits.ToString();
            visitsField.Value = t.Visits;
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string name = nameField.Text ?? "Музей смерти";
            string owner = ownerField.Text ?? "Сатана";
            string address = addressField.Text ?? "Ад";
            int visits = visitsField.Value;
            Result = new Museum(name, owner, address, visits);

            DialogResult = DialogResult.OK;
            Close();
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string name    = nameField.Text ?? "Музей смерти";
            string owner   = ownerField.Text ?? "Сатана";
            string address = addressField.Text ?? "Ад";
            int    visits  = visitsField.Value;

            Result = new Museum(name, owner, address, visits);

            DialogResult = DialogResult.OK;
            Close();
        }
Beispiel #5
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild == null)
            {
                MessageBox.Show("Не открыто ни одной формы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            Table  table      = (Table)ActiveMdiChild;
            var    currentRow = table.DataGridView.CurrentRow;
            Museum t          = (Museum)currentRow?.DataBoundItem;

            if (t != null)
            {
                table.Museums.Remove(t);
            }
        }
Beispiel #6
0
        private void editATigerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild == null)
            {
                MessageBox.Show("Не открыто ни одной формы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            Table  table = (Table)ActiveMdiChild;
            Museum t     = (Museum)table.DataGridView.CurrentRow?.DataBoundItem;

            if (t != null)
            {
                int index = table.Museums.IndexOf(t);
                using (EditForm editForm = new EditForm(t))
                {
                    var result = editForm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        table.Museums[index] = editForm.Result;
                    }
                }
            }
        }