Beispiel #1
0
        public async Task <IHttpActionResult> GetNewParameter()
        {
            var unitCode    = _servicePeriod.GetCurrentUnitCode();
            var currentDate = DateTime.Now.Date;
            var result      = new ParameterSinhNhatKh()
            {
                ToDay        = currentDate.Day,
                FromDay      = currentDate.Day,
                MonthOfBirth = currentDate.Month,
                MinDay       = currentDate.Day,
                MaxDay       = currentDate.Day,

                ToDate   = currentDate,
                FromDate = currentDate,
                MinDate  = currentDate,
                MaxDate  = currentDate,

                UnitCode = unitCode
            };

            var periodCollection = _servicePeriod.Repository.DbSet.Where(x => x.UnitCode == unitCode && x.TrangThai == (int)ApprovalState.IsComplete);

            if (periodCollection != null && periodCollection.Count() > 0)
            {
                var lastPeriod     = periodCollection.OrderByDescending(x => x.Year).OrderByDescending(x => x.Period).FirstOrDefault();
                var originalPeriod = periodCollection.OrderBy(x => x.Period).FirstOrDefault();
                result.MaxDate = lastPeriod.ToDate;
                result.MinDate = originalPeriod.FromDate;
                result.ToDate  = lastPeriod.ToDate;
                if (lastPeriod.ToDate.AddMonths(-1) >= originalPeriod.FromDate)
                {
                    result.FromDate = lastPeriod.ToDate.AddMonths(-1);
                }
                else
                {
                    result.FromDate = originalPeriod.FromDate;
                }



                result.MaxDay       = lastPeriod.ToDate.Day;
                result.MinDay       = originalPeriod.FromDate.Day;
                result.ToDay        = lastPeriod.ToDate.Day;
                result.FromDay      = originalPeriod.ToDate.Day;
                result.MonthOfBirth = lastPeriod.ToDate.Month;
            }

            return(Ok(result));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> ReportSinhNhatKh(ParameterSinhNhatKh para)
        {
            var result = new TransferObj <ReportSinhNhatKh>();

            try
            {
                var reporter = new ReportSinhNhatKh();
                var data     = new List <MdCustomer>();
                reporter.UnitCode = _servicePeriod.GetCurrentUnitCode();
                var unitCode = _servicePeriod.GetCurrentUnitCode();

                reporter.FromDay      = para.FromDay;
                reporter.ToDay        = para.ToDay;
                reporter.MonthOfBirth = para.MonthOfBirth;

                //reporter.FromDate = para.FromDate;
                //reporter.ToDate = para.ToDate;
                reporter.CreateDate  = DateTime.Now;
                reporter.TenDonVi    = CurrentSetting.GetUnitName(unitCode);
                reporter.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
                //GetNhanVien
                if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal)
                {
                    var currentUser = (HttpContext.Current.User as ClaimsPrincipal);
                    var name        = currentUser.Identity.Name;
                    var nhanVien    = _service.UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault();
                    if (nhanVien != null)
                    {
                        reporter.Username = nhanVien.TenNhanVien;
                    }
                    else
                    {
                        reporter.Username = "******";
                    }
                }
                reporter.Data  = _service.ReportSinhNhatKh(para);
                result.Data    = reporter;
                result.Status  = true;
                result.Message = "Xuất báo cáo thành công";
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }