Beispiel #1
0
        public void Execute(object parameter)
        {
            ScannedProduct s  = (ScannedProduct)parameter;
            EditProduct    ep = new EditProduct(ref s);

            VM.LoadEditProductView(ep);
        }
Beispiel #2
0
 public void update_ScannedProduct(ScannedProduct sp)
 {
     if (sp != null)
     {
         rep.update_ScannedProduct(sp);
     }
 }
Beispiel #3
0
 public EditProduct(ref ScannedProduct sp)
 {
     _sp = sp;
     InitializeComponent();
     VM = new EditProductVM(this, ref _sp);
     this.DataContext = VM;
 }
 public EditProductVM(EditProduct view, ref ScannedProduct s)
 {
     this.View  = view;
     this.sp    = s;
     this.p     = new BLimp().getProductByScannedProduct(sp);
     NumberList = new ObservableCollection <int>(Enumerable.Range(0, 1000));
 }
Beispiel #5
0
        public void add_ScannedProduct(ScannedProduct scan, string name)
        {
            using (var context = new ProductDB())
            {
                var arr = (from p in context.products where p.num == scan.productNo select p).ToList <Product>();
                if (arr.Count == 0)
                {
                    add_Product(new Product(scan.productNo, name, "", null));
                }
                //var temp = context.scans.FirstOrDefault(value => value.productNo == scan.productNo && value.store.Equals(scan.store) && (DbFunctions.TruncateTime(scan.dateScan) == (DbFunctions.TruncateTime(value.dateScan))));
                //if (temp != null)
                //{
                //    temp.amount++;
                //    context.SaveChanges();

                //    // update_ScannedProduct(temp);
                //}
                //if (temp == null)
                //{
                //    context.scans.Add(scan);
                //    context.SaveChanges();
                //}
                context.scans.Add(scan);
                context.SaveChanges();
            }
        }
        private void SaveStream(System.IO.MemoryStream stream, string saveTo)
        {
            using (System.IO.FileStream file = new System.IO.FileStream(saveTo, System.IO.FileMode.Create, System.IO.FileAccess.Write))
            {
                stream.WriteTo(file);
            }
            DAL.Barcode_reader reader = new Barcode_reader();

            string text = reader.Decode(saveTo);

            string time     = saveTo.Substring(saveTo.Length - 1 - 9 - 3, 6);
            string hour     = time.Substring(0, 2);
            string minnutes = time.Substring(2, 2);
            string dayNight = time.Substring(4, 2);

            if (dayNight == "PM")
            {
                hour = (Int32.Parse(hour) + 12).ToString();
            }
            int      y        = saveTo.IndexOf("at") - saveTo.IndexOf("Barcodes") - 10;
            string   x        = saveTo.Substring(saveTo.IndexOf("Barcodes") + 9, y);
            DateTime dateTime = DateTime.Parse(x + " " + hour + ":" + minnutes + ":" + "00" + " " + dayNight);

            string[]       str = text.Split('-');
            ScannedProduct s   = new ScannedProduct(Int32.Parse(str[4]), str[3], dateTime, float.Parse(str[2]), Int32.Parse(str[1]));

            rep.saveProductFromDrive(s, str[0]);
        }
        public void Execute(object parameter)
        {
            ScannedProduct s  = (ScannedProduct)parameter;
            BLimp          bl = new BLimp();

            bl.delete_ScannedProduct(s);
            VM.worker.RunWorkerAsync();
        }
Beispiel #8
0
        public Product getProductByScannedProduct(ScannedProduct sp)
        {
            Product result;

            using (var context = new ProductDB())
            {
                result = context.products.FirstOrDefault(value => value.num == sp.productNo);
            }
            return(result);
        }
Beispiel #9
0
        public void delete_ScannedProduct(ScannedProduct scan)
        {
            using (var context = new ProductDB())
            {
                var old = context.scans.Find(scan.Id);
                context.scans.Remove(old);

                context.SaveChanges();
            }
        }
Beispiel #10
0
 public bool isInScannedProductInDay(int value, string dt)
 {
     using (var context = new ProductDB())
     {
         ScannedProduct p = context.scans.Find(value);
         if (p == null)
         {
             return(false);
         }
         return(p.dateScan.DayOfWeek.ToString() == dt);
     }
 }
