Esempio n. 1
0
        static void GetProductDetails()
        {
            if (null == produtListFromDB)
            {
                produtListFromDB = new List <DBProduct>();

                DataSet dataSet = MySqlHelper.GetAllProducts();
                var     table   = dataSet.Tables[0];

                foreach (DataRow row in table.Rows)
                {
                    string    productCode = row["code"].ToString();
                    string    description = row["description"].ToString();
                    string    barcode     = row["barcode"].ToString();
                    string    price       = row["price"].ToString();
                    string    partner     = row["partner"].ToString();
                    string    created_by  = row["created_by"].ToString();
                    DBProduct pd          = new DBProduct();
                    pd.Code        = productCode;
                    pd.Description = description;
                    pd.Barcode     = barcode;
                    pd.UnitPrice   = price;
                    pd.Partner     = partner;
                    pd.Creator     = created_by;
                    produtListFromDB.Add(pd);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Invokes this command to perform its intended task.
        /// </summary>
        public void Execute(object parameter)
        {
            if (null != m_ViewModel.ScannedItemBarcode)
            {
                int quantity = 1;

                if (null != m_ViewModel.ScannedQuantity)
                {
                    quantity = int.Parse(m_ViewModel.ScannedQuantity);
                }

                Product productFromDB = m_ViewModel.CheckIfProductExist(m_ViewModel.ScannedItemBarcode);
                if (null != productFromDB)
                {
                    productFromDB.Quantity = productFromDB.Quantity + quantity;
                    return;
                }

                DBProduct p = m_ViewModel.GetProductForBarcode(m_ViewModel.ScannedItemBarcode);
                if (null != p)
                {
                    Product modelp = new Product(m_ViewModel, p.Partner, quantity, p.Code, long.Parse(p.Barcode), p.Creator, p.Description, double.Parse(p.UnitPrice), m_ViewModel.ItemCount);

                    m_ViewModel.OBProductList.Add(modelp);
                }
                else
                {
                    MessageBoxResult result = MessageBox.Show("Scanned barcode does not exist in database", "Database Error", MessageBoxButton.OK);
                }
            }
        }