Beispiel #1
0
        public static void B()
        {
            //<snippet2>
            using (AdventureWorksEntities AWEntities = new AdventureWorksEntities())
            {
                double?stdDev = EntityFunctions.StandardDeviation(
                    from o in AWEntities.SalesOrderHeaders
                    select o.SubTotal);

                Console.WriteLine(stdDev);
            }
            //</snippet2>
        }
Beispiel #2
0
        public IEnumerable <EventureList> GetEventureListsByOwnerId(Int32 id)
        {
            var queryOwnerEventures = _contextProvider.Context
                                      .Eventures.Where(e => e.OwnerId == id)
                                      .Select(e => e.Id);

            return(_contextProvider.Context.EventureLists
                   .Where(el => queryOwnerEventures.Contains(el.EventureId) &&
                          (el.Active) &&
                          (EntityFunctions.TruncateTime(el.DateBeginReg) <= EntityFunctions.TruncateTime(DateTime.Now)) &&
                          (EntityFunctions.TruncateTime(el.DateEndReg) >= EntityFunctions.TruncateTime(DateTime.Now)))
                   .OrderBy(el => el.SortOrder).ToList());
        }
Beispiel #3
0
        public ActionResult Index()
        {
            var sonuc = db.Order
                        .GroupBy(s => EntityFunctions.TruncateTime(s.OrderTime))
                        .Select(gruop => new GunlukCiro
            {
                Gun         = gruop.Key,
                SiparisAdet = gruop.Count(),
                Ciro        = gruop.Sum(x => x.PaymentTotal)
            }).ToList();

            return(View(sonuc));
        }
Beispiel #4
0
        // GET: /OldCopies/Delete/5
        public ActionResult Delete(int?id)
        {
            DateTime currentDate = DateTime.Now;
            var      data        = db.DVDDetails.Where(d => EntityFunctions.DiffDays(d.DateAdded, currentDate) > 365);

            foreach (var item in data)
            {
                db.DVDDetails.Remove(item);
            }
            db.SaveChanges();
            ViewBag.Message = "Delete successful";
            return(RedirectToAction("Index"));
        }
        public void ClearOldServiceMessages()
        {
            var targets = DataService.PerThread.MessageSet
                          .Where(x => x.Type != (byte)MessageType.PrivateMessage && EntityFunctions.DiffMonths(x.Date, DateTime.Today) > 1)
                          .ToList();

            foreach (var msg in targets)
            {
                DataService.PerThread.MessageSet.DeleteObject(msg);
            }

            DataService.PerThread.SaveChanges();
        }
Beispiel #6
0
        private StatusData.Status GetCurrentStatusMinus30(int counterId, double minThreshold, double maxThreshold)
        {
            var stat = _context.Results
                       .Where(c => c.DeviceCounter.Id == counterId)
                       .Where(t => t.LogDate <= EntityFunctions.AddMinutes(DateTime.Now, -20) && t.LogDate >= EntityFunctions.AddMinutes(DateTime.Now, -30))
                       .FirstOrDefault();

            if (stat != null)
            {
                return(GetStatus(minThreshold, maxThreshold, stat.AverageRead, stat.DeviceCounter.Device.Name));
            }
            return(StatusData.Status.Green);
        }
Beispiel #7
0
        public ActionResult Index()
        {
            var liste = db.PERSONELs.Where(a => a.DOGUM_GUNU_TARIHI != null).
                        OrderBy(a => EntityFunctions.DiffDays(DateTime.Today, EntityFunctions.AddYears(a.DOGUM_GUNU_TARIHI, EntityFunctions.DiffYears(a.DOGUM_GUNU_TARIHI, DateTime.Today) +
                                                                                                       ((a.DOGUM_GUNU_TARIHI.Month < DateTime.Today.Month ||
                                                                                                         (a.DOGUM_GUNU_TARIHI.Day <= DateTime.Today.Day && a.DOGUM_GUNU_TARIHI.Month == DateTime.Today.Month)) ? 1 : 0)))).Take(3).ToList();

            ViewData["yuksek"]   = db.EGITIMs.Where(s => s.OGRETIM_TIPI == "Yüksek Lisans").Count();
            ViewData["lisans"]   = db.EGITIMs.Where(s => s.OGRETIM_TIPI == "Lisans").Count();
            ViewData["onlisans"] = db.EGITIMs.Where(s => s.OGRETIM_TIPI == "Ön Lisans").Count();
            ViewData["duyuru"]   = db.DUYURUs.ToList();
            return(View(liste));
        }
Beispiel #8
0
        public ActionResult PayConsultation(ConsultationPaymentViewModel model)
        {
            if (model.price < (model.discount + model.insurer))
            {
                ModelState.AddModelError("", _("lblPaymentAmountsErr"));
            }

            var consultation = db.Consultations
                               .FirstOrDefault(c => c.patientID == model.patientID && c.doctorID == model.doctorID &&
                                               EntityFunctions.TruncateTime(c.createDate) == EntityFunctions.TruncateTime(DateTime.Now));

            if (consultation != null && consultation.Consultations_Payment.FirstOrDefault() != null)
            {
                ModelState.AddModelError("alreadyPayed", _("lblPaymentMadeErr"));
            }

            if (ModelState.IsValid)
            {
                var c = new Consultation();
                GlobalHelpers.Transfer <ConsultationPaymentViewModel, Consultation>(model, c);
                var cp = new Consultations_Payment();
                cp.Consultation = c;
                GlobalHelpers.Transfer <ConsultationPaymentViewModel, Consultations_Payment>(model, cp);
                db.Consultations.Add(c);
                db.Consultations_Payment.Add(cp);
                var appointment = db.Appointments.FirstOrDefault(a => a.finalStatus == null && a.patientID == model.patientID);
                if (appointment != null)
                {
                    appointment.finalStatus     = AppointmentStatus.Assisted.ToString();
                    db.Entry(appointment).State = EntityState.Modified;
                }
                db.SaveChanges();
                return(RedirectToAction("Index", "Consultations"));
            }
            ViewBag.patientID = db.Patients
                                .Where(p => p.User1.status == true &&
                                       p.Appointments.FirstOrDefault(a => a.finalStatus == null) != null &&
                                       EntityFunctions.TruncateTime(p.Appointments.FirstOrDefault(a => a.finalStatus == null).appointmentDate)
                                       == EntityFunctions.TruncateTime(DateTime.Now)).ToList()
                                .ToSelectListItems(p => p.UserAccount.CompleteName, p => p.ID.ToString(), p => p.ID == model.patientID);
            ViewBag.doctorID = db.Doctors
                               .Where(d => d.User.status == true).ToList()
                               .ToSelectListItems(d => d.User.CompleteName, d => d.ID.ToString(), d => d.ID == model.doctorID);
            ViewBag.insurerID = db.Insurers
                                .Where(i => i.status == true)
                                .ToSelectListItems(i => i.name, i => i.ID.ToString(), i => i.ID == model.insurerID);
            ViewBag.paymentForm = (GlobalHelpers.ParseEnum <PaymentForms>(model.paymentForm)).EnumToList(false);
            ViewBag.patients    = db.Patients.Where(p => p.User1.status == true).ToList();

            return(View(model));
        }
