/// <summary> /// 更新一条数据 /// </summary> public bool Update(KryptonAccessController.SQLite.Model.InteractRelation.EventInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update EventInfo set "); strSql.Append("ControllerID=@ControllerID,"); strSql.Append("PointType=@PointType,"); strSql.Append("PointID=@PointID,"); strSql.Append("CardID=@CardID,"); strSql.Append("EventCodeID=@EventCodeID,"); strSql.Append("EventDateTime=@EventDateTime"); strSql.Append(" where EventID=@EventID "); SQLiteParameter[] parameters = { new SQLiteParameter("@ControllerID", DbType.Int32, 4), new SQLiteParameter("@PointType", DbType.Int32, 4), new SQLiteParameter("@PointID", DbType.Int32, 4), new SQLiteParameter("@CardID", DbType.String), new SQLiteParameter("@EventCodeID", DbType.Int32, 4), new SQLiteParameter("@EventDateTime", DbType.String), new SQLiteParameter("@EventID", DbType.Int32, 4) }; parameters[0].Value = model.ControllerID; parameters[1].Value = model.PointType; parameters[2].Value = model.PointID; parameters[3].Value = model.CardID; parameters[4].Value = model.EventCodeID; parameters[5].Value = model.EventDateTime; parameters[6].Value = model.EventID; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(KryptonAccessController.SQLite.Model.InteractRelation.EventInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into EventInfo("); strSql.Append("EventID,ControllerID,PointType,PointID,CardID,EventCodeID,EventDateTime)"); strSql.Append(" values ("); strSql.Append("@EventID,@ControllerID,@PointType,@PointID,@CardID,@EventCodeID,@EventDateTime)"); SQLiteParameter[] parameters = { new SQLiteParameter("@EventID", DbType.Int32, 4), new SQLiteParameter("@ControllerID", DbType.Int32, 4), new SQLiteParameter("@PointType", DbType.Int32, 4), new SQLiteParameter("@PointID", DbType.Int32, 4), new SQLiteParameter("@CardID", DbType.String), new SQLiteParameter("@EventCodeID", DbType.Int32, 4), new SQLiteParameter("@EventDateTime", DbType.String) }; parameters[0].Value = model.EventID; parameters[1].Value = model.ControllerID; parameters[2].Value = model.PointType; parameters[3].Value = model.PointID; parameters[4].Value = model.CardID; parameters[5].Value = model.EventCodeID; parameters[6].Value = model.EventDateTime; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.SQLite.Model.InteractRelation.EventInfo DataRowToModel(DataRow row) { KryptonAccessController.SQLite.Model.InteractRelation.EventInfo model = new KryptonAccessController.SQLite.Model.InteractRelation.EventInfo(); if (row != null) { if (row["EventID"] != null && row["EventID"].ToString() != "") { model.EventID = int.Parse(row["EventID"].ToString()); } if (row["ControllerID"] != null && row["ControllerID"].ToString() != "") { model.ControllerID = int.Parse(row["ControllerID"].ToString()); } if (row["PointType"] != null && row["PointType"].ToString() != "") { model.PointType = int.Parse(row["PointType"].ToString()); } if (row["PointID"] != null && row["PointID"].ToString() != "") { model.PointID = int.Parse(row["PointID"].ToString()); } if (row["CardID"] != null) { model.CardID = row["CardID"].ToString(); } if (row["EventCodeID"] != null && row["EventCodeID"].ToString() != "") { model.EventCodeID = int.Parse(row["EventCodeID"].ToString()); } if (row["EventDateTime"] != null) { model.EventDateTime = row["EventDateTime"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.SQLite.Model.InteractRelation.EventInfo GetModel(int EventID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select EventID,ControllerID,PointType,PointID,CardID,EventCodeID,EventDateTime from EventInfo "); strSql.Append(" where EventID=@EventID "); SQLiteParameter[] parameters = { new SQLiteParameter("@EventID", DbType.Int32, 4) }; parameters[0].Value = EventID; KryptonAccessController.SQLite.Model.InteractRelation.EventInfo model = new KryptonAccessController.SQLite.Model.InteractRelation.EventInfo(); DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.SQLite.Model.InteractRelation.EventInfo DataRowToModel(DataRow row) { KryptonAccessController.SQLite.Model.InteractRelation.EventInfo model=new KryptonAccessController.SQLite.Model.InteractRelation.EventInfo(); if (row != null) { if(row["EventID"]!=null && row["EventID"].ToString()!="") { model.EventID=int.Parse(row["EventID"].ToString()); } if(row["ControllerID"]!=null && row["ControllerID"].ToString()!="") { model.ControllerID=int.Parse(row["ControllerID"].ToString()); } if(row["PointType"]!=null && row["PointType"].ToString()!="") { model.PointType=int.Parse(row["PointType"].ToString()); } if(row["PointID"]!=null && row["PointID"].ToString()!="") { model.PointID=int.Parse(row["PointID"].ToString()); } if(row["CardID"]!=null) { model.CardID=row["CardID"].ToString(); } if(row["EventCodeID"]!=null && row["EventCodeID"].ToString()!="") { model.EventCodeID=int.Parse(row["EventCodeID"].ToString()); } if(row["EventDateTime"]!=null) { model.EventDateTime=row["EventDateTime"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.SQLite.Model.InteractRelation.EventInfo GetModel(int EventID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select EventID,ControllerID,PointType,PointID,CardID,EventCodeID,EventDateTime from EventInfo "); strSql.Append(" where EventID=@EventID "); SQLiteParameter[] parameters = { new SQLiteParameter("@EventID", DbType.Int32,4) }; parameters[0].Value = EventID; KryptonAccessController.SQLite.Model.InteractRelation.EventInfo model=new KryptonAccessController.SQLite.Model.InteractRelation.EventInfo(); DataSet ds=DbHelperSQLite.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }