示例#1
0
        public OemData GetOemData(string lotNumber)
        {
            using (OemDataServiceClient client = new OemDataServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    PageNo   = 0,
                    PageSize = 1,
                    Where    = string.Format("Key='{0}'", lotNumber)
                };
                MethodReturnResult <IList <OemData> > result = client.Get(ref cfg);

                if (result.Code == 0 && result.Data != null & result.Data.Count > 0)
                {
                    return(result.Data[0]);
                }
            }
            return(null);
        }
示例#2
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (OemDataServiceClient client = new OemDataServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <OemData> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.OemDataList  = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
示例#3
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> Query(OemDataViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (OemDataServiceClient client = new OemDataServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.LotNumber))
                            {
                                where.AppendFormat(" {0} Key LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.LotNumber.ToString().Trim().ToUpper());
                            }

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

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

                            if (!string.IsNullOrEmpty(model.PnName))
                            {
                                where.AppendFormat(" {0} PnName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.PnName.ToString().Trim().ToUpper());
                            }
                            if (!string.IsNullOrEmpty(model.Grade))
                            {
                                where.AppendFormat(" {0} Grade LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Grade.ToString().Trim().ToUpper());
                            }
                            if (!string.IsNullOrEmpty(model.Color))
                            {
                                where.AppendFormat(" {0} Color LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Color.ToString().Trim().ToUpper());
                            }
                            if (!string.IsNullOrEmpty(model.PsSubCode))
                            {
                                where.AppendFormat(" {0} PsSubCode LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.PsSubCode.ToString().Trim().ToUpper());
                            }
                            if (!string.IsNullOrEmpty(model.Status))
                            {
                                where.AppendFormat(" {0} Status LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Status.ToString().Trim().ToUpper());
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <OemData> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.OemDataList  = result.Data;
                        }
                    });
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", model));
            }
            else
            {
                return(View(model));
            }
        }