Beispiel #1
0
 public ResponseTPLGet TPLGet([FromBody] RequestTPLGet request)
 {
     try
     {
         TPLBLL bll = new TPLBLL();
         return(bll.TPLGet(request));
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(
                   Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Beispiel #2
0
        public ResponseTPLGet TPLGet(RequestTPLGet request)
        {
            ResponseTPLGet response = new ResponseTPLGet();

            using (cnn = GetConnection())
            {
                var ts = cnn.BeginTransaction();

                try
                {
                    var user = UserInfoGet(request.Token, ts);
                    var head = cnn.QuerySingle <TKS_FAS_DocTPL>("select * from TKS_FAS_DocTPL where id=@Id", new
                    {
                        Id = request.Data.Id
                    }, ts);

                    var detail = cnn.Query <TKS_FAS_DocDetailTPL>(
                        @"select * from tks_fas_docDetailTPL where parentId=@ParentId",
                        new { ParentId = head.Id }, ts).ToList();

                    for (int i = 0; i < detail.Count; i++)
                    {
                        var item = detail[i];

                        if (!string.IsNullOrEmpty(item.CalItem1))
                        {
                            detail[i].CalValue1 += item.CalItem1 + "," + item.CalValue1 + "#";
                        }

                        if (!string.IsNullOrEmpty(item.CalItem2))
                        {
                            detail[i].CalValue1 += item.CalItem2 + ',' + item.CalValue2 + "#";
                        }

                        if (!string.IsNullOrEmpty(item.CalItem3))
                        {
                            detail[i].CalValue1 += item.CalItem3 + "," + item.CalValue3 + "#";
                        }
                        if (!string.IsNullOrEmpty(item.CalItem4))
                        {
                            detail[i].CalValue1 += item.CalItem4 + "," + item.CalValue4 + "#";
                        }
                        if (!string.IsNullOrEmpty(item.CalItem5))
                        {
                            detail[i].CalValue1 += item.CalItem5 + "," + item.CalValue5 + "#";
                        }
                    }

                    ts.Commit();
                    response.IsSuccess = true;
                    response.Message   = "加载完毕";
                    response.Head      = head;
                    response.Detail    = detail;
                    #region add by Hero.Zhang 判断科目行是否有子科目
                    int flag = 0;
                    for (int i = 0; i < detail.Count(); i++)
                    {
                        var item = detail[i];
                        List <TKS_FAS_AccountSubject> sub = cnn.Query <TKS_FAS_AccountSubject>(@"select * from TKS_FAS_AccountSubject where AccountId=@AccountId and RootCode=@RootCode",
                                                                                               new { AccountId = user.AccountId, RootCode = item.SubjectCode }, ts).ToList();
                        if (sub.Count > 1)
                        {
                            flag++;
                            response.CheckParent = "1";
                            response.Message    += "</br>第" + (i + 1).ToString() + "行有子科目,请重新选择";
                        }
                    }
                    //if (flag>0)
                    //{
                    //    throw new NormalException("固定资产原值与期初固定资产不匹配</br>固定资产原值:" + FixedAssets.InitialAssetValue.ToString() + "</br>期初固定资产:" + val.ToString());
                    //}

                    #endregion
                    return(response);
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    return(this.DealException(response, ex) as ResponseTPLGet);
                }
            }
        }