public int AddApply(Nairc.KpwFramework.DataModel.Apply apply) { Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "INSERT INTO [Kpw_Applies] ([UserId],[ApplyDate],[TimeRange]," + "[ApplyStatus],[DateCreated])" + " VALUES(@UserId,@ApplyDate,@TimeRange,@ApplyStatus,@DateCreated)"; DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand); db.AddInParameter(dbCommand, "UserId", DbType.String, apply.UserId); db.AddInParameter(dbCommand, "ApplyDate", DbType.DateTime, apply.ApplyDate); db.AddInParameter(dbCommand, "TimeRange", DbType.Int32, apply.TimeRange); db.AddInParameter(dbCommand, "ApplyStatus", DbType.Int32, apply.ApplyStatus); db.AddInParameter(dbCommand, "DateCreated", DbType.DateTime, apply.CreatedDate); return db.ExecuteNonQuery(dbCommand); }
public void UpdateApply(Nairc.KpwFramework.DataModel.Apply apply) { Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "UPDATE [Kpw_Applies]" + "SET [UserId] = @UserId" + ",[ApplyDate] = @ApplyDate" + ",[TimeRange] = @TimeRange" + ",[ApplyStatus] = @ApplyStatus" + ",[DateCreated] = @DateCreated" + " WHERE [ID] = @ID"; DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand); // Retrieve products from the specified category. db.AddInParameter(dbCommand, "ID", DbType.Int32, apply.ID); db.AddInParameter(dbCommand, "UserId", DbType.String, apply.UserId); db.AddInParameter(dbCommand, "ApplyDate", DbType.DateTime, apply.ApplyDate); db.AddInParameter(dbCommand, "TimeRange", DbType.Int32, apply.TimeRange); db.AddInParameter(dbCommand, "ApplyStatus", DbType.Int32, apply.ApplyStatus); db.AddInParameter(dbCommand, "DateCreated", DbType.DateTime, apply.CreatedDate); db.ExecuteNonQuery(dbCommand); }