Пример #1
0
 private void UpdateId_Click(object sender, EventArgs e)
 {
     if (idTextBox.Text != "")
     {
         long id = 0;
         if (long.TryParse(idTextBox.Text, out id))
         {
             ItemBase[] items = new ItemBase[itemBox.Items.Count];
             itemBox.Items.CopyTo(items, 0);
             if (items.FirstOrDefault(x => x.ItemId == id && x.ItemId != (itemBox.SelectedItem as ItemBase).ItemId) != null)
             {
                 Interaction.MsgBox("ID already in use", MsgBoxStyle.Exclamation);
                 idTextBox.Text = "";
             }
             else
             {
                 idLabel.Text   = idTextBox.Text;
                 idTextBox.Text = "";
             }
         }
         else
         {
             Interaction.MsgBox("ID must be a number.", MsgBoxStyle.Exclamation);
             idTextBox.Text = "";
         }
     }
 }