public ActionResult Index(SearchItemModel Model, int?page)
        {
            var pageNumber = page ?? 1;
            int total      = new int();
            List <ItemDisplayModel> lstModel    = new List <ItemDisplayModel>();
            List <GetCatetoryModel> lstcombobox = new List <GetCatetoryModel>();

            if (!string.IsNullOrEmpty(Session["code"] as string))
            {
                Model.code = Session["code"].ToString();
            }
            if (!string.IsNullOrEmpty(Session["name"] as string))
            {
                Model.name = Session["name"].ToString();
            }
            if (Session["category_id"] as int? != null)
            {
                Model.category_id = (int)Session["category_id"];
            }
            _itemBLL.Search(Model, out lstModel, out total, pageNumber);
            var list = new StaticPagedList <ItemDisplayModel>(lstModel, pageNumber, 15, total);

            ViewBag.ListSearch = lstModel.OrderByDescending(x => x.id);
            _itemBLL.GetCategory(true, out lstcombobox);
            ViewBag.lstcombobox = lstcombobox;
            ViewBag.page        = 0;
            if (page != null)
            {
                ViewBag.page = pageNumber - 1;
            }
            return(View(new Tuple <SearchItemModel, IPagedList <ItemDisplayModel> >(Model, list)));
        }
        public void showSearchItemPage(SearchItemModel pantryItem)
        {
            SearchItemPage searchItemPage = new SearchItemPage();

            searchItemPage.BindingContext = new SearchItemViewModel(pantryItem);
            navigation.PushAsync(searchItemPage);
        }
        public SearchItemViewModel(SearchItemModel searchItem)
        {
            navManager = PageNavigationManager.Instance;
            SearchItem = searchItem;

            Position itemPosition = new Position(SearchItem.ItemLocation.Latitude, SearchItem.ItemLocation.Longitude);
            MapSpan  mapSpan      = MapSpan.FromCenterAndRadius(itemPosition, Distance.FromKilometers(5));

            Map = new Map(mapSpan);
            Map.HeightRequest = 150;
            Map.WidthRequest  = 150;
            Map.IsShowingUser = false;

            Pin pin = new Pin
            {
                Type     = PinType.Place,
                Position = itemPosition,
                Label    = SearchItem.Description,
                Address  = SearchItem.Location
            };

            Map.Pins.Add(pin);

            MessageCommand = new Command(MessageUserAsync);
        }
 public SearchMedicinesViewModel()
 {
     NewMedicine    = new Command(arg => AddItem());
     FindMedicines  = new Command(arg => FindItem());
     DeleteMedicine = new Command(arg => DeleteItem());
     _selectedItem  = null;
     GetDataFromDatabase();
 }
Beispiel #5
0
        public async Task <IHttpActionResult> Search([FromBody] SearchItemModel model)
        {
            var ids      = model.Ids;
            var memberId = User.GetMemberId();
            var models   = await queryService.SearchUnitItems(memberId, ids);

            return(Ok(models));
        }
Beispiel #6
0
        public void DeleteMedicine(SearchItemModel medicine)
        {
            string query = "DELETE FROM `medicine` WHERE id=@id_item";

            command = new MySqlCommand(query, connection);
            command.Parameters.AddWithValue("@id_item", medicine.id);
            command.ExecuteNonQuery();
            command.Dispose();
        }
 private void DeleteItem()
 {
     if (_selectedItem != null)
     {
         DatabaseModel database = new DatabaseModel();
         database.DeleteMedicine(_selectedItem);
         DataGridMedicines.Remove(_selectedItem);
         _selectedItem = null;
     }
 }
