Exemplo n.º 1
0
        public static void RecordSale(Sale sale) {
            string sql = "SELECT MAX(saleId) FROM `cafe_sales`";
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            object result = cmd.ExecuteScalar();
            int saleId = Convert.ToInt32(result) + 1;   //Hämta högsta saleId och öka med 1

            string type = sale.arbetsGladje == true ? "work" : "default";
            sql = "INSERT INTO `cafe_sales` (saleId, articleId, timestamp, income, cost, type, discountId, invoiceId) VALUES (\'" + saleId + "\', \'" + sale.articleID + "\', NOW(), \'" + sale.price + "\', \'" + sale.cost + "\', \'" + type + "\', \'0\', \'0\')";
            cmd = new MySqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
        }
Exemplo n.º 2
0
        public static Sale ArticleNameToSale(string articleName) {
            Sale sale = new Sale();

            IEnumerable<Article> articles = from a in articleTable
                                            where a.name == articleName
                                            select a;

            Article article = articles.First();

            sale.articleID = article.id;
            sale.price = article.price;
            sale.cost = article.cost;
            sale.arbetsGladje = false;

            return sale;
        }