public void Extensions_T013_AbsoluteStart_AbsoluteEnd() { /* Test with DateTime.MinValue */ DateTime DateTimeForTest = DateTime.MinValue; DateTimeForTest = DateTimeForTest.AbsoluteStart(); Assert.IsTrue(DateTimeForTest == DateTime.MinValue); DateTimeForTest = DateTime.MinValue; DateTimeForTest = DateTimeForTest.AbsoluteEnd(); Assert.IsTrue(DateTimeForTest == "1/1/0001 23:59:59.9999999".Parse <DateTime>()); /* Test with DateTime.MaxValue */ DateTimeForTest = DateTime.MaxValue; DateTimeForTest = DateTimeForTest.AbsoluteStart(); Assert.IsTrue(DateTimeForTest == DateTime.MaxValue.Date); DateTimeForTest = DateTime.MaxValue; DateTimeForTest = DateTimeForTest.AbsoluteEnd(); Assert.IsTrue(DateTimeForTest == "12/31/9999 23:59:59.9999999".Parse <DateTime>()); }
public JsonResult CustomizeReport(DateTime fromDate, DateTime toDate) { IResponseData <CustomizeReportItemResponse> response = new ResponseData <CustomizeReportItemResponse>(); try { var filter = new FilterObject() { FromDate = fromDate.AbsoluteStart(), ToDate = toDate.AbsoluteEnd() }; var currentDrugStoreCode = WebSessionManager.Instance.CurrentDrugStoreCode; var customizeReportService = IoC.Container.Resolve <ICustomizeReportService>(); var data = customizeReportService.GetCustomizeReportItems(currentDrugStoreCode, filter); response.SetData(data); } catch (ValidationException ex) { response.SetErrors(ex.Errors); response.SetStatus(HttpStatusCode.PreconditionFailed); } return(Json(response)); }
public static double GetPayOfDay(DateTime date) { var startDate = date.AbsoluteStart(); var endDate = date.AbsoluteEnd(); return(BudgetSum(startDate, endDate, RecordTypeEnum.Pay)); }
public static IList <DateTime> GetDaysDuringPeriod(DateTime startDateTime, DateTime endDateTime) { var result = new List <DateTime>(); var periodStartTime = startDateTime.AbsoluteStart(); var periodEndTime = endDateTime.AbsoluteEnd(); for (DateTime currentDate = periodStartTime; currentDate < periodEndTime; currentDate = currentDate.AddDays(1)) { result.Add(currentDate); } return(result); }
public object GetHistory(string from, string to, bool isExport) { DateTime dtFrom = DateTime.Now, dtTo = DateTime.Now; bool chkFrom = DateTime.TryParseExact(from, MP_FormatHelper.Format103, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtFrom); bool chkTo = DateTime.TryParseExact(to, MP_FormatHelper.Format103, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtTo); if (!chkFrom || !chkTo) { return new { status = MP_AjaxError.DateFormat } } ; return(new { status = MP_AjaxError.OK, value = _loginHistoryServices.GetLoginHistory(dtFrom.AbsoluteStart(), dtTo.AbsoluteEnd(), isExport) }); } }
// lấy thông tin chi tiết của thuốc theo mã nhóm thuốc, mã thuốc hoặc barcode public List <ThuocModel> GetDrugInfo(string maNhaThuoc, int?maNhomThuoc, int?[] drugIds, string ngayTao, string barcode = "") { var phieuKiemKeRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, PhieuKiemKe> >().GetAll(); var phieuKiemKeChiTietRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, PhieuKiemKeChiTiet> >().GetAll(); var thuocs = _dataFilterService.GetValidDrugs(maNhaThuoc); var nhomThuocRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, Med.Entity.NhomThuoc> >().GetAll(); var donViTinhRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, Med.Entity.DonViTinh> >().GetAll(); var rpService = IoC.Container.Resolve <IReportService>(); DateTime toDate = Convert.ToDateTime(ngayTao); toDate = toDate.AbsoluteEnd(); // lọc theo mã nhóm thuốc if (maNhomThuoc > 0) { thuocs = thuocs.Where(i => i.NhomThuoc_MaNhomThuoc == maNhomThuoc); } // lọc theo Id thuốc else if (drugIds != null && drugIds.Count() > 0) { thuocs = thuocs.Where(i => drugIds.Contains(i.ThuocId)); } // lọc theo mã vạch else if (!string.IsNullOrWhiteSpace(barcode)) { thuocs = thuocs.Where(i => i.BarCode == barcode); } var thuocQuery = from t in thuocs join nt in nhomThuocRepo on t.NhomThuoc_MaNhomThuoc equals nt.MaNhomThuoc join dvt in donViTinhRepo on t.DonViXuatLe_MaDonViTinh equals dvt.MaDonViTinh where (nt.MaNhaThuoc == maNhaThuoc && dvt.MaNhaThuoc == maNhaThuoc) select new ThuocModel() { ThuocId = t.ThuocId, TenNhomThuoc = nt.TenNhomThuoc, MaThuoc = t.MaThuoc, TenThuoc = t.TenThuoc, TenDonViTinh = dvt.TenDonViTinh, Gia = t.GiaBanLe, }; var thuocModels = thuocQuery.ToList(); var thuocIds = thuocModels.Select(i => i.ThuocId).Distinct().ToArray(); // lấy danh sách phiếu Kiêm kê chưa cân kho để xem thuốc đã được kiểm kê chưa var pkkChuaCanKhoQuery = from pkk in phieuKiemKeRepo join pkkct in phieuKiemKeChiTietRepo on pkk.MaPhieuKiemKe equals pkkct.PhieuKiemKe_MaPhieuKiemKe where (pkk.NhaThuoc_MaNhaThuoc == maNhaThuoc && thuocIds.Contains(pkkct.Thuoc_ThuocId.Value) && pkk.DaCanKho == false && pkk.RecordStatusID == (byte)RecordStatus.Activated && pkkct.RecordStatusID == (byte)RecordStatus.Activated) select new { pkk.MaPhieuKiemKe, pkkct.Thuoc_ThuocId }; var invService = IoC.Container.Resolve <IInventoryService>(); var drugQuantityAndPrice = invService.GetDrugInventoryValues(maNhaThuoc, thuocIds, MedConstants.MinProductionDataDate, toDate); var phieuNhapChiTietQueryable = _dataFilterService.GetValidReceiptNoteItems(maNhaThuoc); var phieuNhapChiTietQuery = from pnct in phieuNhapChiTietQueryable join t in thuocs on pnct.DrugId equals t.ThuocId orderby pnct.NoteDate descending select new { t.ThuocId, pnct.Price, pnct.SerialNumber, pnct.ExpiredDate }; var phieuNhapChiTietResult = phieuNhapChiTietQuery.ToList(); var pkkChuaCanKhoResult = pkkChuaCanKhoQuery.ToList(); // duyệt danh sách thuốc để update giá trị giá/số tồn/lô/hạn dùng/mã phiếu kk chưa cân kho tồn tại thuocModels.ForEach(t => { if (drugQuantityAndPrice.ContainsKey(t.ThuocId)) { t.TonKho = (decimal)drugQuantityAndPrice[t.ThuocId].LastInventoryQuantity; t.Gia = (decimal)drugQuantityAndPrice[t.ThuocId].InPrice; } var pnct = phieuNhapChiTietResult.Where(x => x.ThuocId == t.ThuocId).FirstOrDefault(); // lấy thông tin giá, số lô, hạn dùng if (pnct != null) { t.SoLo = pnct.SerialNumber; t.HanDung = pnct.ExpiredDate; } // nếu thuốc này đã có trong phiếu Kiểm kê khác, gán mã phiếu đó vào MaPhieuKiemKeTonTai var pkk = pkkChuaCanKhoResult.Where(x => x.Thuoc_ThuocId == t.ThuocId).FirstOrDefault(); if (pkk != null) { t.MaPhieuKiemKeTonTai = pkk.MaPhieuKiemKe; } // TH HanDung nho hon MinTime, update lai HanDung t.HanDung = (!t.HanDung.HasValue || t.HanDung <= MedConstants.MinProductionDataDate) ? null : t.HanDung; } ); return(thuocModels); }