public int[] SuggestPersons(string productName)
        {
            try
            {
                string[] relativeProducts = FindRelatives(productName);

                ECDBEntities entity = new ECDBEntities();
                var          ids    = (from purchase in entity.PurchaseTbls
                                       where
                                       relativeProducts.Contains(purchase.ProductName) &&
                                       Math.Abs((double)EntityFunctions.DiffMonths(DateTime.Today, purchase.Date.Value)) <= NumberOfMonthesForPurchase
                                       select purchase.Cid).Distinct();

                return(ids.ToArray());
            }
            catch (Exception ex)
            {
                MySoapFault fault = new MySoapFault();
                fault.Operation   = "SuggestPersons";
                fault.Reason      = "Error in suggesting persons for buyying product name :  " + productName + " .";
                fault.Details     = ex.Message;
                fault.MoreDetails = ex.StackTrace;
                throw new FaultException <MySoapFault>(fault);
            }
        }
示例#2
0
 /// <summary>
 /// 获取工作日报信息
 /// </summary>
 /// <returns></returns>
 public static IEnumerable GetWorkreport()
 {
     using (Entities db = new Entities())
     {
         DateTime  date = DateTime.Now;
         LoginUser user = new LoginUser();;
         return(db.V_US_WorkReportWithState.Where(
                    l => l.Creator == user.EmployeeId && EntityFunctions.DiffMonths(l.Date, date) == 0).OrderBy(l => l.Date).ToList());
     }
 }
示例#3
0
 /// <summary>
 /// 获取考勤信息
 /// </summary>
 /// <returns></returns>
 public static IEnumerable GetCheck()
 {
     using (Entities db = new Entities())
     {
         DateTime  date = DateTime.Now;
         LoginUser user = new LoginUser();;
         return(db.V_HR_AttendAssessWithExceptionType.Where(
                    l => l.UserId == user.EmployeeId && EntityFunctions.DiffMonths(l.AttendDate, date) == 0).OrderBy(l => l.AttendDate).ToList());
     }
 }
示例#4
0
        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();
        }
        public void DateTimeDiffMonths()
        {
            DateTime date = stored.AddYears(-1).AddMonths(-1);

#if !EFOLD
            var q = this.Entities
                    .Select(x =>
                            DbFunctions.DiffMonths(date, x.DateTime) == 13);
#else
            var q = this.Entities
                    .Where(x =>
                           EntityFunctions.DiffMonths(date, x.DateTime) == 13);
#endif

            q.Should().NotBeEmpty();
        }
示例#6
0
        private void UpdatingInformationDeposit()
        {
            string deposit    = LvDeposits.SelectedItem.ToString();
            int    k          = deposit.IndexOf('.');
            int    depositId  = Int32.Parse(deposit.Substring(0, k));
            var    depositSel = bd.Deposits.Find(depositId);

            TblName.Text     = depositSel.Name;
            TblNumber.Text   = depositSel.Term.ToString();
            TblPassport.Text = depositSel.Percent.ToString();
            TblAdress.Text   = depositSel.Currency.Name.ToString();
            TblStaff.Text    = null;
            InitializeInformationDeposit();
            var table = (from p in bd.DepositClients
                         join d in bd.Deposits on p.Deposit_Id equals d.Id
                         join c in bd.Clients on p.Client_Id equals c.Id
                         where EntityFunctions.AddMonths(p.DateOfEnrollment, d.Term) > DateTime.Today &&
                         d.Id == depositId
                         select new
            {
                id = d.Id,
                surname = c.Surname,
                name = c.Name,
                dateOfEnrollment = p.DateOfEnrollment,
                enrollment = p.Enrollment,
                endDate = EntityFunctions.AddMonths(p.DateOfEnrollment, d.Term),
                summ = (double)p.Enrollment * Math.Pow((double)(1 + (d.Percent) / (100 * 12)), (12 * (double)(EntityFunctions.DiffMonths(p.DateOfEnrollment, DateTime.Today)) / 12))
            }).ToList();

            depositsGrid.ItemsSource = table; //.Where(p => p.id == depositId);
        }
示例#7
0
        public void UpdatingInformationClient()
        {
            InitializeInformationClient();
            string client      = LvClients.SelectedItem.ToString();
            int    k           = client.IndexOf('.');
            int    clientId    = Int32.Parse(client.Substring(0, k));
            var    clientsSel2 = bd.Clients.FirstOrDefault(p => p.Id == clientId);

            TblName.Text     = clientsSel2.Surname + " " + clientsSel2.Name;
            TblNumber.Text   = clientsSel2.PhoneNumber;
            TblPassport.Text = clientsSel2.Passport;
            TblAdress.Text   = clientsSel2.City + ", " + clientsSel2.Adress;
            TblStaff.Text    = clientsSel2.Staff.Surname + " " + clientsSel2.Staff.Name;

            var table = (from p in bd.DepositClients
                         join d in bd.Deposits on p.Deposit_Id equals d.Id
                         join c in bd.Clients on p.Client_Id equals c.Id
                         where EntityFunctions.AddMonths(p.DateOfEnrollment, d.Term) > DateTime.Today
                         select new
            {
                id = c.Id,
                name = d.Name,
                currency = d.Currency.Name,
                dateOfEnrollment = p.DateOfEnrollment,
                enrollment = p.Enrollment,
                endDate = EntityFunctions.AddMonths(p.DateOfEnrollment, d.Term),
                summ = (double)p.Enrollment * Math.Pow((double)(1 + (d.Percent) / (100 * 12)), (12 * (double)(EntityFunctions.DiffMonths(p.DateOfEnrollment, DateTime.Today)) / 12))
            }).ToList();

            clientsGrid.ItemsSource = table.Where(p => p.id == clientId);
        }
示例#8
0
        public ActionResult StockPicks(int month, int year)
        {
            IEnumerable <StockPick> stockPicks = _database.StockPicks.Include(s => s.Type).Include(s => s.Updates)
                                                 .Where(stockPick => stockPick.IsPublished && EntityFunctions.DiffMonths(stockPick.PublishingDate, new DateTime(year, month, 1)) == 0)
                                                 .OrderByDescending(stockPick => stockPick.PublishingDate.Value);

            return(this.View(stockPicks));
        }
示例#9
0
        public ActionResult OptionPicks(int month, int year)
        {
            IEnumerable <OptionPick> optionPicks = _database.OptionPicks.Include(o => o.Type).Include(o => o.Updates).Include(o => o.Legs)
                                                   .Where(optionPick => optionPick.IsPublished && EntityFunctions.DiffMonths(optionPick.PublishingDate, new DateTime(year, month, 1)) == 0)
                                                   .OrderByDescending(optionPick => optionPick.PublishingDate.Value);

            return(this.View(optionPicks));
        }