예제 #1
0
        /// <summary>
        /// Ánh xạ từ đối tượng Document sang đối tượng DocumentViewModel
        /// </summary>
        /// <param name="documentViewModel"></param>
        /// <returns>Document</returns>
        /// Tạo bởi: NBDUONG(20/6/2019)
        public DocumentViewModel MapDocumentToDocumentViewModel(Document document)
        {
            var documentViewModel = new DocumentViewModel();
            var personBL          = new PersonBL();
            var employeeBL        = new EmployeeBL();
            var documentTypeBL    = new DocumentTypeBL();

            documentViewModel.DocumentID       = document.DocumentID;
            documentViewModel.DocumentCode     = document.DocumentCode;
            documentViewModel.DocumentDate     = document.DocumentDate;
            documentViewModel.TotalMoney       = document.TotalMoney;
            documentViewModel.Reason           = document.Reason;
            documentViewModel.DocumentAddress  = document.DocumentAddress;
            documentViewModel.ReceiverName     = document.ReceiverName;
            documentViewModel.DocumentTypeName = documentTypeBL.GetDocumentTypeByID(document.DocumentTypeID).DocumentTypeName;
            documentViewModel.PersonName       = personBL.GetPersonByID(document.PersonID).PersonName;
            documentViewModel.PersonCode       = personBL.GetPersonByID(document.PersonID).PersonCode;
            documentViewModel.EmployeeCode     = employeeBL.GetEmployeeByID(document.EmployeeID).EmployeeCode;
            documentViewModel.EmployeeName     = employeeBL.GetEmployeeByID(document.EmployeeID).EmployeeName;
            documentViewModel.MoneyHasToPay    = document.MoneyHasToPay;
            documentViewModel.MoneyHasNotPaid  = document.MoneyHasNotPaid;
            documentViewModel.AmountPaid       = document.AmountPaid;
            documentViewModel.IsPaid           = document.IsPaid;
            documentViewModel.CheckType        = document.CheckType;
            documentViewModel.DocumentTypeID   = document.DocumentTypeID;
            documentViewModel.PersonID         = document.PersonID;
            documentViewModel.EmployeeID       = document.EmployeeID;

            return(documentViewModel);
        }
예제 #2
0
        /// <summary>
        /// Hàm kiểm tra chứng từ theo điều kiện lọc
        /// </summary>
        /// <param name="documentDto"></param>
        /// <returns></returns>
        /// Tạo bởi: NBDUONG(21/6/2019)
        public List <Document> GetListDocumentsByFilter(DocumentDto documentDto)
        {
            var documents     = new List <Document>();
            var listDocuments = _documentDL.GetDocumentData();

            if (documentDto.TypeFilter == "search-documentCode")
            {
                documents = listDocuments.Where(s => s.DocumentCode.ToLower().Contains(documentDto.TextFilter.ToLower())).ToList();
            }
            else if (documentDto.TypeFilter == "search-reason")
            {
                documents = listDocuments.Where(s => s.Reason.ToLower().Contains(documentDto.TextFilter.ToLower())).ToList();
            }
            else if (documentDto.TypeFilter == "search-personName")
            {
                var personBL = new PersonBL();
                documents = listDocuments.Where(s => personBL.GetPersonByID(s.PersonID).PersonName.ToLower().Contains(documentDto.TextFilter.ToLower())).ToList();
            }
            else if (documentDto.TypeFilter == "search-documentType")
            {
                var documentTypeBL = new DocumentTypeBL();
                documents = listDocuments.Where(s => documentTypeBL.GetDocumentTypeByID(s.DocumentTypeID).DocumentTypeName.ToLower().Contains(documentDto.TextFilter.ToLower())).ToList();
            }
            return(documents);
        }
예제 #3
0
        public AjaxResult GetPersonById(Guid id)
        {
            var ajaxResult = new AjaxResult();

            try
            {
                using (PersonBL _personBL = new PersonBL()) {
                    PersonViewModel personVM = _personBL.GetPersonByID(id);
                    ajaxResult.Data    = personVM;
                    ajaxResult.Success = true;
                }
            }
            catch (Exception)
            {
                ajaxResult.Success   = false;
                ajaxResult.Messenger = "Có lỗi xảy ra khi lấy dữ liệu đối tượng. Xin vui lòng liên hệ MISA để giải quyết";
            }
            return(ajaxResult);
        }