public async Task <ActionResult> SaveModify(ProductControlObjectViewModel model)
        {
            using (ProductControlObjectServiceClient client = new ProductControlObjectServiceClient())
            {
                ProductControlObjectKey key = new ProductControlObjectKey()
                {
                    ProductCode  = model.ProductCode,
                    CellEff      = model.CellEff,
                    SupplierCode = model.SupplierCode,
                    Type         = model.Type,
                    Object       = model.Object
                };
                MethodReturnResult <ProductControlObject> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    result.Data.ProductName  = model.ProductName;
                    result.Data.SupplierName = model.SupplierName;
                    result.Data.Value        = model.Value;
                    result.Data.IsUsed       = model.IsUsed;
                    result.Data.Editor       = User.Identity.Name;
                    result.Data.EditTime     = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(ZPVMResources.StringResource.ProductControlObject_SaveModify_Success
                                                    , key);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
        public async Task <ActionResult> Save(ProductControlObjectViewModel model)
        {
            using (ProductControlObjectServiceClient client = new ProductControlObjectServiceClient())
            {
                ProductControlObject obj = new ProductControlObject()
                {
                    Key = new ProductControlObjectKey()
                    {
                        ProductCode  = model.ProductCode,
                        CellEff      = model.CellEff,
                        SupplierCode = model.SupplierCode,
                        Object       = model.Object,
                        Type         = model.Type
                    },
                    ProductName  = model.ProductName,
                    SupplierName = model.SupplierName,
                    Value        = model.Value,
                    IsUsed       = model.IsUsed,
                    Editor       = User.Identity.Name,
                    EditTime     = DateTime.Now,
                    CreateTime   = DateTime.Now,
                    Creator      = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(ZPVMResources.StringResource.ProductControlObject_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
        //
        //POST: /ZPVM/ProductControlObject/Query
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> Query(string ProductCode, string ProductName)
        //public ActionResult Query(string ProductCode, string ProductName)
        {
            if (ModelState.IsValid)
            {
                ViewBag.ProductName = ProductName;
                ViewBag.ProductCode = ProductCode;
                using (ProductControlObjectServiceClient client = new ProductControlObjectServiceClient())
                {
                    await Task.Run(() =>
                    {
                        string where     = null;
                        where            = string.Format("Key.ProductCode='{0}' AND ProductName='{1}'", ProductCode, ProductName);
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key.Object",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <ProductControlObject> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", new ProductControlObjectViewModel()
                {
                    ProductName = ProductName, ProductCode = ProductCode
                }));
            }
            else
            {
                return(View("_Query", new ProductControlObjectViewModel()
                {
                    ProductName = ProductName, ProductCode = ProductCode
                }));
            }
        }
        //
        // GET: /ZPVM/ProductControlObject/Modify
        public async Task <ActionResult> Modify(string ProductCode, string CellEff, string SupplierCode, EnumPVMTestDataType obj, string type)
        {
            ProductControlObjectViewModel viewModel = new ProductControlObjectViewModel();

            using (ProductControlObjectServiceClient client = new ProductControlObjectServiceClient())
            {
                MethodReturnResult <ProductControlObject> result = await client.GetAsync(new ProductControlObjectKey()
                {
                    ProductCode  = ProductCode,
                    CellEff      = CellEff,
                    SupplierCode = SupplierCode,
                    Object       = obj,
                    Type         = type
                });

                if (result.Code == 0)
                {
                    viewModel = new ProductControlObjectViewModel()
                    {
                        ProductCode  = result.Data.Key.ProductCode,
                        CellEff      = result.Data.Key.CellEff,
                        SupplierCode = result.Data.Key.SupplierCode,
                        ProductName  = result.Data.ProductName,
                        SupplierName = result.Data.SupplierName,
                        Value        = result.Data.Value,
                        Type         = result.Data.Key.Type,
                        Object       = result.Data.Key.Object,
                        IsUsed       = result.Data.IsUsed,
                        CreateTime   = result.Data.CreateTime,
                        Creator      = result.Data.Creator,
                        Editor       = result.Data.Editor,
                        EditTime     = result.Data.EditTime
                    };
                    return(PartialView("_ModifyPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_ModifyPartial", new ProductControlObjectViewModel()));
        }
        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 (ProductControlObjectServiceClient client = new ProductControlObjectServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <ProductControlObject> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
        public async Task <ActionResult> Delete(string ProductCode, string CellEff, string SupplierCode, EnumPVMTestDataType obj, string type)
        {
            MethodReturnResult      result = new MethodReturnResult();
            ProductControlObjectKey key    = new ProductControlObjectKey()
            {
                ProductCode  = ProductCode,
                CellEff      = CellEff,
                SupplierCode = SupplierCode,
                Object       = obj,
                Type         = type
            };

            using (ProductControlObjectServiceClient client = new ProductControlObjectServiceClient())
            {
                result = await client.DeleteAsync(key);

                if (result.Code == 0)
                {
                    result.Message = string.Format(ZPVMResources.StringResource.ProductControlObject_Delete_Success
                                                   , key);
                }
                return(Json(result));
            }
        }