Beispiel #1
0
        public ResponsePZZUpdate PZZUpdate(RequestPZZUpdate request)
        {
            ResponsePZZUpdate response = new ResponsePZZUpdate();

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

                try
                {
                    var user = this.UserInfoGet(request.Token, ts);
                    var d    = cnn.Query("select * from TKS_FAS_CertificateWord where pzz=@PZZ and id<>@Id",
                                         new { PZZ = request.Data.PZZ, Id = request.Data.Id }, ts);
                    if (d.Count() > 0)
                    {
                        throw new NormalException("凭证字已经存在");
                    }
                    d = cnn.Query("select * from TKS_FAS_CertificateWord where ShowTitle=@ShowTitle and id<>@Id",
                                  new { ShowTitle = request.Data.ShowTitle, Id = request.Data.Id }, ts);

                    if (d.Count() > 0)
                    {
                        throw new NormalException("显示名称已经存在");
                    }

                    if (request.Data.IsDefault == 1)
                    {
                        cnn.Execute("update TKS_FAS_CertificateWord set isDefault=0 where accountId=@AccountId",
                                    new { AccountId = user.AccountId }, ts);
                    }

                    string sql = @"update TKS_FAS_CertificateWord set 
                        PZZ=@PZZ,
                        ShowTitle=@ShowTitle,
                        IsDefault=@IsDefault
                        where id=@Id";

                    var r = cnn.Execute(sql, request.Data, ts);


                    if (r == 1)
                    {
                        ts.Commit();
                        response.IsSuccess = true;
                        response.Message   = "更新成功";
                        return(response);
                    }
                    else
                    {
                        throw new AppException(user.User.UserName, "PZZUpdate", "数据更新异常", r + "行数据被更新");
                    }
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    return(this.DealException(response, ex) as ResponsePZZUpdate);
                }
            }
        }
Beispiel #2
0
 public ResponsePZZUpdate PZZUpdate([FromBody] RequestPZZUpdate request)
 {
     try
     {
         PZZBLL bll = new PZZBLL();
         return(bll.PZZUpdate(request));
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(
                   Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }