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

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemple #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 (PlanMonthServiceClient client = new PlanMonthServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <PlanMonth> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemple #3
0
        public async Task <ActionResult> Delete(string year, string month, string locationname)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                //判断是否存在日明细记录
                using (PlanDayServiceClient client = new PlanDayServiceClient())
                {
                    StringBuilder where = new StringBuilder();

                    //年度条件
                    if (!string.IsNullOrEmpty(year))
                    {
                        where.AppendFormat(" {0} Key.Year = '{1}'"
                                           , where.Length > 0 ? "AND" : string.Empty
                                           , year);
                    }

                    //月度条件
                    if (!string.IsNullOrEmpty(month))
                    {
                        where.AppendFormat(" {0} Key.Month = '{1}'"
                                           , where.Length > 0 ? "and" : string.Empty
                                           , month);
                    }

                    //车间条件
                    if (!string.IsNullOrEmpty(locationname))
                    {
                        where.AppendFormat(" {0} Key.LocationName = '{1}'"
                                           , where.Length > 0 ? "AND" : string.Empty
                                           , locationname);
                    }

                    //设置参数
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key",
                        Where   = where.ToString()
                    };

                    //取得数据
                    MethodReturnResult <IList <PlanDay> > resultlist = client.Get(ref cfg);

                    if (resultlist.Code == 0)
                    {
                        if (resultlist.Data.Count > 0)
                        {
                            //数据错误
                            result.Code    = 1000;       //错误代码
                            result.Message = "存在日计划";    //错误信息

                            return(Json(result));
                        }
                    }
                    else
                    {
                        //数据错误
                        result.Code    = resultlist.Code;       //错误代码
                        result.Message = resultlist.Message;    //错误信息
                        result.Detail  = resultlist.Message;    //错误明细

                        return(Json(result));
                    }
                }

                using (PlanMonthServiceClient client = new PlanMonthServiceClient())
                {
                    PlanMonthKey key = new PlanMonthKey()
                    {
                        Year         = year,
                        Month        = month,
                        LocationName = locationname == null? "":locationname
                    };

                    result = await client.DeleteAsync(key);

                    if (result.Code == 0)
                    {
                        result.Message = string.Format(PPMResources.StringResource.PlanMonth_Delete_Success
                                                       , key);
                    }

                    return(Json(result));
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();

                return(Json(result));
            }
        }