Beispiel #9
0
        //public static List<TeamMember> GetTeamMemberList(int UserId)
        //{
        //    List<TeamMember> memberList = new List<TeamMember>();
        //    using (DSRCManagementSystemEntities1 dbHrms = new DSRCManagementSystemEntities1())
        //    {
        //        var ProjectIds = dbHrms.UserProjects.Where(x => x.UserID == UserId).Select(x => x.ProjectID).ToList();
        //        var UserList = dbHrms.UserProjects.Where(x => ProjectIds.Contains(x.ProjectID)).Select(x => x.UserID).Distinct().ToList();
        //        memberList = dbHrms.Users.Where(x => UserList.Contains(x.UserID)).Select(x => new TeamMember()
        //             {
        //                 MemberId = x.EmpID,
        //                 MemberName = (x.FirstName + " " + (x.LastName ?? "")).Trim()
        //             }).OrderBy(x => x.MemberName).ToList();
        //        memberList.Insert(0, new TeamMember()
        //        {
        //            MemberId = "0",
        //            MemberName = "All"
        //        }
        //        );
        //        return memberList;
        //    }
        //}
        #endregion



        #region Individual work entry

        public static List <HoursWorkData> GetSingleMemberData(string EmpId, DateTime FromDate, DateTime ToDate, bool IsAscending, int BranchId)
        {
            try
            {
                using (DSRCManagementSystemEntities1 dbHrms = new DSRCManagementSystemEntities1())
                {
                    var WorkingHoursData = dbHrms.TimeManagements.Where(x => x.EmpID == EmpId && x.BranchId == BranchId && x.Date >= FromDate && x.Date <= ToDate).
                                           OrderBy(x => x.Date).Select(x => new WorkData
                    {
                        Date       = EntityFunctions.TruncateTime(x.Date) ?? DateTime.Now,
                        minsWorked = x.TotalTime,
                        BranchID   = x.BranchId,
                        //    minsWorked = x.OutTimeMin == 0 ? null : x.OutTimeMin - x.InTimeMin,
                        IsOutEntry = (x.OutTimeMin != 0),
                        IsAbsent   = (x.OutTimeMin == 0 && x.InTimeMin == 0),
                        InTime     = x.InTime,
                        OutTime    = x.OutTime
                    }).ToList();
                    ///var lll = dbHrms.TimeManagements.Where(x => x.EmpID.Contains(EmpId));
                    List <HoursWorkData> JsonWorkedData = new List <HoursWorkData>();
                    if (IsAscending)
                    {
                        JsonWorkedData = WorkingHoursData.Select(x => new DSRCManagementSystem.Models.HoursWorkData()
                        {
                            Date = (x.IsAbsent) ? x.Date.ToString(DateFormat) + LeaveFormat : (!x.IsOutEntry) ? x.Date.ToString(DateFormat) + NoOutEntryFormat : x.Date.ToString(DateFormat),
                            //hoursWorked = Math.Round((double)((x.minsWorked == null ? 0 : x.IsOutEntry ? (Math.Round(TimeSpan.FromMinutes(x.minsWorked ?? 0).TotalHours, 0) >= 5 ? (Math.Floor(TimeSpan.FromMinutes(x.minsWorked ?? 0).TotalHours) - 1) : Math.Floor(TimeSpan.FromMinutes(x.minsWorked ?? 0).TotalHours)) : 0) + ((x.minsWorked % 60) / 100)), 2),
                            hoursWorked = Math.Round((double)((x.minsWorked == null ? 0 : x.IsOutEntry ? (Math.Floor(TimeSpan.FromMinutes(x.minsWorked ?? 0).TotalHours)) : 0) + ((x.minsWorked % 60) / 100)), 2),
                            Day         = x.Date.ToString("dddd"),
                            InTime      = x.InTime,
                            OutTime     = x.OutTime
                        }).ToList();
                    }
                    else
                    {
                        JsonWorkedData = WorkingHoursData.Select(x => new DSRCManagementSystem.Models.HoursWorkData()
                        {
                            Date        = (x.IsAbsent) ? x.Date.ToString(DateFormat) + LeaveFormat : (!x.IsOutEntry) ? x.Date.ToString(DateFormat) + NoOutEntryFormat : x.Date.ToString(DateFormat),
                            hoursWorked = Math.Round((double)((x.minsWorked == null ? 0 : x.IsOutEntry ? (Math.Floor(TimeSpan.FromMinutes(x.minsWorked ?? 0).TotalHours)) : 0) + ((x.minsWorked % 60) / 100)), 2),
                            Day         = x.Date.ToString("dddd"),
                            InTime      = x.InTime,
                            OutTime     = x.OutTime
                        }).ToList();
                    }
                    return(JsonWorkedData);
                }
            }
            catch
            {
                return(new List <HoursWorkData>());
            }
        }
Beispiel #10
0
        public List <CheckOut> GetCheckOuts(DateTime date)
        {
            List <CheckOut> list = new List <CheckOut>();

            try
            {
                list.AddRange(hotelDB.CheckOuts.Where(i => EntityFunctions.TruncateTime(i.checkOutDate) <= EntityFunctions.TruncateTime(date)));
                return(list);
            }
            catch (Exception)
            {
                return(list);
            }
        }
Beispiel #11
0
        public override void FilaVistoBuenoCambiado(DataGridViewRow Fila, bool bVistoBueno)
        {
            if (this.Actualizando)
            {
                return;
            }

            string sCatTabla    = Util.Cadena(Fila.Cells["Tabla"].Value);
            int    iRegistroID  = Util.Entero(Fila.Cells["RegistroID"].Value);
            int    iUsuarioVBId = GlobalClass.UsuarioGlobal.UsuarioID;

            // Se obtiene el visto bueno a marcar/desmarcar, si es que ya existe
            DateTime dHoy        = DateTime.Today;
            var      oVistoBueno = Datos.GetEntity <CajaVistoBueno>(q => q.CatTabla == sCatTabla && q.TablaRegistroID == iRegistroID &&
                                                                    EntityFunctions.TruncateTime(q.Fecha) == dHoy);

            if (bVistoBueno)
            {
                if (oVistoBueno == null)
                {
                    // Se guarda el dato de visto bueno
                    oVistoBueno = new CajaVistoBueno()
                    {
                        CatTabla            = sCatTabla,
                        TablaRegistroID     = iRegistroID,
                        UsuarioVistoBuenoID = iUsuarioVBId,
                        Fecha = DateTime.Now
                    };
                    Datos.Guardar <CajaVistoBueno>(oVistoBueno);
                }
                else
                {
                    UtilLocal.MensajeAdvertencia("Ya existe un Visto Bueno para el registro especificado.");
                }
                Fila.Cells["TextoCheck"].Value = oVistoBueno.Fecha.ToString(CajaDetalleCorte.FormatoHora);
            }
            else
            {
                // Se borra el dato de visto bueno
                if (oVistoBueno == null)
                {
                    UtilLocal.MensajeAdvertencia("No se encontró el Visto Bueno especificado, en la base de datos.");
                }
                else
                {
                    Datos.Eliminar <CajaVistoBueno>(oVistoBueno, false);
                }
                Fila.Cells["TextoCheck"].Value = "";
            }
        }
