protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Model.managers.manager admin_info = GetAdminInfo(); //管理员信息 //登录信息 if (admin_info != null) { BLL.managers.manager_log bll = new BLL.managers.manager_log(); Model.managers.manager_log model1 = bll.GetModel(admin_info.user_name, 1, OSEnums.ActionEnum.Login.ToString()); if (model1 != null) { //本次登录 litIP.Text = model1.user_ip; } Model.managers.manager_log model2 = bll.GetModel(admin_info.user_name, 2, OSEnums.ActionEnum.Login.ToString()); if (model2 != null) { //上一次登录 litBackIP.Text = model2.user_ip; litBackTime.Text = model2.add_time.ToString(); } } } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.managers.manager_log model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "manager_log("); strSql.Append("user_id,user_name,action_type,remark,user_ip)"); strSql.Append(" values ("); strSql.Append("@user_id,@user_name,@action_type,@remark,@user_ip)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@user_name", SqlDbType.NVarChar, 100), new SqlParameter("@action_type", SqlDbType.NVarChar, 100), new SqlParameter("@remark", SqlDbType.NVarChar, 255), new SqlParameter("@user_ip", SqlDbType.NVarChar, 30) }; parameters[0].Value = model.user_id; parameters[1].Value = model.user_name; parameters[2].Value = model.action_type; parameters[3].Value = model.remark; parameters[4].Value = model.user_ip; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 增加管理日志 /// </summary> /// <param name="用户id"></param> /// <param name="用户名"></param> /// <param name="操作类型"></param> /// <param name="备注"></param> /// <returns></returns> public int Add(int user_id, string user_name, string action_type, string remark) { Model.managers.manager_log manager_log_model = new Model.managers.manager_log(); manager_log_model.user_id = user_id; manager_log_model.user_name = user_name; manager_log_model.action_type = action_type; manager_log_model.remark = remark; manager_log_model.user_ip = OSRequest.GetIP(); return dal.Add(manager_log_model); }
/// <summary> /// 增加管理日志 /// </summary> /// <param name="用户id"></param> /// <param name="用户名"></param> /// <param name="操作类型"></param> /// <param name="备注"></param> /// <returns></returns> public int Add(int user_id, string user_name, string action_type, string remark) { Model.managers.manager_log manager_log_model = new Model.managers.manager_log(); manager_log_model.user_id = user_id; manager_log_model.user_name = user_name; manager_log_model.action_type = action_type; manager_log_model.remark = remark; manager_log_model.user_ip = OSRequest.GetIP(); return(dal.Add(manager_log_model)); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.managers.manager_log GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,user_id,user_name,action_type,remark,user_ip,add_time from " + databaseprefix + "manager_log "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.managers.manager_log model = new Model.managers.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.remark = ds.Tables[0].Rows[0]["remark"].ToString(); model.user_ip = ds.Tables[0].Rows[0]["user_ip"].ToString(); if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.managers.manager_log GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,user_id,user_name,action_type,remark,user_ip,add_time from " + databaseprefix + "manager_log "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.managers.manager_log model = new Model.managers.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.remark = ds.Tables[0].Rows[0]["remark"].ToString(); model.user_ip = ds.Tables[0].Rows[0]["user_ip"].ToString(); if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } return model; } else { return null; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.managers.manager_log model) { return(dal.Add(model)); }