示例#1
0
        /// <summary>
        /// 更新同比环比数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Result UpdateLastData(int id)
        {
            var entity = Load(id);

            if (entity == null)
            {
                return(ResultUtil.AuthFail("请求的数据不存在"));
            }

            int lastMonthYear  = entity.Year;
            int lastMonthMonth = entity.Month;

            int lastYearYear  = entity.Year - 1;
            int lastYearMonth = entity.Month;

            if (lastMonthMonth == 1)
            {
                lastMonthMonth = 12;
                lastMonthYear  = lastMonthYear - 1;
            }
            else
            {
                lastMonthMonth = lastMonthMonth - 1;
            }

            KeyValuePairs kvs = new KeyValuePairs();

            kvs.Add(@"UPDATE Base_MonthReport SET LastMonthXY=(SELECT XY FROM Base_MonthReport WHERE SalerId=@SalerId AND Year=@Year AND Month=@Month) WHERE Id=@Id",
                    new { Id = id, Year = lastMonthYear, Month = lastMonthMonth, SalerId = entity.SalerId });
            kvs.Add(@"UPDATE Base_MonthReport SET LastYearXY=(SELECT XY FROM Base_MonthReport WHERE SalerId=@SalerId AND Year=@Year AND Month=@Month) WHERE Id=@Id",
                    new { Id = id, Year = lastYearYear, Month = lastYearMonth, SalerId = entity.SalerId });

            var result = db.ExecuteTran(kvs);

            return(result ? ResultUtil.Success() : ResultUtil.Fail());
        }
示例#2
0
 public override void VisitKeyValue(object key, object value, int depth)
 {
     base.VisitKeyValue(key, value, depth);
     KeyValuePairs.Add(String.Format("{0} = {1}", Values[Values.Count - 2], Values[Values.Count - 1]));
 }
 protected override bool OnDeserializeUnrecognizedAttribute(string name, string value)
 {
     KeyValuePairs.Add(new KeyValuePair <string, string>(name, value));
     return(true);
 }
示例#4
0
 public Task<KeyValuePairs> GetInstitutions()
 {
     var func = new Func<KeyValuePairs>(() => {
         var request = new RestRequest("institutions", Method.GET);
         var response = Client.Execute(request);
         if (response.StatusCode != HttpStatusCode.OK) {
             throw new Exception(response.StatusDescription);
         }
         JsonObject[] institutions = JsonConvert.DeserializeObject<JsonObject[]>(response.Content);
         var kvp = new KeyValuePairs();
         foreach (JsonObject institution in institutions) {
             kvp.Add(institution["type"].ToString(), institution["name"].ToString());
         }
         return kvp;
     });
     return Task.Factory.StartNew(func);
 }
示例#5
0
 public void Add(string key, string val)
 {
     KeyValuePairs.Add(new KeyVal(key, val));
 }