public bool Delete(ActivityApplyInfo model) { Database db = DBHelper.CreateDataBase(); StringBuilder sb = new StringBuilder(); sb.Append("delete from ActivityApply"); sb.Append(" where Id=@Id"); DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString()); db.AddInParameter(dbCommand, "@Id", DbType.Int32, model.Id); return(db.ExecuteNonQuery(dbCommand) < 1 ? false : true); }
public bool Update(ActivityApplyInfo model) { Database db = DBHelper.CreateDataBase(); StringBuilder sb = new StringBuilder(); sb.Append("update ActivityApply set "); sb.Append("ActivityId=@ActivityId,UserId=@UserId,StarId=@StarId,Status=@Status,CreateDate=@CreateDate,CreateIP=@CreateIP"); sb.Append(" where Id=@Id"); DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString()); db.AddInParameter(dbCommand, "@Id", DbType.Int32, model.Id); db.AddInParameter(dbCommand, "@ActivityId", DbType.Int32, model.ActivityId); db.AddInParameter(dbCommand, "@UserId", DbType.Int32, model.UserId); db.AddInParameter(dbCommand, "@StarId", DbType.Int32, model.StarId); db.AddInParameter(dbCommand, "@Status", DbType.Int32, model.Status); db.AddInParameter(dbCommand, "@CreateDate", DbType.DateTime, model.CreateDate); db.AddInParameter(dbCommand, "@CreateIP", DbType.String, model.CreateIP); return(db.ExecuteNonQuery(dbCommand) < 1 ? false : true); }
private ActivityApplyInfo FillList(IDataReader dataReader) { ActivityApplyInfo model = new ActivityApplyInfo(); object ojb; ojb = dataReader["Id"]; if (ojb != null && ojb != DBNull.Value) { model.Id = ( int)(ojb); } ojb = dataReader["ActivityId"]; if (ojb != null && ojb != DBNull.Value) { model.ActivityId = ( int)(ojb); } ojb = dataReader["UserId"]; if (ojb != null && ojb != DBNull.Value) { model.UserId = ( int)(ojb); } ojb = dataReader["StarId"]; if (ojb != null && ojb != DBNull.Value) { model.StarId = ( int)(ojb); } ojb = dataReader["Status"]; if (ojb != null && ojb != DBNull.Value) { model.Status = ( int)(ojb); } ojb = dataReader["CreateDate"]; if (ojb != null && ojb != DBNull.Value) { model.CreateDate = ( DateTime)(ojb); } ojb = dataReader["CreateIP"]; if (ojb != null && ojb != DBNull.Value) { model.CreateIP = ( string)(ojb); } return(model); }
public ActivityApplyInfo Get(int Id) { Database db = DBHelper.CreateDataBase(); StringBuilder sb = new StringBuilder(); sb.Append("select * from ActivityApply where Id=@Id"); DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString()); db.AddInParameter(dbCommand, "@Id", DbType.Int32, Id); ActivityApplyInfo model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = FillList(dataReader); } } return(model); }
public int Create(ActivityApplyInfo model) { Database db = DBHelper.CreateDataBase(); StringBuilder sb = new StringBuilder(); sb.Append("insert into ActivityApply("); sb.Append("ActivityId,UserId,StarId,Status,CreateDate,CreateIP"); sb.Append(") values("); sb.Append("@ActivityId,@UserId,@StarId,@Status,@CreateDate,@CreateIP);SELECT @@IDENTITY;"); DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString()); db.AddInParameter(dbCommand, "@ActivityId", DbType.Int32, model.ActivityId); db.AddInParameter(dbCommand, "@UserId", DbType.Int32, model.UserId); db.AddInParameter(dbCommand, "@StarId", DbType.Int32, model.StarId); db.AddInParameter(dbCommand, "@Status", DbType.Int32, model.Status); db.AddInParameter(dbCommand, "@CreateDate", DbType.DateTime, model.CreateDate); db.AddInParameter(dbCommand, "@CreateIP", DbType.String, model.CreateIP); int id = Convert.ToInt32(db.ExecuteScalar(dbCommand)); return(id); }
public bool Delete(ActivityApplyInfo model) { return(dal.Delete(model)); }
public bool Update(ActivityApplyInfo model) { return(dal.Update(model)); }
public int Create(ActivityApplyInfo model) { int id = dal.Create(model); return(id); }