예제 #1
0
            /// <summary>
            /// 得到一个对象实体 by id
            /// </summary>
            public Lebi_Tips GetModel(int id)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select  top 1  * from [Lebi_Tips] ");
                strSql.Append(" where id=@id");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id", SqlDbType.Int, 4)
                };
                parameters[0].Value = id;

                Lebi_Tips model = new Lebi_Tips();
                DataSet   ds    = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                    }
                    model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                    if (ds.Tables[0].Rows[0]["Time_Update"].ToString() != "")
                    {
                        model.Time_Update = DateTime.Parse(ds.Tables[0].Rows[0]["Time_Update"].ToString());
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
예제 #2
0
            /// <summary>
            /// 得到一个对象实体 by SQLpara
            /// </summary>
            public Lebi_Tips GetModel(SQLPara para)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select top 1 * from [Lebi_Tips] ");
                if (para.Where != "")
                {
                    strSql.Append(" where " + para.Where + "");
                }
                Lebi_Tips model = new Lebi_Tips();
                DataSet   ds    = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), para.Para);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                    }
                    model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                    if (ds.Tables[0].Rows[0]["Time_Update"].ToString() != "")
                    {
                        model.Time_Update = DateTime.Parse(ds.Tables[0].Rows[0]["Time_Update"].ToString());
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
예제 #3
0
            /// <summary>
            /// 增加一条数据
            /// </summary>
            public int Add(Lebi_Tips model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("insert into [Lebi_Tips](");
                strSql.Append("Content,Time_Update)");
                strSql.Append(" values (");
                strSql.Append("@Content,@Time_Update)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Content",     model.Content),
                    new SqlParameter("@Time_Update", model.Time_Update)
                };

                object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters);

                if (obj == null)
                {
                    return(1);
                }
                else
                {
                    return(Convert.ToInt32(obj));
                }
            }
예제 #4
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Tips SafeBindForm(Lebi_Tips model)
 {
     if (HttpContext.Current.Request["Content"] != null)
     {
         model.Content = Shop.Tools.RequestTool.RequestSafeString("Content");
     }
     if (HttpContext.Current.Request["Time_Update"] != null)
     {
         model.Time_Update = Shop.Tools.RequestTool.RequestTime("Time_Update", System.DateTime.Now);
     }
     return(model);
 }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EX_Admin.Power("tips_list", "每日箴言"))
            {
                WindowNoPower();
            }
            int id = RequestTool.RequestInt("id", 0);

            model = B_Lebi_Tips.GetModel(id);
            if (model == null)
            {
                model = new Lebi_Tips();
            }
        }
예제 #6
0
            /// <summary>
            /// 更新一条数据
            /// </summary>
            public void Update(Lebi_Tips model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("update [Lebi_Tips] set ");
                strSql.Append("[Content]=@Content,");
                strSql.Append("[Time_Update]=@Time_Update");
                strSql.Append(" where id=" + model.id);
                OleDbParameter[] parameters =
                {
                    new OleDbParameter("@Content",     model.Content),
                    new OleDbParameter("@Time_Update", model.Time_Update.ToString("yyyy-MM-dd hh:mm:ss"))
                };

                AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters);
            }
예제 #7
0
            /// <summary>
            /// 增加一条数据
            /// </summary>
            public int Add(Lebi_Tips model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("insert into [Lebi_Tips](");
                strSql.Append("[Content],[Time_Update])");
                strSql.Append(" values (");
                strSql.Append("@Content,@Time_Update)");
                OleDbParameter[] parameters =
                {
                    new OleDbParameter("@Content",     model.Content),
                    new OleDbParameter("@Time_Update", model.Time_Update.ToString("yyyy-MM-dd hh:mm:ss"))
                };

                AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters);
                return(1);
            }
예제 #8
0
            /// <summary>
            /// 对象实体绑定数据
            /// </summary>
            public Lebi_Tips ReaderBind(IDataReader dataReader)
            {
                Lebi_Tips model = new Lebi_Tips();
                object    ojb;

                ojb = dataReader["id"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.id = (int)ojb;
                }
                model.Content = dataReader["Content"].ToString();
                ojb           = dataReader["Time_Update"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Time_Update = (DateTime)ojb;
                }
                return(model);
            }
예제 #9
0
            /// <summary>
            /// 更新一条数据
            /// </summary>
            public void Update(Lebi_Tips model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("update [Lebi_Tips] set ");
                strSql.Append("Content= @Content,");
                strSql.Append("Time_Update= @Time_Update");
                strSql.Append(" where id=@id");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",          SqlDbType.Int,         4),
                    new SqlParameter("@Content",     SqlDbType.NVarChar, 2000),
                    new SqlParameter("@Time_Update", SqlDbType.DateTime)
                };
                parameters[0].Value = model.id;
                parameters[1].Value = model.Content;
                parameters[2].Value = model.Time_Update;

                SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters);
            }
예제 #10
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("");
        }
예제 #11
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("");
        }
예제 #12
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Tips model)
 {
     D_Lebi_Tips.Instance.Update(model);
 }
예제 #13
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Tips model)
 {
     return(D_Lebi_Tips.Instance.Add(model));
 }
예제 #14
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Tips SafeBindForm(Lebi_Tips model)
 {
     return(D_Lebi_Tips.Instance.SafeBindForm(model));
 }