コード例 #1
0
        public GLVoucherListResponse DeleteGLPaymentList(string refId)
        {
            var response = new GLVoucherListResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                var glVoucherEntity = GlVoucherListDao.GetGLPaymentListByRefId(refId);
                if (glVoucherEntity == null)
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    response.Message     = "Dữ liệu cần xóa không tồn tại!";
                    return(response);
                }
                using (var scope = new TransactionScope())
                {
                    // Xóa Detail
                    response.Message = GlVoucherListDetailDao.DeleteGLPaymentListDetailByRefId(glVoucherEntity.RefId);
                    if (!string.IsNullOrEmpty(response.Message))
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }

                    response.Message = GlVoucherListDao.DeleteGLPaymentList(glVoucherEntity);
                    if (!string.IsNullOrEmpty(response.Message))
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }
                    scope.Complete();
                }
                response.RefId = glVoucherEntity.RefId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(response);
            }
        }
コード例 #2
0
        public GLVoucherListResponse InsertGLVoucherList(GLVoucherListEntity glVoucherListEntity)
        {
            var response = new GLVoucherListResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!glVoucherListEntity.Validate())
                {
                    foreach (var error in glVoucherListEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                using (var scope = new TransactionScope())
                {
                    var faDepreciation = GlVoucherListDao.GetGLVoucherListByRefNo(glVoucherListEntity.RefNo.Trim(), glVoucherListEntity.RefDate);
                    if (faDepreciation != null && faDepreciation.RefDate.Year == glVoucherListEntity.RefDate.Year)
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        response.Message     = @"Số chứng từ " + glVoucherListEntity.RefNo + @" đã tồn tại !";
                        return(response);
                    }

                    glVoucherListEntity.RefId = Guid.NewGuid().ToString();
                    response.Message          = GlVoucherListDao.InsertGLVoucherList(glVoucherListEntity);
                    if (!string.IsNullOrEmpty(response.Message))
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }

                    #region Insert detail
                    if (glVoucherListEntity.GlVoucherListDetails != null)
                    {
                        foreach (var glVoucherListDetail in glVoucherListEntity.GlVoucherListDetails)
                        {
                            glVoucherListDetail.RefDetailId = Guid.NewGuid().ToString();
                            glVoucherListDetail.RefId       = glVoucherListEntity.RefId;
                            response.Message = GlVoucherListDetailDao.InsertGLVoucherListDetail(glVoucherListDetail);
                            if (!string.IsNullOrEmpty(response.Message))
                            {
                                response.Acknowledge = AcknowledgeType.Failure;
                                return(response);
                            }
                        }
                    }
                    #endregion

                    scope.Complete();
                }
                response.RefId = glVoucherListEntity.RefId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(response);
            }
        }