Example #1
0
        public productForm(Context context, Product product)
        {
            this.context = context;

            InitializeComponent();
            this.product = product;
            populateFields();
        }
Example #2
0
        public productForm(Context context)
        {
            this.context = context;

            InitializeComponent();
            product = new Product();
            populateFields();
        }
Example #3
0
 private void editSelection()
 {
     try
     {
         foreach (ListViewItem item in listView.SelectedItems)
         {
             int id = Convert.ToInt16(item.Tag);
             Product product = new Product(id);
             productForm form = new productForm(this.context, product);
             form.ShowDialog(this);
             loadList();
         }
     }
     catch (Exception ex)
     {
         Tools.ShowError("Unable to load product\n" + ex.Message);
     }
 }
Example #4
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (ListViewItem item in listView.SelectedItems)
         {
             int id = Convert.ToInt16(item.Tag);
             Product product = new Product(id);
             if(MessageBox.Show(this, "Are you sure you want to delete " + product.Name + "?", Properties.Settings.Default.companyname, MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
             {
                 product.Delete();
                 loadList();
             }
         }
     }
     catch (Exception ex)
     {
         Tools.ShowError("Unable to delete product\n" + ex.Message);
     }
 }
 private void populateFields(Product product)
 {
     comboBoxProducts.Text = product.Name;
     if (invoiceproduct.Price == 0)
     {
         textBoxPrice.Text = product.Price.ToString();
     }
 }
Example #6
0
        public static Product[] listProducts()
        {
            Product[] products = new Product[0];

            Dal dal = new Dal();
            HashSet<Hashtable> results = dal.executeAsHashset("call listProducts();");
            products = new Product[results.Count];
            int counter = 0;
            foreach (Hashtable table in results)
            {
                Product product = new Product(table);
                products[counter] = product;
                counter++;
            }
            return products;
        }