Example #1
0
 private void TextBoxSearch_LostFocus(object sender, RoutedEventArgs e)
 {
     if (dataGridSearch.SelectedValue == null)
     {
         dataGridSearch.Visibility = Visibility.Collapsed;
         TextBoxSearch.Clear();
     }
     //else
     //{
     //    DataRowView drv = (DataRowView)dataGridSearch.SelectedItem;
     //    TextBoxSearch.Text = (drv`"Unit #"`).ToString();
     //    dataGridSearch.Visibility = Visibility.Collapsed;
     //}
 }
Example #2
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == Keys.Enter)
     {
         SetNodes();
         return(true);
     }
     if (keyData == Keys.Escape)
     {
         TextBoxSearch.Clear();
         TreeViewFind.Nodes.Clear();
         return(true);
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }
Example #3
0
        private void metroTileSearch_Click(object sender, EventArgs e)
        {
            int rows = 0;

            try
            {
                rows = employeeTA.SearchBySurname(this.employeeDS.EMPLOYEE, TextBoxSearch.Text.ToLower());
                if (rows == 0)
                {
                    MessageBox.Show("The surname: " + TextBoxSearch.Text + " does not exist in our database records.");
                    TextBoxSearch.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error searching staff member:\n" + ex.Message.ToString());
            }
        }
 private void ButtonAddPlaylist_Click(object sender, EventArgs e)
 {
     openFileDialog.FileName = "";
     openFileDialog.Title    = "Відкрити плейліст";
     openFileDialog.Filter   = "XML File (.xml)|*.xml|TXT File (.txt)|*.txt";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         dataGridView1.Rows.Clear();
         XmlReaderSettings ws = new XmlReaderSettings();
         //ws.IgnoreWhitespace = false;
         XmlSerializer serializer = new XmlSerializer(typeof(List <Song>));
         string        path       = "";
         try
         {
             using (XmlReader xmlWriter = XmlReader.Create(openFileDialog.FileName, ws))
             {
                 path = openFileDialog.FileName;
                 if (Path.GetExtension(openFileDialog.FileName) == ".xml")
                 {
                     Songs = serializer.Deserialize(xmlWriter) as List <Song>;
                     foreach (Song song in Songs)
                     {
                         dataGridView1.Rows.Add(song.Artist, song.Album, song.Name, song.Year, song.Genre);
                     }
                     ButtonSavePlaylist.Enabled = true;
                     ButtonLyrics.Enabled       = true;
                     TextBoxSearch.Clear();
                 }
                 else
                 {
                     MessageBox.Show("Wrong format, .xml required", "Wrong format error", MessageBoxButtons.OK);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error reading file", MessageBoxButtons.OK);
         }
     }
 }//Deserialization
        private void ButtonClearSearchFilters_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            TextBoxSearch.Clear();
            ButtonSearch.Enabled       = true;
            ButtonSavePlaylist.Enabled = true;
            foundSongs.Clear();

            try
            {
                for (int i = 0; i < Songs.Count; i++)
                {
                    dataGridView1.Rows.Insert(i, Songs[i].Artist, Songs[i].Album, Songs[i].Name, Songs[i].Year, Songs[i].Genre);
                }
                dataGridView1.ClearSelection();
                ButtonDelete.Enabled = false;
                ButtonFormat.Enabled = false;
                ButtonLyrics.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }