async void OnSaveButtonClicked(object sender, EventArgs e)
        {
            var product = (Product)BindingContext;
            await App.Database.SaveProductAsync(product);

            listView.ItemsSource = await App.Database.GetProductsAsync();

            var lp = new ListProduct()
            {
                SupplyListID = sl.ID,
                ProductID    = product.ID
            };

            var listProducts = await App.Database.GetListProductAsyncTest(sl.ID);

            foreach (var listProduct in listProducts)
            {
                if (listProduct.ProductID == product.ID)
                {
                    return;
                }
            }

            _listProduct         = lp;
            product.ListProducts = new List <ListProduct> {
                lp
            };

            await App.Database.SaveListProductAsync(_listProduct);

            ((Product)BindingContext).ID = 0;

            await Navigation.PopAsync();
        }
Esempio n. 2
0
        public void EditHandler(Object sender, EventArgs e)
        {
            listProduct = SharedUserData.addProduct;
            ListProduct obj   = (sender as Button).CommandParameter as ListProduct;
            int         index = listProduct.IndexOf(obj);

            //      AddProduct(content, true, index, counter);


            //  storeName.Text = "Update Item";
            autoComplete.Text = obj.items;
            Quantity.Text     = "" + obj.quantity;
            Size.SelectedItem = obj.size;
            Unit.SelectedItem = obj.unit;
            stores            = obj.store;
            storeSuburbs      = obj.storeSuburb;
            description.Text  = obj.description;
            updateState       = true;
            // counter.Text = ""+count;
            updateItemButton.Text = "Update Item";
            updateIndex           = index;

            CheckList();
            ListProduct();

            listSection.TranslateTo(0, 0, 100);
            listSection1.TranslateTo(0, 0, 100);

            listGrid.Height = 1;
        }