Beispiel #12
0
        public ActionResult Index()
        {
            DateTime currentDate = DateTime.Now;
            DateTime date        = DateTime.Now.AddDays(45);

            Console.WriteLine(currentDate);
            System.Diagnostics.Debug.WriteLine(currentDate);
            System.Diagnostics.Debug.WriteLine(date);
            System.Diagnostics.Debug.WriteLine(date.Subtract(currentDate));

            var data = db.DVDDetails.Where(d => EntityFunctions.DiffDays(d.DateAdded, currentDate) > 365).ToList();

            return(View(data));
        }
        public List <MeterUnitCollect> MeterUnitCollect(DateTime fromDate, DateTime toDate, string transformerID, string QuarterID)
        {
            List <MeterUnitCollect> data;

            if (!string.IsNullOrEmpty(transformerID))
            {
                data = mBMSEntities.MeterUnitCollects.Where(x => EntityFunctions.TruncateTime(x.FromDate) >= fromDate.Date && EntityFunctions.TruncateTime(x.ToDate) <= toDate.Date && x.TransformerID == transformerID).ToList();
            }
            else
            {
                data = mBMSEntities.MeterUnitCollects.Where(x => EntityFunctions.TruncateTime(x.FromDate) >= fromDate.Date && EntityFunctions.TruncateTime(x.ToDate) <= toDate.Date).ToList();
            }
            return(data);
        }
Beispiel #14
0
        private StatusData.Status GetCurrentDeviceCounterStatus(DeviceCounterBase counter)
        {
            var result = _context.Results
                         .Where(r => r.DeviceCounter.Id == counter.Id)
                         .Where(r => r.LogDate >= EntityFunctions.AddMinutes(DateTime.Now, -5))
                         .Select(r => r.AverageRead)
                         .FirstOrDefault();

            if (result <= counter.MinThreshold)
            {
                return(StatusData.Status.Green);
            }
            return(result >= counter.MaxThreshold ? StatusData.Status.Red : StatusData.Status.Yellow);
        }
        public void FindPaymentNumber()
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                lblAll.Text = (from u in db.Orders
                               where u.IsDelete == false
                               select new { u.OrderID }).Count().ToString();
                lblpay.Text = (from u in db.Orders
                               where u.IsDelete == false && u.IsPaid == true
                               select new { u.OrderID }).Count().ToString();
                lblFinal.Text = (from u in db.Orders
                                 where u.IsDelete == false && u.IsPaid == false && u.IsFinalized == true
                                 select new { u.OrderID }).Count().ToString();
                lblNotFinal.Text = (from u in db.Orders
                                    where u.IsDelete == false && u.IsFinalized == false
                                    select new { u.OrderID }).Count().ToString();

                //var n = (from u in db.Orders
                //    where u.IsDelete == false && u.IsNewOrder == false
                //    select new {u.OrderID});
                //if (n != null)
                //{
                //    int a = n.Count();
                //}
                string notCheckedOrderCount = (from u in db.Orders
                                               where u.IsDelete == false && (u.IsNewOrder == true || u.IsNewOrder == null)
                                               select new { u.OrderID }).Count().ToString();
                lblNotChecked.Text   = notCheckedOrderCount;
                lblNotification.Text = notCheckedOrderCount;
                lblNotiNotCheck.Text = notCheckedOrderCount;
                lblCounttotal.Text   = notCheckedOrderCount;


                DateTime yesterday = DateTime.Today.AddDays(-1).Date;
                DateTime today     = DateTime.Now.Date;
                //var yesterdayPaidOrders =db.Orders.Where(x => DateTime.Compare(x.PaymentDate.Value.Date, yesterday.Date) == 0).Count();
                var yesterdayPaidOrders = (from u in db.Orders
                                           where u.IsPaid == true && u.IsDelete == false &&
                                           EntityFunctions.TruncateTime(u.PaymentDate) == yesterday
                                           select u).Count();
                lblYesterdayPay.Text = yesterdayPaidOrders.ToString();

                var todayPaidOrders = (from u in db.Orders
                                       where u.IsPaid == true && u.IsDelete == false &&
                                       EntityFunctions.TruncateTime(u.PaymentDate) == today
                                       select u).Count();

                lblTodayPay.Text = todayPaidOrders.ToString();
            }
        }
