Ejemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (listCD.Count == 0)
            {
                MessageBox.Show("You don't have any item to update", "Update Error", MessageBoxButtons.OK);
                return;
            }
            if (gvCD.SelectedRows.Count == 0)
            {
                ErrorClick.SetError(btnSave, "Please select row!!!");
                return;
            }
            ErrorClick.Clear();
            DataGridViewRow row    = gvCD.SelectedRows[0];
            FormInput       update = new FormInput();
            CDInformation   cd     = new CDInformation(
                row.Cells[0].Value.ToString(),
                row.Cells[1].Value.ToString(),
                row.Cells[2].Value.ToString(),
                row.Cells[3].Value.ToString(),
                int.Parse(row.Cells[4].Value.ToString()));

            for (int i = 0; i < lSong.Items.Count; i++)
            {
                cd.Song.Add((string)lSong.Items[i]);
            }
            update.setInfo(cd);
            lSong.Items.Clear();
            update.Owner = this;
            update.IsAdd = false;
            update.ShowDialog();
        }
Ejemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (listCD.Count == 0)
            {
                MessageBox.Show("You don't have any item to delete", "Delete Error", MessageBoxButtons.OK);
                return;
            }
            if (gvCD.SelectedRows.Count == 0)
            {
                ErrorClick.SetError(btnSave, "Please select row!!!");
                return;
            }
            ErrorClick.Clear();
            DataGridViewRow row = gvCD.SelectedRows[0];

            foreach (CDInformation cd in listCD)
            {
                if (row.Cells[0].Value.ToString().Equals(cd.ID1))
                {
                    listCD.Remove(cd);
                    break;
                }
            }
            loadListData();
            lSong.Items.Clear();
        }
Ejemplo n.º 3
0
 private void ErrorButton_OnClick(object sender, RoutedEventArgs e)
 {
     ErrorClick?.Invoke(this, _appointmentCalendarAdapter);
 }
Ejemplo n.º 4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (gvCD.Rows.Count == 0)
            {
                return;
            }
            string searchby = cbxSearch.Text;

            if (searchby == "")
            {
                ErrorClick.SetError(btnClearSearch, "Search Value must not be empty!!!");
                return;
            }
            if (searchby.Equals("Album"))
            {
                ErrorClick.Clear();
                string searchValue = txtSearch.Text;
                foreach (DataGridViewRow row in gvCD.Rows)
                {
                    if (row.Cells[1].Value.ToString().Contains(searchValue))
                    {
                        row.Visible = true;
                    }
                    else
                    {
                        row.Visible = false;
                    }
                }
                txtSearch.Clear();
                return;
            }
            if (searchby.Equals("Singer"))
            {
                string searchValue = txtSearch.Text;
                foreach (DataGridViewRow row in gvCD.Rows)
                {
                    if (row.Cells[2].Value.ToString().Contains(searchValue))
                    {
                        row.Visible = true;
                    }
                    else
                    {
                        row.Visible = false;
                    }
                }
                txtSearch.Clear();
                return;
            }
            if (searchby.Equals("Song"))
            {
                string        searchValue = txtSearch.Text;
                List <string> result      = new List <string>();
                foreach (CDInformation cd in listCD)
                {
                    foreach (string song in cd.Song)
                    {
                        if (song.Contains(searchValue))
                        {
                            result.Add(cd.ID1);
                        }
                    }
                }//end of find song
                foreach (DataGridViewRow row in gvCD.Rows)
                {
                    foreach (string song in result)
                    {
                        if (row.Cells[0].Value.ToString().Contains(song))
                        {
                            row.Visible = true;
                        }
                        else
                        {
                            row.Visible = false;
                        }
                    }
                }
                txtSearch.Clear();
                return;
            }
        }