private void buttonUpdate_Click(object sender, EventArgs e) { UpdateList(list[count - 1]); DBItem dbItem = new DBItem(); dbItem.Update(this.db.Connection, list[count - 1].Name, list[count - 1].Department, list[count - 1].BestBefore, list[count - 1].Quantity, list[count - 1].Price); }
private void buttonDelete_Click(object sender, EventArgs e) { DBItem dbItem = new DBItem(); dbItem.Delete(this.db.Connection, list[count - 1].Name); list.RemoveAt(count - 1); count--; DisplayItem(list[count - 1]); }
private void buttonSaveItem_Click(object sender, EventArgs e) { Item item = new Item(textBoxName.Text, textBoxDepartment.Text, textBoxBestBefore.Text, int.Parse(textBoxQuantity.Text), Double.Parse(textBoxPrice.Text), textBoxPath.Text); list.Add(item); DBItem dbItem = new DBItem(); dbItem.Insert(this.db.Connection, item.Name, item.Department, item.BestBefore, item.Quantity, item.Price, item.Image); DisplayItem(item); buttonSaveItem.Visible = false; labelPath.Visible = false; textBoxPath.Visible = false; }
private void FormStore_Load(object sender, EventArgs e) { this.db = new DBConnection("localhost", "store", "csharp", "password"); if (db.Connect()) { MessageBox.Show("Connected to MySql Server"); } dbItem = new DBItem(); reader = dbItem.GetItems(this.db.Connection); while (reader.Read()) { Item item = new Item(); item.Name = reader.GetString(0); item.Department = reader.GetString(1); item.BestBefore = reader.GetString(2); item.Quantity = reader.GetInt32(3); item.Price = reader.GetDouble(4); item.Image = reader.GetString(5); list.Add(item); }//WHILE DisplayItem(list[count - 1]); reader.Close(); }//LOAD