예제 #1
0
        public string DeleteGLPaymentList(GLPaymentListEntity glPaymentList)
        {
            const string sql = @"uspDelete_GlPaymentList";

            object[] parms = { "@RefID", glPaymentList.RefId };
            return(Db.Delete(sql, true, parms));
        }
예제 #2
0
 private static object[] Take(GLPaymentListEntity gLVoucherListEntity)
 {
     return(new object[]
     {
         "@RefID", gLVoucherListEntity.RefId,
         "@RefType", gLVoucherListEntity.RefType,
         "@RefDate", gLVoucherListEntity.RefDate,
         "@PostedDate", gLVoucherListEntity.PostedDate,
         "@RefNo", gLVoucherListEntity.RefNo,
         "@VoucherTypeID", gLVoucherListEntity.VoucherTypeId,
         "@SetupType", gLVoucherListEntity.SetupType,
         "@Description", gLVoucherListEntity.Description,
         "@TotalAmount", gLVoucherListEntity.TotalAmount,
         "@EditVersion", gLVoucherListEntity.EditVersion,
     });
 }
        public GLVoucherListResponse UpdateGlPaymentList(GLPaymentListEntity 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.GetGLPaymentListByRefNo(glVoucherListEntity.RefNo.Trim(), glVoucherListEntity.RefDate);
                    if (faDepreciation != null && faDepreciation.RefDate.Year == glVoucherListEntity.RefDate.Year)
                    {
                        if (faDepreciation.RefId != glVoucherListEntity.RefId)
                        {
                            response.Acknowledge = AcknowledgeType.Failure;
                            response.Message     = @"Số chứng từ " + glVoucherListEntity.RefNo + @" đã tồn tại !";
                            return(response);
                        }
                    }

                    response.Message = GlVoucherListDao.UpdateGLPaymentList(glVoucherListEntity);
                    if (!string.IsNullOrEmpty(response.Message))
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }



                    #region Delete detail
                    // Xóa bảng glVoucherDetail
                    //response.Message = GlVoucherListDetailDao.DeleteGLVoucherListDetailByRefId(glVoucherListEntity.RefId);
                    response.Message = GlVoucherListDetailDao.DeleteGLPaymentListDetailByRefId(glVoucherListEntity.RefId);
                    if (!string.IsNullOrEmpty(response.Message))
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }



                    if (glVoucherListEntity.GLPaymentListDetails != null)
                    {
                        foreach (var glVoucherListDetail in glVoucherListEntity.GLPaymentListDetails)
                        {
                            glVoucherListDetail.RefDetailId = Guid.NewGuid().ToString();
                            glVoucherListDetail.RefId       = glVoucherListEntity.RefId;
                            response.Message = GlVoucherListDetailDao.InsertGLPaymentListDetail(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);
            }
        }
예제 #4
0
        public string InsertGLPaymentList(GLPaymentListEntity glPaymentList)
        {
            const string sql = @"uspInsert_GLPaymentList";

            return(Db.Insert(sql, true, Take(glPaymentList)));
        }
예제 #5
0
        public string UpdateGLPaymentList(GLPaymentListEntity glPaymentList)
        {
            const string sql = @"uspUpdate_GLPaymentList";

            return(Db.Update(sql, true, Take(glPaymentList)));
        }