//namespace CSI_122_Final
{
public partial class Form1 : Form
{
private int nextID = 1;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
//This is the save button
if (listBox1.SelectedIndex >= 0)
{
listBox1.Items.Add("Record: #" + label6.Text + 1 + " " + textBox1.Text + " " + textBox2.Text
+ " " + textBox3.Text + " " + textBox4.Text + " Type of items purchased: " + listBox1.Items[listBox2.SelectedIndex]);
label6.Text = $" {nextID++}";
textBox1.Clear();
textBox1.Focus();
textBox2.Clear();
textBox2.Focus();
textBox3.Clear();
textBox3.Focus();
textBox4.Clear();
textBox4.Focus();
listBox2.ClearSelected();
}
else
{
MessageBox.Show("Input information in all fields");
}
}
private void button4_Click(object sender, EventArgs e)
{
//This is the delete button
if (listBox1.SelectedIndex >= -1)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
}
private void button1_Click(object sender, EventArgs e)
{
//this is the first button
listBox1.SelectedItem = listBox1.Items[0];
}
private void button3_Click(object sender, EventArgs e)
{
//this is the last button
listBox1.SelectedItem = listBox1.Items[listBox1.Items.Count-1];
}
}
}