Beispiel #11
0
        public ScannedProduct connectSqlServer()
        {
            ScannedProduct res = new ScannedProduct();

            using (var db = new ProductDB())
            {
                if (db.scans != null)
                {
                    res = db.scans.FirstOrDefault(value => value.Id >= 0);
                }
            }
            return(res);
        }
Beispiel #12
0
        public void update_ScannedProduct(ScannedProduct scan)
        {
            using (var context = new ProductDB())
            {
                var old = context.scans.Find(scan.Id);
                old.amount   = scan.amount;
                old.cost     = scan.cost;
                old.dateScan = scan.dateScan;
                old.rating   = scan.rating;
                old.store    = scan.store;

                context.SaveChanges();
            }
        }
Beispiel #13
0
        private static void SelectShopAndFilter(string path, List <ScannedProduct> SProducts)
        {
            string[] Shops      = new string[] { "MAXIMA", "LIDL", "PALINK", "RIMI", "NORFA" };
            string   ShopResult = Shops.FirstOrDefault <string>(s => tempStr[0].ToUpper().Contains(s));

            switch (ShopResult)
            {
            case "MAXIMA":
                tempStr[0] = "xxx";
                Scan(path, SProducts);
                break;

            case "LIDL":
                tempStr[0] = "xxx";
                ScanLidl(path, SProducts);
                break;

            case "PALINK":
                tempStr[0] = "xxx";
                ScanIki(path, SProducts);
                break;

            case "RIMI":
                tempStr[0] = "xxx";
                Scan(path, SProducts);
                break;

            case "NORFA":
                tempStr[0] = "xxx";
                Scan(path, SProducts);
                break;

            default:
                ScannedProduct Spr = new ScannedProduct()
                {
                    Name = "Could not detect Shop!"
                };
                SProducts.Add(Spr);
                break;
            }
        }
        public void AddProduct(Product Pr)
        {
            IEnumerable <IEnumerable <Product> > products = DataProcessor.LoadJson <IEnumerable <Product> >(Tools.Utils.ProductsPath);
            IEnumerable <Product> filteredProducts        = new List <Product>();

            filteredProducts = products.SelectMany(iepr => iepr.Where(Prod =>
                                                                      Prod.Name == Pr.Name &&
                                                                      Prod.PriceUnit == Pr.PriceUnit &&
                                                                      Prod.Category == Pr.Category &&
                                                                      Prod.Shop == Pr.Shop));

            ScannedProduct pr = new ScannedProduct()
            {
                Shop      = Pr.Shop,
                Name      = Pr.Name,
                PriceUnit = Pr.PriceUnit,
                Price     = Convert.ToDouble(Pr.Price),
                Id        = (from fil in filteredProducts
                             select fil.Id).First()
            };

            ProductEditor.AddProducts(pr);
        }
Beispiel #15
0
 public static void PickProducts(this string[] tempStr, Shops shop, string path, List <ScannedProduct> SProducts)
 {
     foreach (string line in tempStr)
     {
         string query = line.ToLower().Trim();
         IEnumerable <Product> filtered = SearchAndFind.SearchForProduct(query, path);
         foreach (Product pr in filtered)
         {
             if (pr.Shop == shop)
             {
                 ScannedProduct Spr = new ScannedProduct()
                 {
                     Shop      = pr.Shop,
                     Name      = pr.Name,
                     PriceUnit = pr.PriceUnit,
                     Price     = Convert.ToDouble(pr.Price),
                     Id        = pr.Id
                 };
                 SProducts.Add(Spr);
             }
         }
     }
 }
Beispiel #16
0
 public static void AddProducts(ScannedProduct pr)
 {
     ScannedProducts.Add(pr);
 }
Beispiel #17
0
 public void saveProductFromDrive(ScannedProduct s, string name)
 {
     add_ScannedProduct(s, name);
 }
Beispiel #18
0
 public void add_ScannedProduct(ScannedProduct scan, string name)
 {
     rep.add_ScannedProduct(scan, name);
 }
Beispiel #19
0
 public void delete_ScannedProduct(ScannedProduct s)
 {
     rep.delete_ScannedProduct(s);
 }
Beispiel #20
0
 public void connectSqlServer()
 {
     rep.resetLastDate();
     new DAL.GoogleDriveApi().Connect(DateTime.Parse(rep.getLastDate().lastDate));
     ScannedProduct s = rep.connectSqlServer();
 }