コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.manager_log GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,user_id,user_name,action_type,note,login_ip,login_time from dt_manager_log ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Hoto.Model.manager_log model = new Hoto.Model.manager_log();
            DataSet ds = DbHelperSQL.Query(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());
                }
                if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                model.user_name   = ds.Tables[0].Rows[0]["user_name"].ToString();
                model.action_type = ds.Tables[0].Rows[0]["action_type"].ToString();
                model.note        = ds.Tables[0].Rows[0]["note"].ToString();
                model.login_ip    = ds.Tables[0].Rows[0]["login_ip"].ToString();
                if (ds.Tables[0].Rows[0]["login_time"].ToString() != "")
                {
                    model.login_time = DateTime.Parse(ds.Tables[0].Rows[0]["login_time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: manager_log.cs プロジェクト: refinedKing/Hoto-cms
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Model.manager_log GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,user_id,user_name,action_type,note,login_ip,login_time from dt_manager_log ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Hoto.Model.manager_log model = new Hoto.Model.manager_log();
            DataSet ds = DbHelperSQL.Query(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());
                }
                if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                model.action_type = ds.Tables[0].Rows[0]["action_type"].ToString();
                model.note = ds.Tables[0].Rows[0]["note"].ToString();
                model.login_ip = ds.Tables[0].Rows[0]["login_ip"].ToString();
                if (ds.Tables[0].Rows[0]["login_time"].ToString() != "")
                {
                    model.login_time = DateTime.Parse(ds.Tables[0].Rows[0]["login_time"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }