コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                int id = 0;
                if (!int.TryParse(txtID.Text, out id))
                {
                    MessageBox.Show("Enter a numeric value for the ID", "Error");
                    return;
                }

                if (txtTitle.Text == "" || txtRunningTime.Text == "")
                {
                    MessageBox.Show("Enter values for the title and running time", "Error");
                    return;
                }

                movie.Add(Convert.ToInt32(txtID.Text), txtTitle.Text, Convert.ToInt32(txtRunningTime.Text), dateTimePicker1.Value);
            }
            catch (Exception ex)
            {
                lblResult.Text = ex.Message;
            }
        }