Beispiel #16
0
        public JsonResult GetDailyRequestCount()
        {
            var List = oDBContext.CCMEMOMASTERs.Where(x => x.ISACTIVE).GroupBy(t => EntityFunctions.TruncateTime(t.CREATEDON)).Select(x => new ChartDailyRequestCount
            {
                requestDate = x.Key.Value,
                MemoCount   = x.Count()
            });

            return(Json(List.AsEnumerable().OrderBy(x => x.requestDate).Select(r => new
            {
                date = r.requestDate.GetValueOrDefault().ToString("dd.MM.yyyy"),
                count = r.MemoCount
            }), JsonRequestBehavior.AllowGet));
        }
Beispiel #17
0
        public List <int> TongLuotVanChuyenThucTe()
        {
            QLVanTai_2017 dbc = new QLVanTai_2017();
            List <int>    lis = new List <int>();

            for (int item = 1; item <= DateTime.Now.Day; item++)
            {
                DateTime a = new DateTime(DateTime.Now.Year, DateTime.Now.Month, item);

                var temp = dbc.NhatTrinhXes.Where(ptr => EntityFunctions.TruncateTime(ptr.GioCapXuatBen) == a.Date && ptr.XeXepKhach.Value == true).ToList();
                lis.Add(temp.Count);
            }
            return(lis);
        }
Beispiel #18
0
        public IQueryable <DOCUMENTO_SISTEMA> SeleccionarMensajes(short id_anio, short id_centro, int id_imputado, short id_ingreso,
                                                                  short tipoMensaje, string nuc = "", string causapenal = "", DateTime?fechaInicio = null, DateTime?fechaFinal = null)
        {
            var _res = (from n in this.Context.NUC
                        from m in this.Context.MENSAJE
                        from cp in this.Context.CAUSA_PENAL
                        where
                        m.ID_MEN_TIPO == tipoMensaje && n.ID_ANIO == id_anio && n.ID_CENTRO == id_centro && n.ID_IMPUTADO == id_imputado && n.ID_INGRESO == id_ingreso &&
                        n.ID_NUC == m.NUC && cp.ID_CENTRO == n.ID_CENTRO && cp.ID_ANIO == n.ID_ANIO && cp.ID_IMPUTADO == n.ID_IMPUTADO && cp.ID_INGRESO == n.ID_INGRESO && cp.ID_CAUSA_PENAL == n.ID_CAUSA_PENAL
                        select new DOCUMENTO_SISTEMA {
                CP_ANIO = cp.CP_ANIO,
                CP_FOLIO = cp.CP_FOLIO,
                DOCUMENTO = m.INTER_DOCTO.DOCTO,
                FORMATO_DOCUMENTO = m.INTER_DOCTO.ID_FORMATO,
                MENSAJE = m.CONTENIDO,
                NUC = m.NUC.Trim(),
                REGISTRO_FEC = m.REGISTRO_FEC,
                CAUSA_PENAL = cp
            });

            if (!string.IsNullOrWhiteSpace(nuc) || (!string.IsNullOrWhiteSpace(causapenal) && causapenal.Length > 5 && causapenal.Length <= 10) || fechaInicio.HasValue || fechaFinal.HasValue)
            {
                var predicate = PredicateBuilder.True <DOCUMENTO_SISTEMA>();
                if (!string.IsNullOrWhiteSpace(nuc))
                {
                    predicate = predicate.And(w => w.NUC == nuc);
                }
                if (!string.IsNullOrWhiteSpace(causapenal) && causapenal.Length > 5 && causapenal.Length <= 10)
                {
                    int _anio  = 0;
                    int _folio = 0;
                    _anio     = int.Parse(causapenal.Substring(0, 4));
                    _folio    = int.Parse(causapenal.Substring(5, causapenal.Length - 5));
                    predicate = predicate.And(w => w.CP_ANIO == _anio && w.CP_FOLIO == _folio);
                }
                if (fechaInicio.HasValue)
                {
                    predicate = predicate.And(w => EntityFunctions.TruncateTime(w.REGISTRO_FEC) >= fechaInicio.Value);
                }
                if (fechaFinal.HasValue)
                {
                    predicate = predicate.And(w => EntityFunctions.TruncateTime(w.REGISTRO_FEC) <= fechaFinal.Value);
                }
                return(_res.Where(predicate.Expand()));
            }
            else
            {
                return(_res);
            }
        }
Beispiel #19
0
        public ActionResult Report(FamilyReportInfo familyReportInfo)
        {
            var entityContext = new EntityContext();
            var fromDate      = Convert.ToDateTime(familyReportInfo.FromDate);
            var toDate        = Convert.ToDateTime(familyReportInfo.ToDate);
            var reports       = new List <FamilyInfo>();

            if (fromDate != DateTime.MinValue || toDate != DateTime.MinValue)
            {
                reports = entityContext.familyInfos.Where(q => EntityFunctions.TruncateTime(q.CreateDate) >= fromDate && EntityFunctions.TruncateTime(q.CreateDate) <= toDate).ToList();
            }
            familyReportInfo.ReportInfo = reports;
            return(View(familyReportInfo));
        }
Beispiel #20
0
        protected internal Room GetAlternateRoom(TimeSpan startTime, TimeSpan endTime, int numberOfAttendees, int locationId, bool orderAsc)
        {
            Location location       = _locationRepository.GetLocationById(locationId);
            var      availableRooms = _roomRepository.GetByLocationAndSeatCount(location, numberOfAttendees)
                                      .Where(x => x.Bookings.Where(b => startTime <EntityFunctions.CreateTime(b.EndDate.Hour, b.EndDate.Minute, b.EndDate.Second) && endTime> EntityFunctions.CreateTime(b.StartDate.Hour, b.StartDate.Minute, b.StartDate.Second)).Count() == 0);


            availableRooms = (orderAsc) ? availableRooms.OrderBy(r => r.SeatCount) : availableRooms.OrderByDescending(r => r.SeatCount);
            Room alternateRoom = availableRooms.FirstOrDefault();

            _logger.Trace(LoggerHelper.ExecutedFunctionMessage(alternateRoom, startTime, endTime, numberOfAttendees, locationId, orderAsc));

            return(alternateRoom);
        }
        public int?GetNextIndexOfDay()
        {
            DateTime d   = DateTime.Now;
            int?     max = DataProvider.Instant.DB.HealthRecords.Where(x => EntityFunctions.TruncateTime(x.CreateAt) == d.Date).Select(x => x.IndexOfDay).Max();

            if (max == null)
            {
                return(1);
            }
            else
            {
                return(max + 1);
            }
        }
Beispiel #22
0
        public List <TblBankDeposit> SearchTblBankDeposit(string iserial, string storeName, DateTime?Date, string Code, List <int> Storeiserial, string company)
        {
            using (var db = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var tbl = db.TblBankDeposits.Include("TblStore1").Where(m => (m.TblStore1.ENAME.StartsWith(storeName) || storeName == null || storeName == "") &&
                                                                        (m.Iserial.StartsWith(iserial) || iserial == null) &&
                                                                        (m.TblStore1.code.StartsWith(Code) || Code == null || Code == "") &&
                                                                        ((EntityFunctions.TruncateTime(m.FromDate) >= Date && EntityFunctions.TruncateTime(m.ToDate) >= Date) || Date == null) &&
                                                                        Storeiserial.Any(l => m.TblStore1.iserial == l))
                          .ToList();

                return(tbl);
            }
        }
Beispiel #23
0
        public void ActualizarDatos()
        {
            // Se cargan las ventas pendientes en el Grid
            DateTime dHoy   = DateTime.Today;
            var      oPagos = Datos.GetListOf <VentasPagosView>(q => q.SucursalID == GlobalClass.SucursalID &&
                                                                (q.VentaEstatusID != Cat.VentasEstatus.Cancelada && q.VentaEstatusID != Cat.VentasEstatus.CanceladaSinPago) &&
                                                                EntityFunctions.TruncateTime(q.Fecha) == dHoy && q.Importe > 0).OrderBy(q => q.Folio);

            this.dgvDatos.Rows.Clear();
            foreach (var oPago in oPagos)
            {
                this.dgvDatos.Rows.Add(oPago.VentaPagoID, oPago.VentaID, oPago.ClienteID, oPago.Facturada, oPago.Folio, oPago.Cliente, oPago.Vendedor, oPago.Importe);
            }
        }
Beispiel #24
0
        /// <summary>
        /// Finds meetings that clash with a certain time on specific dates.
        /// </summary>
        /// <param name="room">Room to check for meetings in. Provided as this allows us to specify the room, rather than riskly grabbing the room of a random booking</param>
        /// <param name="startTime">Time for which the meetings will begin</param>
        /// <param name="endTime">Time for which the meetings will end</param>
        /// <param name="dates">Dates for to check for meeting clashes</param>
        /// <param name="clashedBookings">OUT bookings which clash with the given parameters</param>
        /// <returns>Boolean based on whether there were any clashes</returns>
        bool DoMeetingsClashRecurringly(Room room, TimeSpan startTime, TimeSpan endTime, DateTime date, out IEnumerable <Booking> clashedBookings)
        {
            ////Get dates only as we are checking against only the date portion in the DB
            //var datesOnly = dates.Select(x => x.Date);

            var totalBookingsClashed = _bookingRepository.GetByDateOnlyAndRoom(date, room)
                                       //Only bookings on the days that intersect our given time period
                                       .Where(z => startTime <= EntityFunctions.CreateTime(z.StartDate.Hour, z.StartDate.Minute, z.StartDate.Second) && endTime > EntityFunctions.CreateTime(z.StartDate.Hour, z.StartDate.Minute, z.StartDate.Second) ||
                                              startTime >= EntityFunctions.CreateTime(z.StartDate.Hour, z.StartDate.Minute, z.StartDate.Second) && startTime < EntityFunctions.CreateTime(z.EndDate.Hour, z.EndDate.Minute, z.EndDate.Second))
                                       .ToList();   // bug fix

            clashedBookings = totalBookingsClashed; // WORKING
            return(totalBookingsClashed.Count > 0);
        }
        public List <Customer> _RecentCustomers()
        {
            List <Customer> objCustomerlst = new List <Customer>();

            try
            {
                using (var db = new DBContext())
                {
                    var objCustomer = (from c in db.Customers
                                       join m in db.MachineDetails on c.CustomerId equals m.CustomerId
                                       join am in db.AdminScheduleReport on m.MachineDetailId equals am.MachineDetailId
                                       where EntityFunctions.TruncateTime(m.CreatedDate) == EntityFunctions.TruncateTime(DateTime.Now) &&
                                       am.bSend == false
                                       select new
                    {
                        c.FirstName,
                        c.LastName,
                        c.CustomerId,
                        c.Email,
                        c.OrganizationName,
                        m.CreatedDate,
                    }).ToList();

                    foreach (var item in objCustomer)
                    {
                        var MachineCount = db.MachineDetails.Where(a => a.CustomerId == item.CustomerId).Count();
                        var Downloads    = db.CustomerDownloadHistory.Where(a => a.CustomerId == item.CustomerId).Count();
                        objCustomerlst.Add(new Customer
                        {
                            CustomerId       = item.CustomerId,
                            LastName         = item.LastName,
                            FirstName        = item.FirstName,
                            Email            = item.Email,
                            OrganizationName = item.OrganizationName,
                            count            = MachineCount,
                            Downloads        = Downloads,
                            CreateDate       = item.CreatedDate,
                        });
                    }
                    return(objCustomerlst);
                }
            }
            catch (Exception e)
            {
                ExceptionHandler handler = new ExceptionHandler();
                handler.HandleException(e);
            }
            return(null);
        }
        public static CallRegistryCollection GetCallRegistries(string connectionString, string searchName, DateTime?callDate)
        {
            try
            {
                using (var context = new CallRegistryDBContext(connectionString))
                {
                    var callRegCollection           = new CallRegistryCollection();
                    IQueryable <CallRegistry> items = null;
                    if (callDate.HasValue && !string.IsNullOrEmpty(searchName))
                    {
                        items =
                            context.CallRegistries.Where(
                                x =>
                                EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value) &&
                                x.Name.Contains(searchName));
                    }
                    else if (!string.IsNullOrEmpty(searchName))
                    {
                        items = context.CallRegistries.Where(x => x.Name.Contains(searchName));
                    }
                    else if (callDate.HasValue)
                    {
                        items =
                            context.CallRegistries.Where(
                                x =>
                                EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value));
                    }
                    else
                    {
                        items = context.CallRegistries;
                    }
                    if (items != null)
                    {
                        foreach (var callReg in items)
                        {
                            callRegCollection.Add(callReg);
                        }
                    }

                    return(new CallRegistryCollection(callRegCollection.ObservableList.OrderByDescending(x => x.CallDate).ToList()));
                }
            }
            catch (Exception exception)
            {
                NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                                    ExceptionResources.ExceptionOccuredLogDetail);
                return(null);
            }
        }
        public void InsertData(DateTime holidayDate, string holidayDesc, List <string> branchCodeList, string createdBy)
        {
            try
            {
                DateTime      createdDate      = DateTime.Now;
                List <string> dbBranchCodeList = null;

                //หา branch ที่มีอยู่ในเบส
                if (holidayDate.Year != 1)
                {
                    dbBranchCodeList = slmdb.kkslm_ms_calendar_branch.Where(p => EntityFunctions.TruncateTime(p.slm_HolidayDate) == EntityFunctions.TruncateTime(holidayDate) && p.is_Deleted == false).Select(p => p.slm_BranchCode).ToList();
                }
                else
                {
                    throw new Exception("Cannot find holiday date");
                }

                //เอา branch ที่มีอยู่ในเบสแล้ว ออกจาก list ที่ต้องการ insert
                if (dbBranchCodeList.Count > 0)
                {
                    branchCodeList = branchCodeList.Except <string>(dbBranchCodeList).ToList();
                }

                if (branchCodeList.Count > 0)
                {
                    foreach (string branchcode in branchCodeList)
                    {
                        kkslm_ms_calendar_branch obj = new kkslm_ms_calendar_branch()
                        {
                            slm_HolidayDate = holidayDate,
                            slm_HolidayDesc = holidayDesc,
                            slm_BranchCode  = branchcode,
                            slm_CreatedBy   = createdBy,
                            slm_CreatedDate = createdDate,
                            slm_UpdatedBy   = createdBy,
                            slm_UpdatedDate = createdDate,
                            is_Deleted      = false
                        };
                        slmdb.kkslm_ms_calendar_branch.AddObject(obj);
                    }

                    slmdb.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public override void Execute(IJobExecutionContext context)
        {
            // Get the list of users who have an active trial and have not logged in for more than 5 days
            List <IUser> inactiveUsers = (from user in _database.GetUsers
                                          where !user.SubscriptionId.HasValue && user.TrialExpiryDate > DateTime.UtcNow &&
                                          EntityFunctions.DiffDays(user.LastLoginDate, DateTime.UtcNow) >= 5 &&
                                          !user.SentInactiveReminder
                                          select user).ToList();

            // Generate email for inactive members
            // TODO: EmailResult emailContents = _accountEmailFactory.InactiveTrialAccount();
            IEmail inactiveUserEmail = _emailFactory.CreateEmail(
                contents: this.GetEmailContents(),
                subject: "Inactive Trial Account",
                recipients: inactiveUsers);

            // Send the email to users
            inactiveUserEmail.Send();

            // Mark the users so that they don't get duplicate notifications
            foreach (var user in inactiveUsers)
            {
                user.SentInactiveReminder = true;
            }
            _database.SaveChanges();

            // Notify dear admins
            StringBuilder adminEmailContents = new StringBuilder();

            adminEmailContents.Append("<html><head></head><body>Fellow admins, your server over here speaking. I just reminded ");
            adminEmailContents.Append(inactiveUsers.Count);
            adminEmailContents.Append(" users that they have been inactive for more than 5 days. Here is who I sent email to:<br/><br/>");

            foreach (IUser user in inactiveUsers)
            {
                adminEmailContents.Append(user.FirstName);
                adminEmailContents.Append(" ");
                adminEmailContents.Append(user.LastName);
                adminEmailContents.Append(" ");
                adminEmailContents.Append(user.EmailAddress);
                adminEmailContents.Append("<br/>");
            }

            adminEmailContents.Append("I'm going to go sleep for another day now.</body></html>");

            IEmail adminNotificationEmail = _emailFactory.CreateEmailForAdministrators(adminEmailContents.ToString(), "Inactive Users Report " + DateTime.UtcNow.ToShortDateString());

            adminNotificationEmail.Send();
        }
Beispiel #29
0
 public static int CountDelayingOrders(this HtmlHelper htmlHelper, int companyId)
 {
     using (OrdersRepository ordersRep = new OrdersRepository(companyId))
     {
         DateTime CurrentTime = DateTime.Now;
         return(ordersRep.GetList("Orders_Statuses", "Supplier", "User")
                .Where(x =>
                       EntityFunctions.DiffHours(x.CreationDate, CurrentTime) >= 48 &&
                       x.StatusId < (int)StatusType.ApprovedPendingInvoice &&
                       x.StatusId != (int)StatusType.Declined &&
                       x.StatusId != (int)StatusType.OrderCancelled
                       )
                .Count());
     }
 }
        // GET: ServicesStatus
        public ActionResult ServiceStatus()
        {
            ViewBag.SunSystems = Common.Helpers.parameters.Sunsys;
            ViewBag.GIS        = Common.Helpers.parameters.Gis;
            ViewBag.BIPServer1 = Common.Helpers.parameters.billpayments1;
            ViewBag.sics       = Common.Helpers.parameters.sics;
            ViewBag.tds        = Common.Helpers.parameters.tds;
            ViewBag.sybrin     = Common.Helpers.parameters.sybrin;
            // ViewBag.billpayments = Common.Helpers.parameters.billpayments;
            DateTime date     = DateTime.Today;
            var      services = db.ServiceMonitors.Include(d => d.Application).Include(d => d.Server).Include(d => d.Service)
                                .Where(d => EntityFunctions.TruncateTime(d.RunDate) == date);

            return(View(services.ToList()));
        }