Exemplo n.º 1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(int user_id, string user_name, string remark)
 {
     Model.users.user_login_log model = new Model.users.user_login_log();
     model.user_id = user_id;
     model.user_name = user_name;
     model.remark = remark;
     model.login_ip = OSRequest.GetIP();
     model.login_time = DateTime.Now;
     return dal.Add(model);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.users.user_login_log GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,user_id,user_name,remark,login_time,login_ip from " + databaseprefix + "user_login_log ");
            strSql.Append(" where [email protected]");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.users.user_login_log model = new Model.users.user_login_log();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && 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"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["remark"] != null && ds.Tables[0].Rows[0]["remark"].ToString() != "")
                {
                    model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["login_time"] != null && ds.Tables[0].Rows[0]["login_time"].ToString() != "")
                {
                    model.login_time = DateTime.Parse(ds.Tables[0].Rows[0]["login_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["login_ip"] != null && ds.Tables[0].Rows[0]["login_ip"].ToString() != "")
                {
                    model.login_ip = ds.Tables[0].Rows[0]["login_ip"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }