private void btnSave_Click(object sender, EventArgs e) { int itemNo = Convert.ToInt32(txtItemNo.Text); string description = txtDescription.Text; decimal price = Convert.ToDecimal(txtPrice.Text); if (IsValidData()) { // Add code here that creates a new item invItem = new InvItem(itemNo, description, price); // and closes the form. this.Close(); } }
private void btnAdd_Click(object sender, EventArgs e) { // Add code here that creates an instance of the New Item form // and then gets a new item from that form. frmNewItem newItemForm = new frmNewItem(); InvItem invItem = newItemForm.GetNewItem(); if (invItem != null) { invItems.Add(invItem); InvItemDB.SaveItems(invItems); FillItemListBox(); } }
private void btnSave_Click(object sender, EventArgs e) { if (IsValidData()) { // Add code here that creates a new item // and closes the form. if (IsValidData()) { invItem = new InvItem(Convert.ToInt32(txtItemNo.Text), txtDescription.Text, Convert.ToDecimal(txtPrice.Text)); this.Close(); } } }
private void btnSave_Click(object sender, EventArgs e) { if (IsValidData()) { if (rdoPlant.Checked) { invItem = new Plant(Convert.ToInt32(txtItemNo.Text), cboSizeOrManufacturer.Text, txtDescription.Text, Convert.ToDecimal(txtPrice.Text)); } else { invItem = new Supply(Convert.ToInt32(txtItemNo.Text), cboSizeOrManufacturer.Text, txtDescription.Text, Convert.ToDecimal(txtPrice.Text)); } this.Close(); } }
private void btnDelete_Click(object sender, System.EventArgs e) { int i = lstItems.SelectedIndex; if (i != -1) { InvItem invItem = invItems[i]; string message = "Are you sure you want to delete " + invItem.Description + "?"; DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo); if (button == DialogResult.Yes) { invItems -= invItem; } } }
private void btnSave_Click(object sender, EventArgs e) { if (IsValidData()) { if (rdoPlant.Checked == true) { string size = cboSizeOrManufacturer.SelectedItem.ToString(); invItem = new Plant(Convert.ToInt32(txtItemNo.Text), txtDescription.Text, Convert.ToDecimal(txtPrice.Text), size); } else if (rdoSupply.Checked == true) { invItem = new Supply(Convert.ToInt32(txtItemNo.Text), txtDescription.Text, Convert.ToDecimal(txtPrice.Text), cboSizeOrManufacturer.SelectedItem.ToString()); } this.Close(); } }
private void btnDelete_Click(object sender, EventArgs e) { int i = lstItems.SelectedIndex; if (i != -1) { InvItem invItem = invItems.GetItemByIndex(i); string message = "Are you sure you want to delete " + invItem.Description + "?"; DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo); if (button == DialogResult.Yes) { invItems.Remove(invItem); invItems.Save(); FillItemListBox(); } } }
private void btnDelete_Click(object sender, EventArgs e) { int i = lstItems.SelectedIndex; if (i != -1) // check if an inventory item has been selected { // Add code here that displays a dialog box to confirm // the deletion and then removes the item from the list, // saves the list of products, and refreshes the list box // if the deletion is confirmed. InvItem invItem = invItems[i]; // create & set variable for selected inventory item string message = "Are you sure you want to delete: " + invItem.ItemNo + " " + invItem.Description + "?"; // create delete confirmation message DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2); // display confirmation to delete if (button == DialogResult.Yes) // check if user confirmed deletion { invItems.Remove(invItem); // remove selected item from list InvItemDB.SaveItems(invItems); // save updated items list FillItemListBox(); // call method to refresh items list box } } }
private void btnDelete_Click(object sender, EventArgs e) { int i = lstItems.SelectedIndex; if (i != -1) { // Add code here that displays a dialog box to confirm // the deletion and then removes the item from the list, // saves the list of products, and refreshes the list box // if the deletion is confirmed. InvItem invItem = invItems[i]; string message = "Are you sure you want to delete " + invItem.Description + "?"; DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo); if (button == DialogResult.Yes) { invItems.Remove(invItem); InvItemDB.SaveItems(invItems); FillItemListBox(); } } }
public void Remove(InvItem invItem) { invItems.Remove(invItem); Changed(this); }
public void Add(InvItem invItem) { invItems.Add(invItem); Changed(this); }
private static void ReadBase(XmlReader xmlIn, InvItem i) { i.ItemNo = xmlIn.ReadElementContentAsInt(); i.Description = xmlIn.ReadElementContentAsString(); i.Price = xmlIn.ReadElementContentAsDecimal(); }
private static void WriteBase(InvItem item, XmlWriter xmlOut) { xmlOut.WriteElementString("ItemNo", Convert.ToString(item.ItemNo)); xmlOut.WriteElementString("Description", item.Description); xmlOut.WriteElementString("Price", Convert.ToString(item.Price)); }
public void Add(InvItem invItem) { invItems.Add(invItem); }
public void Add(InvItem invItem) => invItems.Add(invItem);
public void Add(int itemNo, string description, decimal price) { InvItem i = new InvItem(itemNo, description, price); invItems.Add(i); }
public void Remove(InvItem invItem) { invItems.Remove(invItem); }