Esempio n. 1
0
        private SimplePOS.Article.RegularArticle getArticleByNumberCore(string number, IObjectContainer db)
        {
            SimplePOS.Article.RegularArticle query = new SimplePOS.Article.RegularArticle(number);
            IObjectSet result = db.QueryByExample(query);

            if (result.Count > 0)
            {
                return((SimplePOS.Article.RegularArticle)result[0]);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 public SimplePOS.Article.RegularArticle GetArticleByNumber(string number)
 {
     SimplePOS.Article.RegularArticle retval = null;
     using (IObjectContainer db = Db4oEmbedded.OpenFile(DB_FILNAME))
     {
         try
         {
             retval = getArticleByNumberCore(number, db);
         }
         finally
         {
             db.Close();
         }
     }
     return(retval);
 }
Esempio n. 3
0
 public void SaveArticle(SimplePOS.Article.RegularArticle article)
 {
     using (IObjectContainer db = Db4oEmbedded.OpenFile(DB_FILNAME))
     {
         try
         {
             if (getArticleByNumberCore(article.Number, db) != null)
             {
                 // alte Artikel Löschen
                 deleteArticleByNumberCore(article.Number, db);
             }
             db.Store(article);
         }
         finally
         {
             db.Close();
         }
     }
 }
Esempio n. 4
0
        // Speichern Button
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            // Check for article number
            if (textBox1.Text == "")
            {
                MessageBox.Show("Bitte eine Artikel Nr. eingeben.", "",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            // build article
            double price = 0;
            double tax   = 0;

            try { price = Double.Parse(textBox3.Text); }
            catch
            {
                MessageBox.Show("Fehlerhafte Preisangabe!", "",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (comboBox1.SelectedIndex == 0)
            {
                tax = Preferences.PreferenceManager.TAX_1;
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                tax = Preferences.PreferenceManager.TAX_2;
            }
            string name = textBox2.Text;

            if (name == "")
            {
                name = textBox1.Text;
            }
            RegularArticle article = new RegularArticle
                                         (textBox1.Text, name, textBox4.Text, price, tax);

            // save to database
            db.SaveArticle(article);
            db.AddItemToStock(new SimplePOS.Inventory.SaveableStockItem(article.number, 0));

            this.Close();
        }
Esempio n. 5
0
 public ArticleView(ISposDb db, RegularArticle article)
     : this(db)
 {
     textBox1.Text      = article.Number;
     textBox1.IsEnabled = false;
     textBox2.Text      = article.Name;
     if (article.Name.Length != 0 && article.Price != 0)
     {
         textBox3.Text = string.Format("{0:0.00}", article.Price);
     }
     textBox4.Text = article.Text;
     double tax = article.Tax;
     if (article.Tax == Preferences.PreferenceManager.TAX_1)
     {
         comboBox1.SelectedIndex = 0;
     }
     else if (article.Tax == Preferences.PreferenceManager.TAX_2)
     {
         comboBox1.SelectedIndex = 1;
     }
     //textBox5.Text = article.Tax.ToString(); translater klasse (enum?)
 }
Esempio n. 6
0
        public List <SimplePOS.Article.RegularArticle> GetAllArticles()
        {
            List <SimplePOS.Article.RegularArticle> retval = null;

            using (IObjectContainer db = Db4oEmbedded.OpenFile(DB_FILNAME))
            {
                try
                {
                    retval = new List <SimplePOS.Article.RegularArticle>();
                    SimplePOS.Article.RegularArticle query = new SimplePOS.Article.RegularArticle();
                    IObjectSet result = db.QueryByExample(query);
                    foreach (Object item in result)
                    {
                        retval.Add((SimplePOS.Article.RegularArticle)item);
                    }
                }
                finally
                {
                    db.Close();
                }
            }
            return(retval);
        }
Esempio n. 7
0
        public void SaveArticle(SimplePOS.Article.RegularArticle article)
        {
            mutex.WaitOne();
            connection.Open();
            using (SQLiteCommand command = new SQLiteCommand(connection))
            {
                //delete old article
                command.CommandText = "DELETE FROM article WHERE item_id LIKE ?;";
                command.Parameters.Add(new SQLiteParameter("item_id", article.Number));
                command.ExecuteNonQuery();

                command.Parameters.Clear();
                command.CommandText = "INSERT INTO article (item_id, item_name, " +
                                      "item_text, price, tax) VALUES (?,?,?,?,?);";
                command.Parameters.Add(new SQLiteParameter("item_id", article.Number));
                command.Parameters.Add(new SQLiteParameter("item_name", article.Name));
                command.Parameters.Add(new SQLiteParameter("item_text", article.Text));
                command.Parameters.Add(new SQLiteParameter("price", article.Price));
                command.Parameters.Add(new SQLiteParameter("tax", article.Tax));
                command.ExecuteNonQuery();
            }
            connection.Close();
            mutex.Release();
        }
Esempio n. 8
0
        public SimplePOS.Article.RegularArticle GetArticleByNumber(string number)
        {
            mutex.WaitOne();
            SimplePOS.Article.RegularArticle retval = null;
            connection.Open();
            using (SQLiteCommand command = new SQLiteCommand(connection))
            {
                command.CommandText = "SELECT item_id, item_name, item_text, price, tax " +
                                      "FROM article WHERE item_id LIKE ? ORDER BY item_id LIMIT 1;";
                command.Parameters.Add(new SQLiteParameter("item_id", number));
                SQLiteDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    retval = new SimplePOS.Article.RegularArticle(reader[0].ToString(),
                                                                  reader[1].ToString(), reader[2].ToString(), (double)reader[3],
                                                                  (double)reader[4]);
                }
                reader.Close();
            }
            connection.Close();
            mutex.Release();
            return(retval);
        }