Exemple #1
0
        public async Task <ActionResult> Query(LineStoreMaterialQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (LineStoreMaterialServiceClient client = new LineStoreMaterialServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key.LineStoreName",
                            Where   = GetWhereCondition(model)
                        };
                        MethodReturnResult <IList <LineStoreMaterial> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", new LineStoreMaterialViewModel()));
            }
            else
            {
                return(View("Index"));
            }
        }
Exemple #2
0
        public string GetWhereCondition(LineStoreMaterialQueryViewModel model)
        {
            StringBuilder where = new StringBuilder();
            if (model != null)
            {
                if (!string.IsNullOrEmpty(model.LineStoreName))
                {
                    where.AppendFormat(" {0} Key.LineStoreName = '{1}'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , model.LineStoreName);
                }

                if (!string.IsNullOrEmpty(model.MaterialCode))
                {
                    where.AppendFormat(" {0} Key.MaterialCode LIKE '{1}%'"
                                       , where.Length > 0 ? "AND" : string.Empty
                                       , model.MaterialCode);
                }
            }
            return(where.ToString());
        }