Пример #1
0
 public CaisseViewModelTest()
 {
     testP   = new Product(5555, "hi", 2.5f, 2.8f, "hihiih", 85, true);
     testBDE = new BDE(85, "hibde", "info", "fdfdsfd");
     collectionP.Add(testP);
     collectionBDE.Add(testBDE);
 }
        public static bool AddUser(string name, string clearTextPassword, BDE bde, bool isActive, bool isAdmin)
        {
            try
            {
                using (var context = new DBConnection())
                {
                    var userToAdd = new User()
                    {
                        Nom           = name,
                        CodePersonnel = clearTextPassword,
                        IdBDE         = bde.Id,
                        IsActive      = isActive,
                        IsAdmin       = isAdmin,
                    };

                    context.User.Add(userToAdd);
                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new ConnectionFailedException(ex.Message, ex);
            }
        }
 private void ShowAll()
 {
     selectedBDE = null;
     OnPropertyChanged("ListTickets");
     OnPropertyChanged("SaleTotal");
     OnPropertyChanged("ProfitTotal");
     OnPropertyChanged("MargeTotal");
 }
        public ProductListViewModelTest()
        {
            testP   = new Product(5555, "hi", 2.5f, 2.8f, "hihiih", 85, true);
            testBDE = new BDE(85, "hibde", "info", "fdfdsfd");
            Singleton <User> .SetInstance(new User(0, "hi", "hi", testBDE, "BaseDark", "Indigo", "thomas", true, null));

            collectionP.Add(testP);
            collectionBDE.Add(testBDE);
        }
 private void updateInfo(object sender)
 {
     ListBDE     = new ObservableCollection <BDE>(persistance.GetBDEList().Where(b => b.Account.ID == Singleton <User> .GetInstance().Account.ID).ToList());
     listTickets = persistance.GetTicketsDB();
     selectedBDE = null;
     OnPropertyChanged("ListTickets");
     OnPropertyChanged("SaleTotal");
     OnPropertyChanged("ProfitTotal");
     OnPropertyChanged("MargeTotal");
 }
Пример #6
0
        private void MainWindowView_OnLoaded(object sender, RoutedEventArgs e)
        {
            // Set buying BDE to default buying BDE : user's own BDE
            BDE currentBDE = LoginService.Instance.GetLoginContext().BuyingBDE;

            for (int i = 0; i < ComboBox.Items.Count; i++)
            {
                if (((BDE)ComboBox.Items[i]).idBDE == currentBDE.idBDE)
                {
                    ComboBox.SelectedIndex = i;
                }
            }
        }
Пример #7
0
        /// <summary>
        /// returns the collection of BDE from database
        /// </summary>
        /// <returns>the collection of BDE from database</returns>
        public Collection <BDE> GetBDEList()
        {
            var bdeList = new Collection <BDE>();
            var user    = Singleton <User> .GetInstance();

            DataTable dt = db.Select($"SELECT * FROM bde");

            foreach (DataRow dr in dt.Rows)
            {
                var acc = GetAccountFromID(int.Parse(dr["accountid"].ToString()));
                BDE bde = new BDE(int.Parse(dr["idBDE"].ToString()), dr["name"].ToString(), dr["departement"].ToString(), dr["imageUrl"].ToString(), acc);
                bdeList.Add(bde);
            }
            return(bdeList);
        }
Пример #8
0
        public async void AddBasketToDB(BDE bdeChosen, BaseMetroDialog dialog)
        {
            var totalPrice = TotalPrice;
            var key        = DateTime.Now.ToString().GetHashCode().ToString("x");
            var u          = Singleton <User> .GetInstance();

            var ticket = new Ticket(key, new DateTime(), bdeChosen, BasketItems, u, u.Account, reductionQuantity * 0.2f);

            persistance.AddTicket(ticket);
            await dialogCoordinator.HideMetroDialogAsync(this, dialog);

            await main.ShowMessageAsync("Encaissement Réussi", $"Un montant de {totalPrice.ToString("C2")} a été encaissé au {bdeChosen.Name} avec le ticket {key}");

            ClearBasket();
        }
Пример #9
0
        private async void addBasketToDB(BDE bdeChosen)
        {
            var totalPrice = baskets.Sum(items => items.quantity * items.ItemProduct.Price);
            var key        = DateTime.Now.ToString().GetHashCode().ToString("x");
            var u          = Singleton <User> .GetInstance();

            var ticket = new Ticket(key, new DateTime(), bdeChosen, baskets, u, u.Account, reduction);

            persistance.AddTicket(ticket);
            await dialog.HideCurrentDialog();

            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Deconnexion",
                NegativeButtonText    = "Retour au vente",
                AnimateShow           = true,
                AnimateHide           = true,
            };
            var controller = await main.ShowProgressAsync("Encaissement Réussi", $"\nUn montant de {ticket.TotalPaid} a été encaissé au {bdeChosen.Name} avec le ticket {key}\n\nAppuyez sur 'Retour au vente'. Sinon dans 10 seconds, vous allez etre deconnecter.", settings : mySettings);

            controller.SetCancelable(true);
            double i = 0.0;

            while (i < 100.0)
            {
                double val = (i / 100.0);
                controller.SetProgress(val);
                int seconds = (100 - Convert.ToInt32(i)) / 20;
                controller.SetMessage($"\nUn montant de {ticket.TotalPaid} a été encaissé au {bdeChosen.Name} avec le ticket {key}\n\nRetour au vente dans {seconds} seconds.");


                if (controller.IsCanceled)
                {
                    break; //canceled progressdialog auto closes.
                }
                i += 1.0;

                await Task.Delay(50);
            }

            await controller.CloseAsync();

            Singleton <Event> .GetInstance()?.InvolveClearBasket();

            Singleton <Event> .GetInstance()?.InvolveUpdateProduct();
        }
Пример #10
0
        public User GetUserfromID(int id)
        {
            var m = new Dictionary <string, object>()
            {
                { "@id", id }
            };
            DataTable dt = db.Select("SELECT * FROM users where userID=@id", m);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            DataRow dr         = dt.Rows[0];
            BDE     bde        = GetBDEByID(int.Parse(dr["bdeID"].ToString()));
            Account acc        = GetAccountFromID(int.Parse(dr["accountid"].ToString()));
            User    authedUser = new User(int.Parse(dr["userID"].ToString()), dr["username"].ToString(), dr["name"].ToString(), bde, dr["theme"].ToString(), dr["accent"].ToString(), dr["md5password"].ToString(), dr["isAdmin"].ToString() == "1", acc);

            return(authedUser);
        }
Пример #11
0
        public User GetUserfromCredentials(string username, string password)
        {
            string md5password = Crypto.CalculateMD5Hash(password);
            var    m           = new Dictionary <string, object>
            {
                { "@user", username },
                { "@pass", md5password }
            };
            DataTable dt = db.Select("SELECT * FROM users where username = @user and md5password = @pass", m);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            DataRow dr         = dt.Rows[0];
            BDE     bde        = GetBDEByID(int.Parse(dr["bdeID"].ToString()));
            Account acc        = GetAccountFromID(int.Parse(dr["accountid"].ToString()));
            User    authedUser = new User(int.Parse(dr["userID"].ToString()), dr["username"].ToString(), dr["name"].ToString(), bde, dr["theme"].ToString(), dr["accent"].ToString(), dr["md5password"].ToString(), dr["isAdmin"].ToString() == "1", acc);

            return(authedUser);
        }
Пример #12
0
 public PerfilAcesso()
 {
     bdeForm      = new BDE(this);
     workshopForm = new Workshop(this);
 }