Ejemplo n.º 1
0
 public string GetQueryCondition(CalibrationPlateQueryViewModel model)
 {
     StringBuilder where = new StringBuilder();
     if (model != null)
     {
         if (!string.IsNullOrEmpty(model.LocationName))
         {
             where.AppendFormat(@" {0}  Key.LocationName='{1}'"
                                , where.Length > 0 ? "AND" : string.Empty
                                , model.LocationName);
         }
         if (!string.IsNullOrEmpty(model.LineCode))
         {
             where.AppendFormat(@" {0} Key.LineCode='{1}'"
                                , where.Length > 0 ? "AND" : string.Empty
                                , model.LineCode);
         }
     }
     return(where.ToString());
 }
Ejemplo n.º 2
0
        public ActionResult Query(CalibrationPlateQueryViewModel model)
        {
            string keyList = null;

            if (model.LineCode != null || model.LocationName != null)
            {
                using (CalibrationPlateLineServiceClient client = new CalibrationPlateLineServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <CalibrationPlateLine> > result = client.Get(ref cfg);
                    if (result.Code == 0 && result.Data.Count > 0)
                    {
                        StringBuilder strb = new StringBuilder();
                        foreach (var item in result.Data)
                        {
                            strb.Append("'" + item.Key.CalibrationPlateID + "',");
                        }
                        keyList = strb.ToString().Substring(0, strb.Length - 1);
                    }
                    else
                    {
                        return(PartialView("_ListPartial"));
                    }
                }
            }



            if (keyList != null)
            {
                using (CalibrationPlateServiceClient client = new CalibrationPlateServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(" Key in ({0})"
                                                 , keyList)
                    };
                    MethodReturnResult <IList <CalibrationPlate> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.List = result.Data;
                    }
                }
            }
            else
            {
                using (CalibrationPlateServiceClient client = new CalibrationPlateServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "Key"
                    };
                    MethodReturnResult <IList <CalibrationPlate> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.List = result.Data;
                    }
                }
            }
            return(PartialView("_ListPartial"));
        }