public async Task <IActionResult> Index2(QryVendor qryVendor)
        {
            string             qname = qryVendor.KeyWord;
            string             uno   = qryVendor.UniteNo;
            List <VendorModel> vt    = _context.Vendors.ToList();

            if (!string.IsNullOrEmpty(qname))
            {
                vt = vt.Where(v => v.VendorName.Contains(qname)).ToList();
            }
            if (!string.IsNullOrEmpty(uno))
            {
                vt = vt.Where(v => v.UniteNo == uno).ToList();
            }

            return(PartialView("List", vt));
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            QryVendor             qryVendor = new QryVendor();
            List <SelectListItem> items     = new List <SelectListItem>();

            //items.Add(new SelectListItem { Text = "請選擇",Value = "0" });
            items.Add(new SelectListItem {
                Text = "", Value = "0"
            });
            /* 預設廠商資料 */
            items.Add(new SelectListItem {
                Text = "群益開發生技有限公司(53266746)", Value = "53266746"
            });
            items.Add(new SelectListItem {
                Text = "上揚廣告社(78622428)", Value = "78622428"
            });
            items.Add(new SelectListItem {
                Text = "大山電子材料行(59165371)", Value = "59165371"
            });
            items.Add(new SelectListItem {
                Text = "永美木器行(58110602)", Value = "58110602"
            });
            items.Add(new SelectListItem {
                Text = "全宏鎖店(93891885)", Value = "93891885"
            });
            items.Add(new SelectListItem {
                Text = "育林水電企業有限公司(23721395)", Value = "23721395"
            });
            items.Add(new SelectListItem {
                Text = "雷寶企業有限公司(84809153)", Value = "84809153"
            });
            items.Add(new SelectListItem {
                Text = "建興天井行(58359814)", Value = "58359814"
            });
            items.Add(new SelectListItem {
                Text = "新建源五金行(59188607)", Value = "59188607"
            });
            items.Add(new SelectListItem {
                Text = "協進通信企業行(05932919)", Value = "05932919"
            });
            items.Add(new SelectListItem {
                Text = "建寶鎖店(20338895)", Value = "20338895"
            });
            qryVendor.VendorList = items;
            return(View(qryVendor));
        }
Beispiel #3
0
        public ActionResult QryVendor(QryVendor qryVendor)
        {
            List <SelectListItem> items = new List <SelectListItem>();

            if (qryVendor.QryType == "關鍵字")
            {
                if (!string.IsNullOrEmpty(qryVendor.KeyWord))
                {
                    _context.BMEDVendors.Where(v => v.VendorName.Contains(qryVendor.KeyWord.Trim()))
                    .ToList()
                    .ForEach(v => {
                        items.Add(new SelectListItem()
                        {
                            Text  = v.VendorName,
                            Value = v.VendorId.ToString()
                        });
                    });
                }
            }
            else if (qryVendor.QryType == "統一編號")
            {
                _context.BMEDVendors.Where(v => v.UniteNo == qryVendor.UniteNo)
                .ToList()
                .ForEach(v => {
                    items.Add(new SelectListItem()
                    {
                        Text  = v.VendorName,
                        Value = v.VendorId.ToString()
                    });
                });
            }

            qryVendor.VendorList = items;

            return(PartialView(qryVendor));
        }