Пример #1
0
        public JobObject(Product product, int multiplier)
        {
            this.Product = product;
            this.Multiplier = multiplier;

            this.TotalPrizeExcl = this.Product.ExclVat * this.Multiplier;
            this.TotalPrizeIncl = this.Product.Prize * this.Multiplier;
            this.prizeString = helperFunctions.prizeToString(TotalPrizeExcl);
        }
        private void productViewer_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try {
                this.selectedProduct = (Product)e.AddedItems[0];
            } catch {
                return;
            }

            this.descText.Text = this.selectedProduct.Description;
            string[] exBTW = helperFunctions.getTextFromPrize(this.selectedProduct.ExclVat);
            string inclBTW = helperFunctions.prizeToString(this.selectedProduct.Prize);

            this.exBTWEuros.Text = exBTW[0];
            this.exBTWCents.Text = exBTW[1];

            this.inclPrize.Content = inclBTW;
            this.brandText.Text = this.selectedProduct.Brand;
        }
Пример #3
0
        private IList<JobObject> getProductsOnJob(int id, IDbTransaction transaction)
        {
            IDbCommand command = this.databaseFactory.CreateCommand();
            command.CommandText = String.Format(@"SELECT
            {0}.amount, {1}.id, {1}.description, {1}.prize, {1}.type, {1}.size, {2}.name FROM {0}
            JOIN {1} ON {0}.product_id = {1}.id
            LEFT JOIN {2} ON {1}.brand = {2}.id
            WHERE {0}.job_id = {3}",
                dbConstants.jobLinkProdTable, dbConstants.productTable, dbConstants.brandsTable, id);

            command.CommandType = CommandType.Text;
            command.Connection = transaction.Connection;

            IList<JobObject> result = new List<JobObject>();
            try {
                using (IDataReader reader = command.ExecuteReader()) {
                    while (reader.Read()) {
                        int amount = reader.GetInt32(reader.GetOrdinal("amount"));
                        string desc = reader.GetString(reader.GetOrdinal("description"));
                        string brand = reader.GetString(reader.GetOrdinal("name"));
                        int prize = reader.GetInt32(reader.GetOrdinal("prize"));
                        int type = reader.GetInt32(reader.GetOrdinal("type"));
                        string size = reader.GetString(reader.GetOrdinal("size"));
                        Product prod = new Product(id, desc, prize, brand, size, type);
                        result.Add(new JobObject(prod, amount));
                    }
                }
            } catch (Exception e) {
                throw new Exception("[getProductsOnJob] " + e);
            }
            return result;
        }