Beispiel #8
0
        public int Search(SearchItemModel searchCondition, out List <ItemDisplayModel> lstModel, out int total, int _page)
        {
            _page = _page * 15 - 15;
            int returnCode = (int)Common.ReturnCode.Succeed;

            lstModel = new List <ItemDisplayModel>();
            total    = new int();
            try
            {
                string sql = "SELECT item.`id`, item.`code`, item.`name`, cate.`name` AS category_name, item.`specification`, item.`description`, item.`dangerous` ";
                sql += "FROM `product_item` AS item ";
                sql += "JOIN (SELECT c.`id`, cpp.`name` AS category_parent_name, c.`name` ";
                sql += "FROM `product_category` AS c ";
                sql += "LEFT JOIN (SELECT cp.`name`, cp.`id` FROM `product_category` cp) cpp on cpp.`id` = c.`parent_id` ";
                sql += ") cate ON item.`category_id` = cate.`id` WHERE TRUE ";

                string _sql = "SELECT count(item.`id`) ";
                _sql += "FROM `product_item` AS item ";
                _sql += "JOIN (SELECT c.`id`, cpp.`name` AS category_parent_name, c.`name` ";
                _sql += "FROM `product_category` AS c ";
                _sql += "LEFT JOIN (SELECT cp.`name`, cp.`id` FROM `product_category` cp) cpp on cpp.`id` = c.`parent_id` ";
                _sql += ") cate ON item.`category_id` = cate.`id` WHERE TRUE ";

                if (!string.IsNullOrEmpty(searchCondition.category_id.ToString()))
                {
                    sql  += "AND (item.`category_id` = @category_id OR item.`category_id` IN (SELECT cate.`id` FROM `product_category` cate WHERE cate.`parent_id` = @category_id)) ";
                    _sql += "AND (item.`category_id` = @category_id OR item.`category_id` IN (SELECT cate.`id` FROM `product_category` cate WHERE cate.`parent_id` = @category_id)) ";
                }
                if (!string.IsNullOrEmpty(searchCondition.code))
                {
                    sql  += "AND item.`code` LIKE @code ";
                    _sql += "AND item.`code` LIKE @code ";
                }
                if (!string.IsNullOrEmpty(searchCondition.name))
                {
                    sql  += "AND item.`name` LIKE @name ";
                    _sql += "AND item.`name` LIKE @name ";
                }
                sql     += " ORDER BY item.`id`ASC LIMIT @page,15";
                lstModel = db.Query <ItemDisplayModel>(sql, new { category_id = searchCondition.category_id, code = '%' + searchCondition.code + '%', name = '%' + searchCondition.name + '%', page = _page }).ToList();
                total    = db.ExecuteScalar <int>(_sql, new { category_id = searchCondition.category_id, code = '%' + searchCondition.code + '%', name = '%' + searchCondition.name + '%', page = _page });
            }
            catch (Exception ex)
            {
                return(returnCode = (int)Common.ReturnCode.UnSuccess);
            }
            return(returnCode);
        }
        public ActionResult IndexPost(SearchItemModel Model, int?page)
        {
            var pageNumber = page ?? 1;
            List <ItemDisplayModel> lstModel    = new List <ItemDisplayModel>();
            List <GetCatetoryModel> lstcombobox = new List <GetCatetoryModel>();
            int total = new int();

            _itemBLL.Search(Model, out lstModel, out total, pageNumber);
            var list = new StaticPagedList <ItemDisplayModel>(lstModel, pageNumber, 15, total);

            ViewBag.ListSearch      = lstModel.OrderByDescending(x => x.id);
            Session["code"]         = Model.code;
            Session["name"]         = Model.name;
            Session["category_id"]  = Model.category_id;
            TempData["CountResult"] = total.ToString() + " row(s) found!";
            _itemBLL.GetCategory(true, out lstcombobox);
            ViewBag.lstcombobox = lstcombobox;
            return(View(new Tuple <SearchItemModel, IPagedList <ItemDisplayModel> >(Model, list)));
        }
Beispiel #10
0
        public HashSet <SearchItemModel> GetMedicines()
        {
            string query = "SELECT id, name, description FROM medicine";

            command = new MySqlCommand(query, connection);

            MySqlDataReader           reader = command.ExecuteReader();
            HashSet <SearchItemModel> items  = new HashSet <SearchItemModel>();
            SearchItemModel           item;

            while (reader.Read())
            {
                item             = new SearchItemModel();
                item.id          = (int)reader.GetValue(0);
                item.title       = reader.GetValue(1).ToString();
                item.description = reader.GetValue(2).ToString();

                items.Add(item);
            }
            command.Dispose();
            return(items);
        }
Beispiel #11
0
 public int Search(SearchItemModel searchCondition, out List <ItemDisplayModel> lstModel, out int total, int _page)
 {
     return(_itemDAO.Search(searchCondition, out lstModel, out total, _page));
 }
 private void AddItem()
 {
     SearchItemModel item = new SearchItemModel();
 }
 void SearchItemSelected(SearchItemModel pantryItem)
 {
     navManager.showSearchItemPage(pantryItem);
 }