Esempio n. 3
0
        private async void DelProduct(object obj)
        {
            TableVisible = true;
            if (WpfMessageBox.Show("Удаление продуктов", "Вы действительно хотите удалить продукт(ы) ?", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
                Loading.Invoke(obj, null);
                await Task.Run(() =>
                {
                    List <Product> col = ListProduct.Where(item => item.IsSelected == true).ToList();
                    _model.db.ProductSet.RemoveRange(col);
                    _model.db.SaveChanges();
                    ListProduct = _model.db.ProductSet.ToList();



                    _waitHandle.Set();
                });

                _waitHandle.WaitOne();
                _can_edit = true;
                UpdateEv?.Invoke(obj, null);
                Loading?.Invoke(obj, null);
            }
            TableVisible = false;
        }
Esempio n. 4
0
        public void LoadData()
        {
            try
            {
                List <ListProduct> dataItems = new List <ListProduct>();
                //  title.Text = items.trollyTitle;

                StatusUpdate(items.status);
                string trollyData = "[" + items.trollyDetail + "]";
                List <Dictionary <string, object> > posts = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(trollyData);
                listView.ItemsSource = posts;


                foreach (Dictionary <string, object> i in posts)
                {
                    if (store == Convert.ToString(i["store"]))
                    {
                        ListProduct ob = new ListProduct()
                        {
                            detailItem = Convert.ToString(i["detailItem"])
                        };

                        dataItems.Add(ob);
                    }
                }

                listView.ItemsSource = dataItems;
            }catch (Exception ex)
            {
                DisplayAlert("", ExceptionManagement.LogException(ex), "Ok");
                //Exception Class
            }
        }
Esempio n. 5
0
        public ActionResult san_pham(int?type, int?page)
        {
            List <Product> list = ListProduct.Product_type(type);

            ViewBag.list = list;

            List <ProductType> types = ListProduct.getType();

            ViewBag.type = types;
            if (type == null)
            {
                list         = ListProduct.showProduct();
                ViewBag.list = list;
            }

            if (page == null && type == null)
            {
                page = 1;
            }
            List <Product> pages = ListProduct.getPage(page);

            int pageSize   = 12;
            int pageNumber = (page ?? 1);

            return(View(pages.ToPagedList(pageNumber, pageSize)));
        }
Esempio n. 6
0
        public ActionResult ShowWithNSX(int?MaNSX, int?MaLoaiSP, int?page)
        {
            IEnumerable <SanPham> ListProduct;
            NhaSanXuat            sp  = DB.NhaSanXuats.Single(p => p.MaNSX == MaNSX);
            LoaiSanPham           lsp = DB.LoaiSanPhams.SingleOrDefault(p => p.MaLoaiSP == MaLoaiSP);

            if (MaLoaiSP.HasValue)
            {
                ListProduct = DB.SanPhams.Where(p => p.SoLuongTon > 0 && p.DaXoa != true && p.MaNSX == MaNSX && p.MaLoaiSP == MaLoaiSP)
                              .OrderByDescending(p => p.NgayCapNhap)
                              .ToList();

                ViewBag.Title = "Sản phẩm " + lsp.TenLoai + " của nhà sản xuất : " + sp.TenNSX;
            }
            else
            {
                ListProduct = DB.SanPhams.Where(p => p.SoLuongTon > 0 && p.DaXoa != true && p.MaNSX == MaNSX)
                              .OrderByDescending(p => p.NgayCapNhap)
                              .ToList();

                ViewBag.Title = "Nhà sản xuất : " + sp.TenNSX;
            }
            ViewBag.MaLoaiSP = MaLoaiSP;
            ViewBag.MaNSX    = MaNSX;
            int pageNumber = (page ?? 1);

            return(View(ListProduct.ToPagedList(pageNumber, pagasize)));
        }
Esempio n. 7
0
        public async void DeleteHandler(Object sender, EventArgs e)
        {
            bool check = await DisplayAlert("", "Are you sure Delete this Item from list", "Yes", "Cancel");

            if (check)
            {
                ListProduct content = (sender as Button).CommandParameter as ListProduct;
                ShareUserData.addProduct.Remove(content);
            }

            list = ShareUserData.addProduct;
            listItems.Clear();
            if (list != null)
            {
                foreach (ListProduct listData in list)
                {
                    if (listData.store == titleStore)
                    {
                        listItems.Add(listData);
                    }
                }
                listView.ItemsSource = null;
                listView.ItemsSource = listItems;
            }
        }
Esempio n. 8
0
        public ActionResult nhat_ky()
        {
            List <Product> list = ListProduct.showProduct();

            ViewBag.pro = list;
            return(View());
        }
        private void dtgListProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            ListProduct product = new ListProduct();

            product.STT = Convert.ToInt32(this.dtgListProduct.CurrentRow.Cells[0].Value.ToString());
            if (product.STT <= 0)
            {
                return;
            }
            if (this.dtgListProduct.CurrentRow.Cells[1].Value is null)
            {
                this.dtgListProduct.CurrentRow.Cells[1].Value = "";
            }
            product.ProductID = this.dtgListProduct.CurrentRow.Cells[1].Value.ToString();
            if (this.dtgListProduct.CurrentRow.Cells[2].Value is null)
            {
                this.dtgListProduct.CurrentRow.Cells[2].Value = "";
            }
            product.ProductType = this.dtgListProduct.CurrentRow.Cells[2].Value.ToString();
            if (this.dtgListProduct.CurrentRow.Cells[3].Value is null)
            {
                this.dtgListProduct.CurrentRow.Cells[3].Value = "";
            }
            product.ProductName = this.dtgListProduct.CurrentRow.Cells[3].Value.ToString();
            QRController.UpdateQRProduct(product);
        }
        public ActionResult Frutas()
        {
            ListProduct miLista = new ListProduct("FRUTA");

            ViewBag.nameList = "Listado de Frutas";
            return(View("Product", miLista));
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string lblProductIDCut = lblProductID.Text.Replace(" ", "");
            string ProductIDCut    = lblProductIDCut.Trim() + txtProductID.Text;

            if (QRController.getProduct(ProductIDCut) != null)
            {
                MessageBox.Show("Sản phẩm này đã tồn tại", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            ListProduct product = new ListProduct();

            product.ProductID   = ProductIDCut;
            product.ProductType = this.cbxProductType.Text;
            product.ProductName = this.txtProductName.Text;
            if (QRController.AddProduct(product) == false)
            {
                MessageBox.Show("Lỗi thêm sản phẩm", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            BindingSource source = new BindingSource();

            source.DataSource = QRController.getListProduct();
            this.dtgListProduct.DataSource = source;
            this.btnSave.Enabled           = false;
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dtgListProduct.SelectedRows.Count <= 0)
            {
                return;
            }
            if (this.dtgListProduct.SelectedRows[0].Cells[1].Value is null)
            {
                MessageBox.Show("Không có giá trị để xoá", "Thông báo", MessageBoxButtons.OK);
            }
            else
            {
                ListProduct product = QRController.getProduct(this.dtgListProduct.SelectedRows[0].Cells[1].Value.ToString());
                if (QRController.DeleteProduct(product) == false)
                {
                    MessageBox.Show("Lỗi xoá sản phẩm", "Thông báo", MessageBoxButtons.OK);
                    return;
                }
            }

            BindingSource source = new BindingSource();

            source.DataSource = QRController.getListProduct();
            this.dtgListProduct.DataSource = source;

            this.btnDelete.Enabled = false;
        }
        public ActionResult Verduras()
        {
            ListProduct miLista = new ListProduct("VEGETAL");

            ViewBag.nameList = "Listado de Vegetales";
            return(View("Product", miLista));
        }
        public ActionResult Estrella()
        {
            ListProduct miLista = new ListProduct("STAR");

            ViewBag.nameList = "Productos Estrella";
            return(View("Product", miLista));
        }
        //ViewGroup
        public ActionResult ViewGroup(string titleidgroup, int?page)
        {
            GroupProduct gp = db.GroupProducts.Where(x => x.SeoUrl == titleidgroup && x.IsDisable == false).FirstOrDefault();

            if (gp == null)
            {
                return(RedirectToAction("HttpError404", "Error"));
            }

            ViewBag.GroupProduct = gp;
            int            currentPageIndex    = page.HasValue ? page.Value - 1 : 0;
            List <Product> ListProduct         = new List <Product>();
            List <Product> ListProductOfParent = db.Products.Include(x => x.GroupProduct).Where(x => x.GroupProduct.GroupProductId == gp.GroupProductId).OrderByDescending(x => x.Order).ToList();

            //nếu là nhóm cha thì lấy sản phẩm nhóm con và của chính nó(nếu có)
            if (gp.IdRoot == null)
            {
                ListProduct = db.Products.Include(x => x.GroupProduct).Where(x => x.GroupProduct.GroupProductParrent.GroupProductId == gp.GroupProductId).OrderByDescending(x => x.Order).ToList();
            }

            ListProduct.AddRange(ListProductOfParent);

            if (ListProduct == null)
            {
                ListProduct = new List <Product>();
            }

            return(View(ListProduct.ToPagedList(currentPageIndex, 12)));
        }
Esempio n. 16
0
        public ActionResult ListHouseWare()
        {
            var listProduct = new ListProduct();

            ViewBag.ListHouseWare = listProduct.listHouseWare();
            return(View());
        }
Esempio n. 17
0
        public DetailProject GetProjectById(int id)
        {
            List <ListProduct> listOfProducts = new List <ListProduct>();

            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Project
                    .Single(e => e.ProjectID == id && e.OwnerId == _userId);
                foreach (var product in entity.Products)
                {
                    var productToAdd = new ListProduct()
                    {
                        Name      = product.Name,
                        Price     = product.Price,
                        ProductID = product.ProductID
                    };
                    listOfProducts.Add(productToAdd);
                }
                return
                    (new DetailProject
                {
                    Name = entity.Name,
                    TypeOfProject = entity.TypeOfProject,
                    Notes = entity.Notes,
                    ProjectCost = entity.ProjectCost,
                    ProjectID = entity.ProjectID,
                    OwnerId = entity.OwnerId,
                    CustomerID = entity.CustomerID,
                    Products = listOfProducts
                });
            }
        }
    void Start()
    {
        TextAsset asset = Resources.Load("product2") as TextAsset;

        Products    = JsonUtility.FromJson <ListProduct>(asset.text);
        listProduct = Products.Products;    // save data from file to list
        Debug.Log("length of list" + string.Format(" {0} ", listProduct.Count));
    }
 public static bool UpdateQRProduct(ListProduct product)
 {
     using (var _context = new DBQuanLyMaQREntities())
     {
         _context.ListProduct.AddOrUpdate(product);
         _context.SaveChanges();
         return(true);
     }
 }
 public static bool DeleteProduct(ListProduct product)
 {
     using (var _context = new DBQuanLyMaQREntities())
     {
         var v = _context.ListProduct.Find(product.STT);
         _context.ListProduct.Remove(v);
         _context.SaveChanges();
         return(true);
     }
 }
Esempio n. 21
0
 public Task <int> SaveListProductAsync(ListProduct listp)
 {
     if (listp.ID != 0)
     {
         return(_database.UpdateAsync(listp));
     }
     else
     {
         return(_database.InsertAsync(listp));
     }
 }
Esempio n. 22
0
    public static ListProduct Parse(SqlString sqlString)
    {
        if (sqlString.IsNull)
        {
            return(Null);
        }
        ListProduct list = new ListProduct();

        list.ProductList = list.GetProductList(sqlString.Value);
        return(list);
    }
        // GET: GroupProduct
        public ActionResult Index(int?page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;

            List <Product> ListProduct = db.Products.Include(x => x.GroupProduct).Where(x => x.IsDisable == false).OrderByDescending(x => x.Order).ToList();

            if (ListProduct == null)
            {
                ListProduct = new List <Product>();
            }
            return(View(ListProduct.ToPagedList(currentPageIndex, 12)));
        }
Esempio n. 24
0
    void Start()
    {
        //string path = Application.streamingAssetsPath + "/" + "test.json";
        //string jsonText = System.IO.File.ReadAllText(path); // read file to text
        TextAsset asset = Resources.Load("test") as TextAsset;

        listProduct = JsonUtility.FromJson <ListProduct>(asset.text);
        int     i = 0;
        Product p = listProduct.Products[1];

        Debug.Log(p.uses);
    }
Esempio n. 25
0
        public void add_productEvent(Object sender, EventArgs e)
        {
            if (EntryValidation())
            {
                string itemProduct = autoComplete.Text;

                int    quantity = Convert.ToInt32(Quantity.Text);
                string sizes    = "";
                if (SizeEntryChange == 0)
                {
                    sizes = Size.Items[Size.SelectedIndex];
                }
                else
                {
                    sizes = SizeEntry.Text;
                }

                string unit = Unit.Items[Unit.SelectedIndex];
                //  string storeSuburbs = storeSuburb.Text;
                string      descriptions = description.Text;
                ListProduct ob           = new ListProduct()
                {
                    items       = itemProduct,
                    unit        = unit,
                    quantity    = quantity,
                    size        = sizes,
                    store       = stores,
                    storeSuburb = storeSuburbs,
                    description = descriptions,
                    detailItem  = quantity + " " + unit + " " + itemProduct + " " + sizes + " FROM " + stores
                };
                list.Add(ob);

                ShareUserData.addProduct = list;

                string item = quantity + " " + unit + " " + itemProduct + " FROM " + stores;


                autoComplete.Text = "";
                // storeSuburb.Text = "";
                description.Text    = "";
                Quantity.Text       = "";
                Size.IsVisible      = true;
                SizeEntry.IsVisible = false;
                Size.SelectedIndex  = 3;
                SizeEntryChange     = 0;
                Unit.SelectedIndex  = -1;
            }
            //list.Add(item);

            //  DisplayAlert("Test", itemProduct, "ok");
        }
Esempio n. 26
0
        private bool CanDelPeoduct(object obj)
        {
            List <Product> item = ListProduct.Where(i => i.IsSelected == true).ToList();

            if (item.Count() > 0)
            {
                return(true);
            }



            return(false);
        }
Esempio n. 27
0
        public ActionResult Index(int?type)
        {
            List <Product>     list  = ListProduct.Product_type(type);
            List <ProductType> types = ListProduct.getType();

            ViewBag.type = types;
            if (type == null)
            {
                list = ListProduct.showProduct();
            }

            return(View(list));
        }
Esempio n. 28
0
 public void EditHandler(Object sender, EventArgs e)
 {
     try
     {
         listProduct = SharedUserData.addProduct;
         ListProduct content = (sender as Button).CommandParameter as ListProduct;
         int         index   = listProduct.IndexOf(content);
         Navigation.PushModalAsync(new AddProduct(content, true, index, counter, content.rewardCard));
     }
     catch (Exception ex) {
         DisplayAlert("", ExceptionManagement.LogException(ex), "Ok");
     }
 }
Esempio n. 29
0
        public ActionResult Index(int page = 1, int pageSize = 8)
        {
            List <Product> products    = (from p in db.Products where (p.Status == true) select p).ToList();
            var            listProduct = new ListProduct();

            ViewBag.NewProducts   = listProduct.listNewProduct(4);
            ViewBag.ListPhone     = listProduct.listPhone();
            ViewBag.ListBrands    = listProduct.listBrand();
            ViewBag.ListHouseWare = listProduct.listHouseWare();
            PagedList <Product> model = new PagedList <Product>(products, page, pageSize);

            return(View(model));
        }
 private void dtgListProduct_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Delete)
     {
         if (this.dtgListProduct.SelectedRows.Count > 0)
         {
             ListProduct product = QRController.getProduct(this.dtgListProduct.SelectedRows[0].Cells[1].Value.ToString());
             if (QRController.DeleteProduct(product) == false)
             {
                 MessageBox.Show("Lỗi xoá sản phẩm", "Thông báo", MessageBoxButtons.OK);
                 return;
             }
         }
     }
 }