Exemplo n.º 1
0
 public static void LoadProduct(IProgress<ProductItem> progress)
 {
     try
     {
         using (MySqlDataReader data = DB.Instance.SelectReader(
             @"SELECT * FROM inventory limit 100;"
             ))
         {
             if (data != null)
             {
                 while (data.Read())
                 {
                     var item = new Item(
                         data.GetUInt16(0),
                         data.GetString(1),
                         data.GetUInt16(2),
                         data.GetUInt16(3),
                         data.GetDecimal(4),
                         data.GetUInt16(5),
                         data.GetInt16(6),
                         data.GetString(7));
                     var productitem = new ProductItem(item);
                     progress.Report(productitem);
     #if DEBUG
                     Console.WriteLine(item);
     #endif
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
        public Browser()
        {
            InitializeComponent();
            try
            {
                using (MySqlDataReader data = DB.Instance.selectReader(@"SELECT inventory.id, inventory.title, category.title, cost FROM inventory left join category on inventory.category_id = category.id;"))
                {
                    if (data != null)
                    {
                        while (data.Read())
                        {

                            var p = new ProductItem(data.GetUInt16(0), data.GetString(1), "", data.GetDecimal(3), Role.Instance.AddToShopCart);
                            p.Dock = DockStyle.Top;
                            tlpProduct.Controls.Add(p);
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }