コード例 #1
0
        public void addNew()
        {
            CDInformation cd = new CDInformation(
                txtID.Text,
                txtAlbum.Text,
                txtSinger.Text,
                cbxGenre.Text,
                int.Parse(txtDuration.Text)
                );

            for (int i = 0; i < listSongs.Items.Count; i++)
            {
                cd.Song.Add(listSongs.Items[i].ToString());
            }
            FormManage owner = (FormManage)this.Owner;

            foreach (CDInformation CD in owner.ListCD)
            {
                if (owner.ListCD.Count == 0)
                {
                    break;
                }
                if (CD.ID1.Equals(txtID.Text))
                {
                    ErrorID.SetError(txtID, "This ID is already existed!!");
                    return;
                }
            }
            ErrorID.Clear();
            owner.ListCD.Add(cd);
            owner.loadListData();
            btnReset_Click(this, null);
        }
コード例 #2
0
        public void update()
        {
            FormManage      ownder = (FormManage)this.Owner;
            DataGridViewRow row    = new DataGridViewRow();
            CDInformation   cd     = new CDInformation(
                txtID.Text,
                txtAlbum.Text,
                txtSinger.Text,
                cbxGenre.Text,
                int.Parse(txtDuration.Text)
                );

            for (int i = 0; i < listSongs.Items.Count; i++)
            {
                cd.Song.Add(listSongs.Items[i].ToString());
            }
            FormManage owner = (FormManage)this.Owner;

            foreach (CDInformation CD in owner.ListCD)
            {
                if (owner.ListCD.Count == 0)
                {
                    break;
                }
                if (CD.ID1.Equals(txtID.Text))
                {
                    CD.Album1   = cd.Album1;
                    CD.Singer1  = cd.Singer1;
                    CD.Genre1   = cd.Genre1;
                    CD.Duration = cd.Duration;
                    CD.Song     = cd.Song;
                    break;
                }
            }
            owner.loadListData();
            this.Close();
        }