コード例 #1
0
ファイル: Shop.cs プロジェクト: groovu/Taco-Shop-Simulator
        public ingredients getIngredient(string ingredient, TacoDBEntity db)
        {
            var q = (from u in db.ingredients where u.ingredient == ingredient select u).FirstOrDefault();

            if (q == null)
            {
                throw new Exception("Ingredient not found.");
            }
            else
            {
                return((ingredients)q);
            }
        }
コード例 #2
0
ファイル: Shop.cs プロジェクト: groovu/Taco-Shop-Simulator
        internal void updateStock(List <buyItem> list, TacoDBEntity db)
        {
            //this is the ugliest thing I've ever written.
            //lesson: plan out your objects data structures
            //well in advance, so you don't have to do
            //bootleg things like this.
            //Dictionary<string, int> dict = new Dictionary<string, int>();
            //foreach (buyItem b in list)
            //{
            //    dict.Add(b.Ingredient, b.Qty);
            //}
            //Dictionary<ingredients, int> newStock = new Dictionary<ingredients, int>();
            //List<ingredients> removeStock = new List<ingredients>();
            //foreach (var i in stock)
            //{
            //    string ingr = i.Key.ingredient;
            //    if (dict.ContainsKey(ingr))
            //    {
            //        removeStock.Add(i.Key);
            //        newStock.Add(i.Key, i.Value + dict[ingr]);
            //    }
            //}
            //foreach (var i in removeStock)
            //{
            //    stock.Remove(i);
            //}
            //foreach (var i in newStock)
            //{
            //    stock.Add(i.Key, i.Value);
            //}

            foreach (buyItem b in list)
            {
                string name   = b.Ingredient;
                var    ingObj = getIngredient(name, db);
                if (stock.ContainsKey(ingObj))
                {
                    int qty = stock[ingObj] + b.Qty;
                    stock.Remove(ingObj);
                    stock.Add(ingObj, qty);
                }
                else
                {
                    stock.Add(ingObj, b.Qty);
                }
            }
        }
コード例 #3
0
        public Messenger(TacoDBEntity database, int userID)
        {
            id = userID;
            db = database;
            InitializeComponent();
            List <int> a = new List <int>();

            for (int i = 0; i < 10; i += 1)
            {
                a.Add(i);
            }
            //msgBox.ItemsSource = a;
            var q = (from u in db.login where u.id == id select u).FirstOrDefault();

            this.Title = "Messenger " + q.username;
            populateMessageList();
        }
コード例 #4
0
        //Utils u = Utils;
        public UserWindow(TacoDBEntity db, int id, MainWindow win)
        {
            prevWin = win; this.db = db; //sets previousWindow and db for use.
            getIngrAndRecipes();         //populates all ingredients and recipes from db.
            user = GetUser(id);          //init user class
            shop = GetShop(user);        //init shop from user

            InitializeComponent();       //default thingo
            newUserCheck();

            initData(shop); //init UserWindow using shop.

            hideAllGroups();
            setUpLabels();
            homeGroup.Visibility = Visibility.Visible;

            this.Closed  += new EventHandler(UserWindowClose);
            this.Closing += new CancelEventHandler(UserWindowConfirmClose);
        }
コード例 #5
0
        public AdminWindow(TacoDBEntity database, MainWindow window)
        {
            InitializeComponent();
            db           = database;
            prevWindow   = window;
            this.Closed += new EventHandler(AdminWindowClose);

            //adminUserGrid.DataContext = db.userDatas.Local;
            //DataTable blah = db.userDatas.Fill
            //adminUssdsderGrid.DataContext = db.userDatas.SingleOrDefault(i => i.id == 3);
            //var blah = db.userDatas.OrderBy(a => a.id);
            //var blah = db.userDatas.Sql;
            var blah  = db.userData.SingleOrDefault(i => i.id == 3); //fetches row
            var blah2 = from item in  db.userData select item;
            var query = db.userData.Where(x => true).ToList();

            adminUserGrid.ItemsSource = query.ToList();
            adminIngrGrid.ItemsSource = db.ingredients.Where(x => true).ToList();
            adminRecpGrid.ItemsSource = db.recipes.Where(x => true).ToList();
        }
コード例 #6
0
 public NewUser(TacoDBEntity database, MainWindow login)
 {
     db       = database;
     loginWin = login;
     InitializeComponent();
 }