private void subButt_Click(object sender, EventArgs e) { HardwareProduct p = new HardwareProduct { Manufacturer = manufacturerTxt.Text, Title = titleTxt.Text, Description = descriptionTxt.Text }; if (priceTxt.Text == "") { p.Price = -1; } else { p.Price = Convert.ToDecimal(priceTxt.Text.Replace("$", "")); } if (!editForm) { HardwareDB.Insert(p); } else { p.ProductId = editProd.ProductId; HardwareDB.Update(p); } var form1 = (Form1)Tag; // set form1 to the Form1 class we tagged earlier form1.Form1_Load(); //refresh products list form1.Show(); Close(); }
private void deletebutt_Click(object sender, EventArgs e) { for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++) { HardwareProduct h = (HardwareProduct)checkedListBox1.CheckedItems[i]; HardwareDB.Delete(h.ProductId); } Form1_Load(); }
public AddForm(HardwareProduct HP) { InitializeComponent(); descriptionTxt.Text = HP.Description; manufacturerTxt.Text = HP.Manufacturer; priceTxt.Text = HP.Price.ToString("F2"); titleTxt.Text = HP.Title; editProd.ProductId = HP.ProductId; editForm = true; }