Exemplo n.º 1
0
        public static void AddPosition(string code, string number)
        {
            var info = WareHouseDBController.Find(code);

            if (info.Any())
            {
                var amount = number.Length != 0
                    ? double.Parse(number, CultureInfo.InvariantCulture)
                    : 1;
                var item = new CheckLine(new ProductData(info), amount);
                var availablePosition = ItemsPositions.Where(x => (x as CheckLine).Data.EAN13 == code);
                if (availablePosition.Any())
                {
                    (availablePosition.FirstOrDefault() as CheckLine).Amount += amount;
                }
                else
                {
                    ItemsPositions.Add(item);
                }
            }
            else
            {
                MessageBox.Show(String.Format(LanguageEngine.Language["FastInvoiceActivity AddPositionErrorMessageBox"], code),
                                LanguageEngine.Language["FastInvoiceActivity AddPositionErrorMessageBoxTitle"], MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        public static void AddUserPosition(string infoStr)
        {
            var usersInfo = UserDBController.FindLike(infoStr);

            if (usersInfo.Any())
            {
                foreach (var userInfo in usersInfo)
                {
                    var currentUser = new User(userInfo);
                    if (!(ItemsPositions
                          .Select(x => (x as User))
                          .Where(x => x.Name == currentUser.Name || x.Id == currentUser.Id)
                          .Any()))
                    {
                        ItemsPositions.Add(currentUser);
                    }
                    else if (usersInfo.Count == 1)
                    {
                        MessageBox.Show(LanguageEngine.Language["UserControlServiceActivity AlreadyExist"],
                                        LanguageEngine.Language["UserControlServiceActivity AlreadyExistTitle"], MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show(LanguageEngine.Language["UserControlServiceActivity NotFound"],
                                LanguageEngine.Language["UserControlServiceActivity NotFoundTitle"], MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 3
0
 public static void AddPositionForSaving(string code)
 {
     if (code.Length == 13)
     {
         var availablePosition = ItemsPositions.Where(x => (x as DBProductData).Data.EAN13 == code);
         if (availablePosition.Any())
         {
             MessageBox.Show(String.Format(LanguageEngine.Language["WareHouseActivity PositionContainsQuestion"], code),
                             LanguageEngine.Language["WareHouseActivity PositionContainsQuestionTitle"], MessageBoxButton.OK, MessageBoxImage.Error);
         }
         else
         {
             var info = WareHouseDBController.Find(code);
             if (!info.Any())
             {
                 ItemsPositions.Add(new DBProductData(new ProductData(code), false));
             }
             else if (MessageBox.Show(String.Format(LanguageEngine.Language["WareHouseActivity ContainsQuestion"], code),
                                      LanguageEngine.Language["WareHouseActivity ContainsQuestionTitle"], MessageBoxButton.YesNo,
                                      MessageBoxImage.Question) == MessageBoxResult.Yes)
             {
                 if (!ItemsPositions.Where(x => (x as DBProductData).Data.EAN13 == code).Any())
                 {
                     ItemsPositions.Add(new DBProductData(new ProductData(info), true));
                 }
             }
         }
     }
     else
     {
         MessageBox.Show(LanguageEngine.Language["WareHouseActivity EAN13FormatError"],
                         LanguageEngine.Language["WareHouseActivity EAN13FormatErrorTitle"], MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 4
0
        public static bool AddNewUser(User newUser, string password)
        {
            var newUserHash = GetHash(password);

            try
            {
                UserDBController.Add(newUser.Id, newUser.Name, newUser.AccessLevel, newUserHash);
            }
            catch (System.Data.SQLite.SQLiteException)
            {
                return(false);
            }
            ItemsPositions.Add(newUser);
            return(true);
        }
Exemplo n.º 5
0
        private static void FillEmployeeStatistic(string cashierName, long fromTime, long toTime)
        {
            List <Invoice> data = new List <Invoice>();
            var            info = DBController.SQLNonVoidCommand(
                $"SELECT Data FROM documents WHERE CashierName='{cashierName}' AND DateTime BETWEEN {fromTime} AND {toTime}");
            var jsons = info.Select(x => x.First()).ToList();

            foreach (var json in jsons)
            {
                data.Add(JsonConvert.DeserializeObject <Invoice>(json));
            }
            if (data.Count != 0)
            {
                ItemsPositions.Add(new EmployeeStatistic(data));
            }
        }
Exemplo n.º 6
0
 public static void AddStatisticsPositions(string name, long fromTime, long toTime)
 {
     ItemsPositions.Clear();
     if (name == LanguageEngine.Language["StatisticsActivity All"])
     {
         foreach (var user in GetUsersList())
         {
             FillEmployeeStatistic(user, fromTime, toTime);
         }
         ItemsPositions.Add(new EmployeeStatistic(
                                LanguageEngine.Language["StatisticsActivity Total"],
                                ItemsPositions.Select(x => ((EmployeeStatistic)x).Invoices).Sum(),
                                ItemsPositions.Select(x => ((EmployeeStatistic)x).Total).Sum()));
     }
     else
     {
         FillEmployeeStatistic(name, fromTime, toTime);
     }
 }