Exemple #1
0
        public async Task <ActionResult> Query(SamplingPlanQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (SamplingPlanServiceClient client = new SamplingPlanServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.Name))
                            {
                                where.AppendFormat(" {0} Key LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Name);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <SamplingPlan> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemple #2
0
        //
        // GET: /EDC/SamplingPlan/Detail
        public async Task <ActionResult> Detail(string key)
        {
            using (SamplingPlanServiceClient client = new SamplingPlanServiceClient())
            {
                MethodReturnResult <SamplingPlan> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    SamplingPlanViewModel viewModel = new SamplingPlanViewModel()
                    {
                        Name        = result.Data.Key,
                        Size        = result.Data.Size,
                        Type        = result.Data.Type,
                        Mode        = result.Data.Mode,
                        Status      = result.Data.Status,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Description = result.Data.Description,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
Exemple #3
0
        public async Task <ActionResult> SaveModify(SamplingPlanViewModel model)
        {
            using (SamplingPlanServiceClient client = new SamplingPlanServiceClient())
            {
                MethodReturnResult <SamplingPlan> result = await client.GetAsync(model.Name);

                if (result.Code == 0)
                {
                    result.Data.Mode        = model.Mode;
                    result.Data.Type        = model.Type;
                    result.Data.Size        = model.Size;
                    result.Data.Status      = model.Status;
                    result.Data.Description = model.Description;
                    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(EDCResources.StringResource.SamplingPlan_SaveModify_Success
                                                    , model.Name);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Exemple #4
0
        public async Task <ActionResult> Save(SamplingPlanViewModel model)
        {
            using (SamplingPlanServiceClient client = new SamplingPlanServiceClient())
            {
                SamplingPlan obj = new SamplingPlan()
                {
                    Key         = model.Name.ToUpper(),
                    Status      = model.Status,
                    Size        = model.Size,
                    Mode        = model.Mode,
                    Type        = model.Type,
                    Description = model.Description,
                    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(EDCResources.StringResource.SamplingPlan_Save_Success
                                                , model.Name);
                }
                return(Json(rst));
            }
        }
Exemple #5
0
        public async Task <ActionResult> Delete(string key)
        {
            MethodReturnResult result = new MethodReturnResult();

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

                if (result.Code == 0)
                {
                    result.Message = string.Format(EDCResources.StringResource.SamplingPlan_Delete_Success
                                                   , key);
                }
                return(Json(result));
            }
        }
Exemple #6
0
        //
        // GET: /EDC/SamplingPlan/
        public async Task <ActionResult> Index()
        {
            using (SamplingPlanServiceClient client = new SamplingPlanServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <SamplingPlan> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new SamplingPlanQueryViewModel()));
        }
Exemple #7
0
        public IEnumerable <SelectListItem> GetSamplingPlanList()
        {
            using (SamplingPlanServiceClient client = new SamplingPlanServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Status='{0}'", Convert.ToInt32(EnumObjectStatus.Available))
                };

                MethodReturnResult <IList <SamplingPlan> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    return(from item in result.Data
                           select new SelectListItem()
                    {
                        Text = item.Key,
                        Value = item.Key
                    });
                }
            }
            return(new List <SelectListItem>());
        }
Exemple #8
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 (SamplingPlanServiceClient client = new SamplingPlanServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <SamplingPlan> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }