public Rain.Model.user_login_log DataRowToModel(DataRow row) { Rain.Model.user_login_log userLoginLog = new Rain.Model.user_login_log(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { userLoginLog.id = int.Parse(row["id"].ToString()); } if (row["user_id"] != null && row["user_id"].ToString() != "") { userLoginLog.user_id = int.Parse(row["user_id"].ToString()); } if (row["user_name"] != null) { userLoginLog.user_name = row["user_name"].ToString(); } if (row["remark"] != null) { userLoginLog.remark = row["remark"].ToString(); } if (row["login_time"] != null && row["login_time"].ToString() != "") { userLoginLog.login_time = DateTime.Parse(row["login_time"].ToString()); } if (row["login_ip"] != null) { userLoginLog.login_ip = row["login_ip"].ToString(); } } return(userLoginLog); }
public int Add(Rain.Model.user_login_log model) { int maxId; using (OleDbConnection oleDbConnection = new OleDbConnection(DbHelperOleDb.connectionString)) { oleDbConnection.Open(); using (OleDbTransaction trans = oleDbConnection.BeginTransaction()) { try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("insert into " + this.databaseprefix + "user_login_log("); stringBuilder.Append("user_id,user_name,[remark],login_time,login_ip)"); stringBuilder.Append(" values ("); stringBuilder.Append("@user_id,@user_name,@remark,@login_time,@login_ip)"); stringBuilder.Append(";select @@IDENTITY"); OleDbParameter[] oleDbParameterArray = new OleDbParameter[5] { new OleDbParameter("@user_id", OleDbType.Integer, 4), new OleDbParameter("@user_name", OleDbType.VarChar, 100), new OleDbParameter("@remark", OleDbType.VarChar, (int)byte.MaxValue), new OleDbParameter("@login_time", OleDbType.Date), new OleDbParameter("@login_ip", OleDbType.VarChar, 50) }; oleDbParameterArray[0].Value = (object)model.user_id; oleDbParameterArray[1].Value = (object)model.user_name; oleDbParameterArray[2].Value = (object)model.remark; oleDbParameterArray[3].Value = (object)model.login_time; oleDbParameterArray[4].Value = (object)model.login_ip; DbHelperOleDb.ExecuteSql(oleDbConnection, trans, stringBuilder.ToString(), oleDbParameterArray); maxId = this.GetMaxId(oleDbConnection, trans); trans.Commit(); } catch { trans.Rollback(); return(-1); } } } return(maxId); }
public int Add(Rain.Model.user_login_log model) { return(this.dal.Add(model)); }