Exemple #1
0
        /// <summary>
        /// 返回每日箴言
        /// </summary>
        /// <returns></returns>
        public string Tips()
        {
            string sqlwhere = "";
            string order    = "";

            sqlwhere = " Time_Update>='" + FormatTime(System.DateTime.Now.Date) + "' and Time_Update<'" + FormatTime(System.DateTime.Now.Date.AddDays(1)) + "'";
            if (LB.DataAccess.BaseUtils.BaseUtilsInstance.DBType == "sqlserver")
            {
                order = "newid()";
            }
            else if (LB.DataAccess.BaseUtils.BaseUtilsInstance.DBType == "access")
            {
                order = "id desc";
            }
            else if (LB.DataAccess.BaseUtils.BaseUtilsInstance.DBType == "mysql")
            {
                order = "rand()";
            }
            Lebi_Tips tips = B_Lebi_Tips.GetModel(sqlwhere);

            if (tips != null)
            {
                return(Lang(tips.Content));
            }
            else
            {
                List <Lebi_Tips> tipslist = B_Lebi_Tips.GetList("", order);
                tips = tipslist.FirstOrDefault();
                if (tips == null)
                {
                    tips = new Lebi_Tips();
                }
                else
                {
                    tips.Time_Update = System.DateTime.Now;
                    B_Lebi_Tips.Update(tips);
                    return(Lang(tips.Content));
                }
            }
            return("");
        }
Exemple #2
0
        /// <summary>
        /// 返回每日箴言
        /// </summary>
        /// <returns></returns>
        public string Tips()
        {
            string sqlwhere = "";
            string order    = "";

            if (DataBase.DBType == "sqlserver")
            {
                sqlwhere = " datediff(d,Time_Update,'" + FormatTime(System.DateTime.Now) + "')=0";
                order    = "newid()";
            }
            if (DataBase.DBType == "access")
            {
                sqlwhere = " datediff('d',Time_Update,'" + FormatTime(System.DateTime.Now) + "')=0";
                order    = "id desc";
            }
            Lebi_Tips tips = B_Lebi_Tips.GetModel(sqlwhere);

            if (tips != null)
            {
                return(Lang(tips.Content));
            }
            else
            {
                List <Lebi_Tips> tipslist = B_Lebi_Tips.GetList("", order);
                tips = tipslist.FirstOrDefault();
                if (tips == null)
                {
                    tips = new Lebi_Tips();
                }
                else
                {
                    tips.Time_Update = System.DateTime.Now;
                    B_Lebi_Tips.Update(tips);
                    return(Lang(tips.Content));
                }
            }
            return("");
        }